Class JdbcSchemaCreator

java.lang.Object
io.deephaven.importers.JdbcSchemaCreator

@Immutable public abstract class JdbcSchemaCreator extends Object
Reads a JDBC result set and attempts to infer column data types and create appropriate schema and importer instructions. Also legalizes column names and adds corresponding ImportColumn entries for translation of column names.
  • Constructor Details

    • JdbcSchemaCreator

      public JdbcSchemaCreator()
  • Method Details

    • builder

      public static JdbcSchemaCreator.Builder builder()
      Creates a builder for JdbcSchemaCreator.
      Returns:
      the new builder
    • logger

      @Default protected Logger logger()
    • progress

      @Default protected io.deephaven.shadow.enterprise.com.illumon.util.progress.StatusCallback progress()
    • namespace

      protected abstract String namespace()
    • tableName

      protected abstract String tableName()
    • groupingColumn

      protected abstract Optional<String> groupingColumn()
    • partitionColumn

      protected abstract Optional<String> partitionColumn()
    • sourceName

      protected abstract String sourceName()
    • jdbcDriver

      protected abstract Optional<String> jdbcDriver()
    • connectionUrl

      protected abstract Optional<String> connectionUrl()
    • user

      protected abstract Optional<String> user()
    • password

      protected abstract Optional<String> password()
    • sqlQuery

      protected abstract Optional<String> sqlQuery()
    • outPackage

      protected abstract Optional<String> outPackage()
    • schemaPath

      protected abstract Optional<String> schemaPath()
    • assessmentMethod

      @Default protected JdbcSchemaCreator.AssessmentMethod assessmentMethod()
    • sourcePartitionColumn

      protected abstract Optional<String> sourcePartitionColumn()
    • importStyle

      @Default protected ImportStyle importStyle()
    • bestFit

      @Default protected boolean bestFit()
    • casingStyle

      @Default protected CasingStyle casingStyle()
    • replacement

      @Default protected String replacement()
    • arrayDelimiter

      @Default protected String arrayDelimiter()
    • outputMode

      @Default protected SchemaCreatorUtils.OutputMode outputMode()
    • logFormat

      @Default protected int logFormat()
    • maxError

      @Default protected int maxError()
    • useNanos

      @Default protected boolean useNanos()
    • resultSet

      protected abstract Optional<ResultSet> resultSet()
    • checkJdbcDetails

      @Check protected void checkJdbcDetails()
    • getTableImportSchemaDocument

      public static io.deephaven.shadow.enterprise.org.jdom2.Document getTableImportSchemaDocument(Logger log, Connection connection, ResultSetMetaData resultSetMetaData, String namespace, String tableName, String groupingColumn, String partitionColumn, String sourceName, ImportStyle importStyle, String sourcePartitionColumn, String outPackage, CasingStyle casingStyle, String replacement, int logFormat, boolean useNanos, int maxError, String arrayDelimiter, Map<String,Class<?>> targetTypeMap)
      Parameters:
      log - the Logger to use
      connection - the JDBC Connection
      resultSetMetaData - the JDBC ResultSetMetaData
      namespace - the target namespace
      tableName - the target table name
      groupingColumn - the grouping column
      partitionColumn - the partition column
      sourceName - the import source name
      importStyle - the ImportStyle
      sourcePartitionColumn - the source partition column
      outPackage - the output package for loggers/listeners
      casingStyle - the CasingStyle
      replacement - the replacement string for invalid characters in column names
      logFormat - the log format
      useNanos - whether to use nanos for time calculations
      maxError - the maximum allowed errors, only used to add to the schema's import source
      arrayDelimiter - the array delimiter, only used to add to the schema's import source
      targetTypeMap - a map of target column names to desired Java types
      Returns:
      the schema Document
    • inferSchemaFromJdbc

      public String inferSchemaFromJdbc() throws SQLException
      Infer the schema.
      Returns:
      a String containing the inferred schema
      Throws:
      SQLException - from the underlying JDBC calls