Package com.exasol.adapter.jdbc
Class BaseTableMetadataReader
- java.lang.Object
-
- com.exasol.adapter.jdbc.AbstractMetadataReader
-
- com.exasol.adapter.jdbc.BaseTableMetadataReader
-
- All Implemented Interfaces:
MetadataReader,TableMetadataReader
public class BaseTableMetadataReader extends AbstractMetadataReader implements TableMetadataReader
This class maps metadata of tables from the remote source to Exasol.
-
-
Field Summary
Fields Modifier and Type Field Description protected ColumnMetadataReadercolumnMetadataReaderColumn metadata reader-
Fields inherited from class com.exasol.adapter.jdbc.AbstractMetadataReader
connection, exaMetadata, properties
-
-
Constructor Summary
Constructors Constructor Description BaseTableMetadataReader(Connection connection, ColumnMetadataReader columnMetadataReader, com.exasol.adapter.AdapterProperties properties, com.exasol.ExaMetadata exaMetadata, IdentifierConverter identifierConverter)Create a new instance of aTableMetadata.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringadjustIdentifierCase(String tableName)Convert the given identifier to the proper casing using the underlyingIdentifierConverter.protected booleanincludeAllTables(List<String> filteredTables)Check if no tables are filtered.booleanisTableIncludedByMapping(String tableName)Returns true if the metadata reader includes the table with the given name when the remote metadata gets mapped table name.protected booleanisTableSupported(List<String> filteredTables, String tableName)Check if a table is supported.protected booleanisUnquotedIdentifier(String identifier)Check if an identifier is unquoted.protected voidlogSkippingTableWithEmptyColumns(String tableName)Log the skipping of a table with no columns.protected voidlogSkippingUnsupportedTable(String tableName)Log the skipping of an unsupported table.protected com.exasol.adapter.metadata.TableMetadatamapTable(ResultSet table, String tableName)Read the table metadata from a result set.List<com.exasol.adapter.metadata.TableMetadata>mapTables(ResultSet remoteTables, List<String> filteredTables)Map a list of tables found in a JDBC result set to a list ofTableMetadata.protected StringreadComment(ResultSet remoteTables)Read the comment from a result set.protected StringreadTableName(ResultSet remoteTables)Read the table name from a result set.protected booleantableHasColumns(com.exasol.adapter.metadata.TableMetadata tableMetadata)Check if a table has columns.-
Methods inherited from class com.exasol.adapter.jdbc.AbstractMetadataReader
getCatalogNameFilter, getSchemaNameFilter
-
-
-
-
Field Detail
-
columnMetadataReader
protected ColumnMetadataReader columnMetadataReader
Column metadata reader
-
-
Constructor Detail
-
BaseTableMetadataReader
public BaseTableMetadataReader(Connection connection, ColumnMetadataReader columnMetadataReader, com.exasol.adapter.AdapterProperties properties, com.exasol.ExaMetadata exaMetadata, IdentifierConverter identifierConverter)
Create a new instance of aTableMetadata.- Parameters:
connection- JDBC connection to remote data sourcecolumnMetadataReader- reader to be used to map the tables columnsproperties- user-defined adapter propertiesexaMetadata- metadata of the Exasol databaseidentifierConverter- converter between source and Exasol identifiers
-
-
Method Detail
-
mapTables
public List<com.exasol.adapter.metadata.TableMetadata> mapTables(ResultSet remoteTables, List<String> filteredTables) throws SQLException
Description copied from interface:TableMetadataReaderMap a list of tables found in a JDBC result set to a list ofTableMetadata.- Specified by:
mapTablesin interfaceTableMetadataReader- Parameters:
remoteTables- result set containing the tables to be mappedfilteredTables- list of tables name that is used to narrow down the mapping- Returns:
- list of
TableMetadata - Throws:
SQLException- if either mapping the table or its columns produces an SQL error
-
readTableName
protected String readTableName(ResultSet remoteTables) throws SQLException
Read the table name from a result set.- Parameters:
remoteTables- result set- Returns:
- table name
- Throws:
SQLException- if something goes wrong
-
mapTable
protected com.exasol.adapter.metadata.TableMetadata mapTable(ResultSet table, String tableName) throws SQLException
Read the table metadata from a result set.- Parameters:
table- result settableName- table to read (name)- Returns:
- table metadata
- Throws:
SQLException- if reading fails
-
adjustIdentifierCase
protected String adjustIdentifierCase(String tableName)
Convert the given identifier to the proper casing using the underlyingIdentifierConverter.- Parameters:
tableName- Table name as provided by source- Returns:
- Table name as required by the virtual schema host database
-
readComment
protected String readComment(ResultSet remoteTables) throws SQLException
Read the comment from a result set.- Parameters:
remoteTables- result set- Returns:
- comment
- Throws:
SQLException- if something goes wrong
-
tableHasColumns
protected boolean tableHasColumns(com.exasol.adapter.metadata.TableMetadata tableMetadata)
Check if a table has columns.- Parameters:
tableMetadata- table metadata- Returns:
trueif table has columns
-
isTableSupported
protected boolean isTableSupported(List<String> filteredTables, String tableName)
Check if a table is supported.- Parameters:
filteredTables- filtered tablestableName- table to check- Returns:
trueif table is supported
-
isTableIncludedByMapping
public boolean isTableIncludedByMapping(String tableName)
Description copied from interface:TableMetadataReaderReturns true if the metadata reader includes the table with the given name when the remote metadata gets mapped table name.- Specified by:
isTableIncludedByMappingin interfaceTableMetadataReader- Parameters:
tableName- name of the table- Returns:
trueif the reader includes the the mapping,falseif it is ignored
-
logSkippingUnsupportedTable
protected void logSkippingUnsupportedTable(String tableName)
Log the skipping of an unsupported table.- Parameters:
tableName- table name
-
includeAllTables
protected boolean includeAllTables(List<String> filteredTables)
Check if no tables are filtered.- Parameters:
filteredTables- filtered tables- Returns:
trueif no filter is applied
-
logSkippingTableWithEmptyColumns
protected void logSkippingTableWithEmptyColumns(String tableName)
Log the skipping of a table with no columns.- Parameters:
tableName- table name
-
isUnquotedIdentifier
protected boolean isUnquotedIdentifier(String identifier)
Check if an identifier is unquoted.- Parameters:
identifier- identifier to check- Returns:
trueif it's unquoted
-
-