Hey David,

Your understanding so far is correct and you are pretty close in making it work.

Indeed, the JDBC URL should start with "jdbc:calcite" if you are to
use the Calcite JDBC driver but for this to happen the driver needs to
be loaded. If you are using some of the recent Calcite versions and
Java version >= 6 normally the registration should happen
transparently since Calcite is using the automatic driver registration
features of JDBC 4 which relies on Java SPI.

The Calcite JDBC driver itself is in the core module but the latter is
not self-contained and has dependencies on other libraries and
modules. For things to work all required dependencies must be in the
classpath as well otherwise you will encounter ClassNotFoundException
and other similar errors; it is plausible that some errors are already
happening in the background and that's why the driver is not loaded.

Sometime ago Gavin wrote a nice post on how to make Calcite work with
SQuirreL [1] which seems pretty close to what you are trying to
achieve.

Best,
Stamatis

[1] https://gist.github.com/GavinRay97/44fcd0f17e5c62ed6e7880fed0b0042e

On Wed, Aug 21, 2024 at 1:11 AM David Ventimiglia
<davidaventimig...@hasura.io.invalid> wrote:
>
> Hello!
>
> The Calcite tutorial <https://calcite.apache.org/docs/tutorial.html> shows
> how to use a custom sqlline to connect to the Calcite JDBC driver with a
> model.json to use a simple adapter that makes a directory of CSV files
> appear to be a schema containing tables.  Later, the tutorial shows what I
> think is a model.json file for using the JDBC Adapter
> <https://calcite.apache.org/docs/tutorial.html#jdbc-adapter> but I don't
> really understand how to use it.  Evidently, there's a Calcite JDBC driver
> that can handle JDBC URLs of the form "jdbc:calcite:model=model.json".
> Given that, I feel like using the JDBC adapter might be as easy as
> substituting a suitable model.json file, like the one for MySQL in the
> tutorial, but that might be overly optimistic.  For that really to work,
> the Calcite JDBC driver would have to be on the classpath as well as the
> MySQL driver (or PostgreSQL driver, or whatever) and I can't figure out how
> to arrange that.  It's easy enough to put the database drivers into the
> CLASSPATH environment variable, but where is the Calcite JDBC driver?  I
> tried adding calcite/core/build/libs/calcite-core-1.38.0-SNAPSHOT.jar to
> CLASSPATH and using the stock (unmodified) sqlline, but it failed to pick
> up the driver, and now I'm wondering if this is even the right approach.
> I'm really kinda lost here and any help would be appreciated.  Thanks!
>
> Best,
> David

Reply via email to