@AutoService(value=java.sql.Driver.class)
public class JdbcDriver
extends org.apache.calcite.jdbc.Driver
Connection URLs have this form:
jdbc:beam:param1=value1;param2=value2;param3=value3
The querystring-style parameters are parsed as PipelineOptions
.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CONNECT_STRING_PREFIX |
static JdbcDriver |
INSTANCE |
Constructor and Description |
---|
JdbcDriver() |
Modifier and Type | Method and Description |
---|---|
java.sql.Connection |
connect(java.lang.String url,
java.util.Properties originalConnectionProperties)
Configures Beam-specific options and opens a JDBC connection to Calcite.
|
static JdbcConnection |
connect(TableProvider tableProvider)
Connects to the driver using standard
connect(String, Properties) call, but overrides
the initial schema factory. |
protected java.lang.String |
getConnectStringPrefix() |
createDriverVersion, createHandler, createMeta, createPrepareFactory, getConnectionProperties, getFactoryClassName
public static final JdbcDriver INSTANCE
public static final java.lang.String CONNECT_STRING_PREFIX
protected java.lang.String getConnectStringPrefix()
getConnectStringPrefix
in class org.apache.calcite.jdbc.Driver
public java.sql.Connection connect(java.lang.String url, java.util.Properties originalConnectionProperties) throws java.sql.SQLException
If originalConnectionProperties
doesn't have the Beam-specific properties, populates
them with defaults (e.g. sets the default schema name to "beam").
Returns null if url
doesn't begin with CONNECT_STRING_PREFIX
. This seems to
be how JDBC decides whether a driver can handle a request. It tries to connect to it, and if
the result is null it picks another driver.
Returns an instance of JdbcConnection
which is a Beam wrapper around CalciteConnection
.
connect
in interface java.sql.Driver
connect
in class org.apache.calcite.avatica.UnregisteredDriver
java.sql.SQLException
public static JdbcConnection connect(TableProvider tableProvider)
connect(String, Properties)
call, but overrides
the initial schema factory. Default factory would load up all table providers. The one
specified here doesn't load any providers. We then override the top-level schema with the
tableProvider
.
This is called in tests and BeamSqlEnv
, core part of SqlTransform
. CLI uses
standard JDBC driver registry, and goes through connect(String, Properties)
instead,
not this path. The CLI ends up using the schema factory that populates the default schema with
all table providers it can find. See BeamCalciteSchemaFactory
.