sqlline
sqlline copied to clipboard
Feature Request: Specify JDBC driver class version
I unfortunately have a driver I need to use that has 3 versions for 3 clusters. I don't see a way to specify -d <driver_class>:<version>
Use case: Hive JDBC connections use the hive-standalone jar seen on:https://repo.hortonworks.com/content/repositories/releases/org/apache/hive/hive-jdbc
We have 3 clusters, two of which have Hive 1.2/2.1 and the other has Hive 3. This leaves me with:
hive-jdbc-1.2.1000.2.6.5.90-1-standalone.jar hive-jdbc-2.1.0.2.6.5.90-1-standalone.jar hive-jdbc-3.1.0.3.1.4.6-1-standalone.jar
The problem is each hive standalone jar has the same class and I don't see a way to specify them specifically with sqlline's -d
option. Adding bash arguments is tough, as you need to push all arguments at the end to sqlline anyway.
$ cat test/META-INF/services/java.sql.Driver
org.apache.hive.jdbc.HiveDriver
BINPATH=$(dirname $0)
exec java -cp "$BINPATH/../target/*" sqlline.SqlLine "$@"
I feel it should be possible to specify the driver version, as it almost always visible fine in the JAR metadata.
I agree this would be useful. But I don't know how to achieve this within the Java code. The easiest way for you to achieve this is to edit the classpath in the shell script.
That's true, but in order for things to by dynamic for end-users, it's hard to do that. It's most certainly wishful thinking and thought i'd at least put it out there.
As a compromise for the time being, would it be possible to allow passthrough of --driver-jar something-1.0.0
? This would allow dynamic loading.
What APIs were you thinking of using to dynamically load a jar?
Oh no, I just mean to code a switcher to dynamically add a jar to the classpath in lieu of the other option. For example, we have a Hadoop Hive environment that has Hive 1.2 and Hive 2 yet, so dynamically loading things is tough unless I can say "load this only" or "load driver_class:version". Unfortunately the hive standalone drivers are the best compatible set vs. Simba drivers.
The easiest way to do that would be to modify the sqlline
shell script. I suppose you could add command-line arguments that control how the shell script builds its classpath before it launches the JVM.
I don't know how many JDBC drivers these days implement OSGI. My understanding is that OSGI would allow you to choose the right version; another connection in the same JVM might even use a different version.
I thought about just putting in positional bash arguments, but the problem is the "$@" at the end that passes all the args in to sqlline. Say you code --driver-jar SOMETHING
, that will still get passed to the final args unless you somehow strip it. Maybe I can come up with something funky after I play around.