Class ExampleRecordHandler

  • All Implemented Interfaces:
    com.amazonaws.services.lambda.runtime.RequestStreamHandler

    public class ExampleRecordHandler
    extends RecordHandler
    All items in the "com.amazonaws.athena.connector.lambda.examples" that this class belongs to are part of an 'Example' connector. We do not recommend using any of the classes in this package directly. Instead you can/should copy and modify as needed.

    More specifically, this class is responsible for providing Athena with actual rows level data from our simulated source. Athena will call readWithConstraint(...) on this class for each 'Split' we generated in ExampleMetadataHandler.

    See Also:
    RecordHandler
    • Constructor Detail

      • ExampleRecordHandler

        public ExampleRecordHandler​(Map<String,​String> configOptions)
        Default constructor used by Lambda.
      • ExampleRecordHandler

        protected ExampleRecordHandler​(com.amazonaws.services.s3.AmazonS3 amazonS3,
                                       com.amazonaws.services.secretsmanager.AWSSecretsManager secretsManager,
                                       com.amazonaws.services.athena.AmazonAthena athena,
                                       Map<String,​String> configOptions)
        Full DI constructor used mostly for testing
        Parameters:
        amazonS3 - The AmazonS3 client to use for spills.
        secretsManager - The AWSSecretsManager client that can be used when attempting to resolve secrets.
        athena - The Athena client that can be used to fetch query termination status to fast-fail this handler.
    • Method Detail

      • setNumRows

        protected void setNumRows​(int numRows)
        Used to set the number of rows per split. This method is mostly used for testing where setting the environment variable to override the default is not practical.
        Parameters:
        numRows - The number of rows to generate per split.
      • onPing

        protected void onPing​(PingRequest request)
        We use the ping signal to simply log the fact that a ping request came in.
        Overrides:
        onPing in class RecordHandler
        Parameters:
        request - The PingRequest.
      • readWithConstraint

        protected void readWithConstraint​(BlockSpiller spiller,
                                          ReadRecordsRequest request,
                                          QueryStatusChecker queryStatusChecker)
        Here we generate our simulated row data. A real connector would instead connect to the actual source and read the data corresponding to the requested split.
        Specified by:
        readWithConstraint in class RecordHandler
        Parameters:
        spiller - A BlockSpiller that should be used to write the row data associated with this Split. The BlockSpiller automatically handles applying constraints, chunking the response, encrypting, and spilling to S3.
        request - The ReadRecordsRequest containing the split and other details about what to read.
        queryStatusChecker - A QueryStatusChecker that you can use to stop doing work for a query that has already terminated