Class JdbcDriver

  • All Implemented Interfaces:
    java.sql.Driver

    @AutoService(java.sql.Driver.class)
    public class JdbcDriver
    extends org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.jdbc.Driver
    Calcite JDBC driver with Beam defaults.

    Connection URLs have this form:

    jdbc:beam:param1=value1;param2=value2;param3=value3

    The querystring-style parameters are parsed as PipelineOptions.

    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.avatica.UnregisteredDriver

        org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.avatica.UnregisteredDriver.JdbcVersion
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CONNECT_STRING_PREFIX  
      static JdbcDriver INSTANCE  
      • Fields inherited from class org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.jdbc.Driver

        prepareFactory
      • Fields inherited from class org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.avatica.UnregisteredDriver

        factory, handler
    • Constructor Summary

      Constructors 
      Constructor Description
      JdbcDriver()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @Nullable java.sql.Connection connect​(java.lang.String url, java.util.Properties info)
      Configures Beam-specific options and opens a JDBC connection to Calcite.
      static JdbcConnection connect​(CatalogManager catalogManager, org.apache.beam.sdk.options.PipelineOptions options)
      Like connect(TableProvider, PipelineOptions), but overrides the top-level schema with a CatalogManager.
      static JdbcConnection connect​(TableProvider tableProvider, org.apache.beam.sdk.options.PipelineOptions options)
      Connects to the driver using standard connect(String, Properties) call, but overrides the initial schema factory.
      protected org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.avatica.AvaticaFactory createFactory()  
      protected java.lang.String getConnectStringPrefix()  
      • Methods inherited from class org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.jdbc.Driver

        createDriverVersion, createHandler, createMeta, createPrepare, createPrepareFactory, getConnectionProperties, getFactoryClassName, withPrepareFactory
      • Methods inherited from class org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.avatica.UnregisteredDriver

        acceptsURL, getDriverVersion, getMajorVersion, getMinorVersion, getParentLogger, getPropertyInfo, instantiateFactory, jdbcCompliant, register
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INSTANCE

        public static final JdbcDriver INSTANCE
      • CONNECT_STRING_PREFIX

        public static final java.lang.String CONNECT_STRING_PREFIX
        See Also:
        Constant Field Values
    • Constructor Detail

      • JdbcDriver

        public JdbcDriver()
    • Method Detail

      • createFactory

        protected org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.avatica.AvaticaFactory createFactory()
        Overrides:
        createFactory in class org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.avatica.UnregisteredDriver
      • getConnectStringPrefix

        protected java.lang.String getConnectStringPrefix()
        Overrides:
        getConnectStringPrefix in class org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.jdbc.Driver
      • connect

        public @Nullable java.sql.Connection connect​(java.lang.String url,
                                                     java.util.Properties info)
                                              throws java.sql.SQLException
        Configures Beam-specific options and opens a JDBC connection to Calcite.

        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.

        Specified by:
        connect in interface java.sql.Driver
        Overrides:
        connect in class org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.avatica.UnregisteredDriver
        Throws:
        java.sql.SQLException
      • connect

        public static JdbcConnection connect​(TableProvider tableProvider,
                                             org.apache.beam.sdk.options.PipelineOptions options)
        Connects to the driver using standard 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.