Class Db2MetadataHandler
- java.lang.Object
-
- com.amazonaws.athena.connector.lambda.handlers.MetadataHandler
-
- com.amazonaws.athena.connectors.jdbc.manager.JdbcMetadataHandler
-
- com.amazonaws.athena.connectors.db2.Db2MetadataHandler
-
- All Implemented Interfaces:
FederationRequestHandler,com.amazonaws.services.lambda.runtime.RequestStreamHandler
public class Db2MetadataHandler extends JdbcMetadataHandler
-
-
Field Summary
-
Fields inherited from class com.amazonaws.athena.connectors.jdbc.manager.JdbcMetadataHandler
caseResolver, jdbcQueryPassthrough, TABLES_AND_VIEWS
-
Fields inherited from class com.amazonaws.athena.connector.lambda.handlers.MetadataHandler
configOptions, DISABLE_SPILL_ENCRYPTION, KMS_KEY_ID_ENV, SPILL_BUCKET_ENV, SPILL_PREFIX_ENV
-
-
Constructor Summary
Constructors Modifier Constructor Description Db2MetadataHandler(DatabaseConnectionConfig databaseConnectionConfig, JdbcConnectionFactory jdbcConnectionFactory, Map<String,String> configOptions)To be used by Mux.Db2MetadataHandler(DatabaseConnectionConfig databaseConnectionConfig, Map<String,String> configOptions)TO be used by Mux.protectedDb2MetadataHandler(DatabaseConnectionConfig databaseConnectionConfig, software.amazon.awssdk.services.secretsmanager.SecretsManagerClient secretsManager, software.amazon.awssdk.services.athena.AthenaClient athena, JdbcConnectionFactory jdbcConnectionFactory, Map<String,String> configOptions, JDBCCaseResolver caseResolver)Db2MetadataHandler(Map<String,String> configOptions)Instantiates handler to be used by Lambda function directly.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GetDataSourceCapabilitiesResponsedoGetDataSourceCapabilities(BlockAllocator allocator, GetDataSourceCapabilitiesRequest request)Overridden this method to describe the types of capabilities supported by a data sourceGetSplitsResponsedoGetSplits(BlockAllocator blockAllocator, GetSplitsRequest getSplitsRequest)Split(s) will be created based on table partition.ListSchemasResponsedoListSchemaNames(BlockAllocator blockAllocator, ListSchemasRequest listSchemasRequest)Overridden this method to fetch only user defined schema(s) in Athena Data window.protected List<TableName>getPaginatedTables(Connection connection, String databaseName, int offset, int limit)voidgetPartitions(BlockWriter blockWriter, GetTableLayoutRequest getTableLayoutRequest, QueryStatusChecker queryStatusChecker)A partition is represented by a partition column(s) of type varchar.org.apache.arrow.vector.types.pojo.SchemagetPartitionSchema(String catalogName)Creates Schema object with arrow compatible filed to frame the partition.protected org.apache.arrow.vector.types.pojo.SchemagetSchema(Connection jdbcConnection, TableName tableName, org.apache.arrow.vector.types.pojo.Schema partitionSchema)Appropriate data type to arrow type conversions will be done by fetching data types of columns.ListTablesResponselistPaginatedTables(Connection connection, ListTablesRequest listTablesRequest)This is default getAllTables without true pagination.protected List<TableName>listTables(Connection connection, String schemaName)Overridden the base class method to provide DB2-specific table listing functionality.-
Methods inherited from class com.amazonaws.athena.connectors.jdbc.manager.JdbcMetadataHandler
convertDatasourceTypeToArrow, doGetQueryPassthroughSchema, doGetTable, doListTables, escapeNamePattern, getArrayArrowTypeFromTypeName, getColumns, getCredentialProvider, getDatabaseConnectionConfig, getJdbcConnectionFactory, getSplitClauses, listDatabaseNames, setupQueryPassthroughSplit, wrapNameWithEscapedCharacter
-
Methods inherited from class com.amazonaws.athena.connector.lambda.handlers.MetadataHandler
doGetTableLayout, doHandleRequest, doPing, enhancePartitionSchema, getCachableSecretsManager, getRequestOverrideConfig, getSecret, handleRequest, makeEncryptionKey, makeSpillLocation, onPing, resolveSecrets, resolveWithDefaultCredentials
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.amazonaws.athena.connector.lambda.handlers.FederationRequestHandler
getAthenaClient, getRequestOverrideConfig, getS3Client, getSessionCredentials
-
-
-
-
Constructor Detail
-
Db2MetadataHandler
public Db2MetadataHandler(Map<String,String> configOptions)
Instantiates handler to be used by Lambda function directly.Recommend using
Db2MuxCompositeHandlerinstead.
-
Db2MetadataHandler
public Db2MetadataHandler(DatabaseConnectionConfig databaseConnectionConfig, Map<String,String> configOptions)
TO be used by Mux.- Parameters:
databaseConnectionConfig-
-
Db2MetadataHandler
public Db2MetadataHandler(DatabaseConnectionConfig databaseConnectionConfig, JdbcConnectionFactory jdbcConnectionFactory, Map<String,String> configOptions)
To be used by Mux.- Parameters:
databaseConnectionConfig-jdbcConnectionFactory-
-
Db2MetadataHandler
protected Db2MetadataHandler(DatabaseConnectionConfig databaseConnectionConfig, software.amazon.awssdk.services.secretsmanager.SecretsManagerClient secretsManager, software.amazon.awssdk.services.athena.AthenaClient athena, JdbcConnectionFactory jdbcConnectionFactory, Map<String,String> configOptions, JDBCCaseResolver caseResolver)
-
-
Method Detail
-
doListSchemaNames
public ListSchemasResponse doListSchemaNames(BlockAllocator blockAllocator, ListSchemasRequest listSchemasRequest) throws Exception
Overridden this method to fetch only user defined schema(s) in Athena Data window.- Overrides:
doListSchemaNamesin classJdbcMetadataHandler- Parameters:
blockAllocator-listSchemasRequest-- Returns:
- Throws:
Exception
-
listTables
protected List<TableName> listTables(Connection connection, String schemaName) throws SQLException
Overridden the base class method to provide DB2-specific table listing functionality.- Overrides:
listTablesin classJdbcMetadataHandler- Parameters:
connection- The JDBC connection to use for querying DB2schemaName- The name of the schema to list tables from- Returns:
- A list of
TableNameobjects representing the tables and views in the specified schema - Throws:
SQLException- if there is an error executing the query or processing the results
-
listPaginatedTables
public ListTablesResponse listPaginatedTables(Connection connection, ListTablesRequest listTablesRequest) throws SQLException
Description copied from class:JdbcMetadataHandlerThis is default getAllTables without true pagination. Paginated list of tables will be returned by retrieving all tables first, then returning subset based off request. Override this if you want to support true pagination behavior.- Overrides:
listPaginatedTablesin classJdbcMetadataHandler- Returns:
- Throws:
SQLException
-
getPaginatedTables
protected List<TableName> getPaginatedTables(Connection connection, String databaseName, int offset, int limit) throws SQLException
- Throws:
SQLException
-
getPartitionSchema
public org.apache.arrow.vector.types.pojo.Schema getPartitionSchema(String catalogName)
Creates Schema object with arrow compatible filed to frame the partition.- Specified by:
getPartitionSchemain classJdbcMetadataHandler- Parameters:
catalogName- Athena provided catalog name.- Returns:
-
getPartitions
public void getPartitions(BlockWriter blockWriter, GetTableLayoutRequest getTableLayoutRequest, QueryStatusChecker queryStatusChecker) throws Exception
A partition is represented by a partition column(s) of type varchar. In case of Db2 connector, partitions are created using below organization schemes. - Distribute by Hash - Partition by range - Organize by dimensions The partition details such as no. of partitions, column name are fetched from the Db2 metadata table(s). A custom query is then used to get the partition. Based upon the number of distinct partitions received, the splits are being created.- Specified by:
getPartitionsin classJdbcMetadataHandler- Parameters:
blockWriter-getTableLayoutRequest-queryStatusChecker-- Throws:
Exception
-
doGetSplits
public GetSplitsResponse doGetSplits(BlockAllocator blockAllocator, GetSplitsRequest getSplitsRequest)
Split(s) will be created based on table partition. We are taking ContinuationToken from GetSplitsRequest object and loop upto row count of the partitions, and inside loop we are creating Split objects. In each Split object we are adding properties to be used in partition framing.- Specified by:
doGetSplitsin classJdbcMetadataHandler- Parameters:
blockAllocator-getSplitsRequest-- Returns:
-
doGetDataSourceCapabilities
public GetDataSourceCapabilitiesResponse doGetDataSourceCapabilities(BlockAllocator allocator, GetDataSourceCapabilitiesRequest request)
Overridden this method to describe the types of capabilities supported by a data source- Overrides:
doGetDataSourceCapabilitiesin classMetadataHandler- Parameters:
allocator- Tool for creating and managing Apache Arrow Blocks.request- Provides details about the catalog being used.- Returns:
- A GetDataSourceCapabilitiesResponse object which returns a map of supported capabilities
-
getSchema
protected org.apache.arrow.vector.types.pojo.Schema getSchema(Connection jdbcConnection, TableName tableName, org.apache.arrow.vector.types.pojo.Schema partitionSchema) throws Exception
Appropriate data type to arrow type conversions will be done by fetching data types of columns. This function creates the arrow Schema pojo from jdbc database metadata of the table.- Overrides:
getSchemain classJdbcMetadataHandler- Parameters:
jdbcConnection-tableName-partitionSchema-- Returns:
- Throws:
Exception
-
-