Class JdbcRecordHandler
- java.lang.Object
-
- com.amazonaws.athena.connector.lambda.handlers.RecordHandler
-
- com.amazonaws.athena.connectors.jdbc.manager.JdbcRecordHandler
-
- All Implemented Interfaces:
FederationRequestHandler,com.amazonaws.services.lambda.runtime.RequestStreamHandler
- Direct Known Subclasses:
ClickHouseRecordHandler,DataLakeGen2RecordHandler,Db2As400RecordHandler,Db2RecordHandler,HiveRecordHandler,HiveRecordHandler,ImpalaRecordHandler,MultiplexingJdbcRecordHandler,MySqlRecordHandler,OracleRecordHandler,PostGreSqlRecordHandler,SaphanaRecordHandler,SnowflakeRecordHandler,SqlServerRecordHandler,SynapseRecordHandler,TeradataRecordHandler
public abstract class JdbcRecordHandler extends RecordHandler
Abstracts JDBC record handler and provides common reusable split records handling.
-
-
Field Summary
Fields Modifier and Type Field Description protected JdbcQueryPassthroughqueryPassthrough-
Fields inherited from class com.amazonaws.athena.connector.lambda.handlers.RecordHandler
configOptions
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedJdbcRecordHandler(String sourceType, Map<String,String> configOptions)Used only by Multiplexing handler.protectedJdbcRecordHandler(software.amazon.awssdk.services.s3.S3Client amazonS3, software.amazon.awssdk.services.secretsmanager.SecretsManagerClient secretsManager, software.amazon.awssdk.services.athena.AthenaClient athena, DatabaseConnectionConfig databaseConnectionConfig, JdbcConnectionFactory jdbcConnectionFactory, Map<String,String> configOptions)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description PreparedStatementbuildQueryPassthroughSql(Connection jdbcConnection, Constraints constraints)abstract PreparedStatementbuildSplitSql(Connection jdbcConnection, String catalogName, TableName tableName, org.apache.arrow.vector.types.pojo.Schema schema, Constraints constraints, Split split)Builds split SQL string and returns prepared statement.protected booleandisableCaseSensitivelyLookUpSession(Connection connection)protected booleanenableCaseSensitivelyLookUpSession(Connection connection)protected CredentialsProvidergetCredentialProvider()protected DatabaseConnectionConfiggetDatabaseConnectionConfig()protected JdbcConnectionFactorygetJdbcConnectionFactory()protected ExtractormakeExtractor(org.apache.arrow.vector.types.pojo.Field field, ResultSet resultSet, Map<String,String> partitionValues)Creates an Extractor for the given field.protected FieldWriterFactorymakeFactory(org.apache.arrow.vector.types.pojo.Field field)Create a field extractor for complex List type.voidreadWithConstraint(BlockSpiller blockSpiller, ReadRecordsRequest readRecordsRequest, QueryStatusChecker queryStatusChecker)A more stream lined option for reading the row data associated with the provided Split.-
Methods inherited from class com.amazonaws.athena.connector.lambda.handlers.RecordHandler
doHandleRequest, doReadRecords, getCachableSecretsManager, getRequestOverrideConfig, getSecret, getSpillConfig, handleRequest, 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
-
-
-
-
Field Detail
-
queryPassthrough
protected final JdbcQueryPassthrough queryPassthrough
-
-
Constructor Detail
-
JdbcRecordHandler
protected JdbcRecordHandler(String sourceType, Map<String,String> configOptions)
Used only by Multiplexing handler. All invocations will be delegated to respective database handler.
-
JdbcRecordHandler
protected JdbcRecordHandler(software.amazon.awssdk.services.s3.S3Client amazonS3, software.amazon.awssdk.services.secretsmanager.SecretsManagerClient secretsManager, software.amazon.awssdk.services.athena.AthenaClient athena, DatabaseConnectionConfig databaseConnectionConfig, JdbcConnectionFactory jdbcConnectionFactory, Map<String,String> configOptions)
-
-
Method Detail
-
getJdbcConnectionFactory
protected JdbcConnectionFactory getJdbcConnectionFactory()
-
getDatabaseConnectionConfig
protected DatabaseConnectionConfig getDatabaseConnectionConfig()
-
getCredentialProvider
protected CredentialsProvider getCredentialProvider()
-
readWithConstraint
public void readWithConstraint(BlockSpiller blockSpiller, ReadRecordsRequest readRecordsRequest, QueryStatusChecker queryStatusChecker) throws Exception
Description copied from class:RecordHandlerA more stream lined option for reading the row data associated with the provided Split. This method differs from doReadRecords(...) in that the SDK handles more of the request lifecycle, leaving you to focus more closely on the task of actually reading from your source.- Specified by:
readWithConstraintin classRecordHandler- Parameters:
blockSpiller- A BlockSpiller that should be used to write the row data associated with this Split. The BlockSpiller automatically handles chunking the response, encrypting, and spilling to S3.readRecordsRequest- Details of the read request, including: 1. The Split 2. The Catalog, Database, and Table the read request is for. 3. The filtering predicate (if any) 4. The columns required for projection.queryStatusChecker- A QueryStatusChecker that you can use to stop doing work for a query that has already terminated- Throws:
Exception
-
makeFactory
protected FieldWriterFactory makeFactory(org.apache.arrow.vector.types.pojo.Field field)
Create a field extractor for complex List type.- Parameters:
field- Field's metadata information.- Returns:
- Extractor for the List type.
-
enableCaseSensitivelyLookUpSession
protected boolean enableCaseSensitivelyLookUpSession(Connection connection)
-
disableCaseSensitivelyLookUpSession
protected boolean disableCaseSensitivelyLookUpSession(Connection connection)
-
makeExtractor
protected Extractor makeExtractor(org.apache.arrow.vector.types.pojo.Field field, ResultSet resultSet, Map<String,String> partitionValues)
Creates an Extractor for the given field. In this example the extractor just creates some random data.
-
buildSplitSql
public abstract PreparedStatement buildSplitSql(Connection jdbcConnection, String catalogName, TableName tableName, org.apache.arrow.vector.types.pojo.Schema schema, Constraints constraints, Split split) throws SQLException
Builds split SQL string and returns prepared statement.- Parameters:
jdbcConnection- jdbc connection. SeeConnectioncatalogName- Athena provided catalog name.tableName- database table name.schema- table schema.constraints- constraints to push down to the database.split- table split.- Returns:
- prepared statement with sql. See
PreparedStatement - Throws:
SQLException- JDBC database exception.
-
buildQueryPassthroughSql
public PreparedStatement buildQueryPassthroughSql(Connection jdbcConnection, Constraints constraints) throws SQLException
- Throws:
SQLException
-
-