Class BaseColumnMetadataReader

    • Constructor Detail

      • BaseColumnMetadataReader

        public BaseColumnMetadataReader​(Connection connection,
                                        com.exasol.adapter.AdapterProperties properties,
                                        com.exasol.ExaMetadata exaMetadata,
                                        IdentifierConverter identifierConverter)
        Create a new instance of a ColumnMetadataReader.
        Parameters:
        connection - JDBC connection through which the column metadata is read from the remote database
        properties - user-defined adapter properties
        exaMetadata - metadata of the Exasol database
        identifierConverter - converter between source and Exasol identifiers
    • Method Detail

      • supportsTimestampsWithNanoPrecision

        protected boolean supportsTimestampsWithNanoPrecision()
        Whether the Exasol database supports timestamp with precision up to nanoseconds.
        Returns:
        true if Exasol database supports timestamps with nanoseconds precision false otherwise.
      • mapColumns

        public List<com.exasol.adapter.metadata.ColumnMetadata> mapColumns​(String tableName)
        Map a metadata for a list of columns to Exasol metadata.
        Specified by:
        mapColumns in interface ColumnMetadataReader
        Parameters:
        tableName - the table for which the columns are mapped
        Returns:
        list of Exasol column metadata objects
      • mapColumns

        protected List<com.exasol.adapter.metadata.ColumnMetadata> mapColumns​(String catalogName,
                                                                              String schemaName,
                                                                              String tableName)
        Read the columns metadata from a result set.
        Parameters:
        catalogName - catalog name
        schemaName - schema name
        tableName - table name
        Returns:
        list with column metadata
      • getColumnMetadata

        protected ResultSet getColumnMetadata​(String catalogName,
                                              String schemaName,
                                              String tableName)
                                       throws SQLException
        Read column metadata from JDBC driver escaping potential SQL wild cards in the names of schema and table.
        Parameters:
        catalogName - catalog name
        schemaName - schema name, potential SQL wildcards will be escaped
        tableName - table name, potential SQL wildcards will be escaped
        Returns:
        list with metadata for all columns of the respective catalog, schema, and table
        Throws:
        SQLException - in case of failures
      • getColumnMetadataAllowingPatterns

        protected ResultSet getColumnMetadataAllowingPatterns​(String catalogName,
                                                              String schemaNamePattern,
                                                              String tableNamePattern)
                                                       throws SQLException
        Read column metadata from JDBC driver without escaping potential SQL wild cards in the names of schema and table.
        Parameters:
        catalogName - catalog name
        schemaNamePattern - schema name pattern, may contain SQL wildcards
        tableNamePattern - table name pattern, may contain SQL wildcards
        Returns:
        list with metadata for all columns of the respective catalog, matching schema name pattern, and table name pattern
        Throws:
        SQLException - in case of failures
      • getColumnsFromResultSet

        protected List<com.exasol.adapter.metadata.ColumnMetadata> getColumnsFromResultSet​(ResultSet remoteColumns)
                                                                                    throws SQLException
        Read the columns result set.
        Parameters:
        remoteColumns - column result set.
        Returns:
        list of column metadata
        Throws:
        SQLException - if read fails
      • mapOrSkipColumn

        public void mapOrSkipColumn​(ResultSet remoteColumns,
                                    List<com.exasol.adapter.metadata.ColumnMetadata> columns)
                             throws SQLException
        Read the column metadata from result set if supported. Otherwise, skip.
        Parameters:
        remoteColumns - column result set
        columns - list to append column to
        Throws:
        SQLException - if read fails
      • readJdbcTypeDescription

        public JDBCTypeDescription readJdbcTypeDescription​(ResultSet remoteColumn)
                                                    throws SQLException
        Read the JDBC type description of a column.
        Parameters:
        remoteColumn - result set column
        Returns:
        JDBC type description
        Throws:
        SQLException - if read fails
      • isRemoteColumnNullable

        protected boolean isRemoteColumnNullable​(ResultSet remoteColumn,
                                                 String columnName)
        Check if a column a nullable.
        Parameters:
        remoteColumn - column result set
        columnName - column name
        Returns:
        true if remote column is nullable
      • readColumnName

        protected String readColumnName​(ResultSet columns)
                                 throws SQLException
        Read the column name form result set.
        Parameters:
        columns - column result set
        Returns:
        column name
        Throws:
        SQLException - if read fails
      • mapJdbcType

        public com.exasol.adapter.metadata.DataType mapJdbcType​(JDBCTypeDescription jdbcTypeDescription)
        Description copied from interface: ColumnMetadataReader
        Map type information from JDBC to the Exasol type information.

        Override this method in a dedicated mapper if you need dialect specific behavior.

        Specified by:
        mapJdbcType in interface ColumnMetadataReader
        Parameters:
        jdbcTypeDescription - parameter object describing the type from the JDBC perspective
        Returns:
        Exasol data type information
      • convertDecimal

        protected com.exasol.adapter.metadata.DataType convertDecimal​(int jdbcPrecision,
                                                                      int scale)
        Build a data type for a decimal value.
        Parameters:
        jdbcPrecision - precision
        scale - scale
        Returns:
        built data type
      • mapColumnName

        protected String mapColumnName​(String columnName)
        Convert the column name.
        Parameters:
        columnName - column name
        Returns:
        column name
      • mapJdbcTypeNumericToDecimalWithFallbackToDouble

        protected com.exasol.adapter.metadata.DataType mapJdbcTypeNumericToDecimalWithFallbackToDouble​(JDBCTypeDescription jdbcTypeDescription)
        Map a NUMERIC column to an Exasol DECIMAL

        If the precision of the remote column exceeds the maximum precision of an Exasol DECIMAL, the column is mapped to an Exasol DOUBLE instead.

        Parameters:
        jdbcTypeDescription - parameter object describing the type from the JDBC perspective
        Returns:
        Exasol DECIMAL if precision is less than or equal maximum precision, DOUBLE otherwise.
      • getNumberTypeFromProperty

        protected com.exasol.adapter.metadata.DataType getNumberTypeFromProperty​(String property)
        Parse a number type property.
        Parameters:
        property - formatted string: <precision>,<scale>
        Returns:
        data type