MCPcopy Index your code
hub / github.com/awslabs/aws-athena-query-federation

github.com/awslabs/aws-athena-query-federation @v2026.24.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2026.24.1 ↗ · + Follow
9,805 symbols 58,478 edges 1,203 files 1,936 documented · 20%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Amazon Athena Query Federation

Build Status codecov

The Amazon Athena Query Federation SDK allows you to customize Amazon Athena with your own code. This enables you to integrate with new data sources, proprietary data formats, or build in new user defined functions. Initially these customizations will be limited to the parts of a query that occur during a TableScan operation but will eventually be expanded to include other parts of the query lifecycle using the same easy to understand interface.

**Athena Federated Queries are available where Athena is supported. **

tldr; Get Started: 1. Ensure you have the proper permissions/policies to deploy/use Athena Federated Queries 1. Navigate to Serverless Application Repository and search for "athena-federation". Be sure to check the box to show entries that require custom IAM roles. 1. Look for entries published by the "Amazon Athena Federation" author. 1. Deploy the application 1. Run a query "show databases in `lambda:`" where is the name of the Lambda function you deployed in the previous steps.

For more information please consult:

  1. Intro Video
  2. SDK ReadMe
  3. Quick Start Guide
  4. Available Connectors
  5. Federation Features
  6. How To Build A Connector or UDF
  7. Gathering diagnostic info for support
  8. Frequently Asked Questions
  9. Common Problems
  10. Installation Pre-requisites
  11. Known Limitations & Open Issues
  12. Predicate Pushdown How-To
  13. Our Github Wiki.
  14. Java Doc

Architecture Image

We've written integrations with more than 20 databases, storage formats, and live APIs in order to refine this interface and balance flexibility with ease of use. We hope that making this SDK and initial set of connectors Open Source will allow us to continue to improve the experience and performance of Athena Query Federation.

Serverless Big Data Using AWS Lambda

Architecture Image

Queries That Span Data Stores

Imagine a hypothetical e-commerce company who's architecture uses:

  1. Payment processing in a secure VPC with transaction records stored in HBase on EMR
  2. Redis is used to store active orders so that the processing engine can get fast access to them.
  3. DocumentDB (e.g. a mongodb compatible store) for Customer account data like email address, shipping addresses, etc..
  4. Their e-commerce site using auto-scaling on Fargate with their product catalog in Amazon Aurora.
  5. Cloudwatch Logs to house the Order Processor's log events.
  6. A write-once-read-many datawarehouse on Redshift.
  7. Shipment tracking data in DynamoDB.
  8. A fleet of Drivers performing last-mile delivery while utilizing IoT enabled tablets.
  9. Advertising conversion data from a 3rd party source.

Architecture Image

Customer service agents begin receiving calls about orders 'stuck' in a weird state. Some show as pending even though they have delivered, others show as delivered but haven't actually shipped. It would be great if we could quickly run a query across this diverse architecture to understand which orders might be affected and what they have in common.

Using Amazon Athena Query Federation and many of the connectors found in this repository, our hypothetical e-commerce company would be able to run a query that:

  1. Grabs all active orders from Redis. (see athena-redis)
  2. Joins against any orders with 'WARN' or 'ERROR' events in Cloudwatch logs by using regex matching and extraction. (see athena-cloudwatch)
  3. Joins against our EC2 inventory to get the hostname(s) and status of the Order Processor(s) that logged the 'WARN' or 'ERROR'. (see athena-cmdb)
  4. Joins against DocumentDB to obtain customer contact details for the affected orders. (see athena-docdb)
  5. Joins against DynamoDB to get shipping status and tracking details. (see athena-dynamodb)
  6. Joins against HBase to get payment status for the affected orders. (see athena-hbase)
WITH logs 
     AS (SELECT log_stream, 
                message                                          AS 
                order_processor_log, 
                Regexp_extract(message, '.*orderId=(\d+) .*', 1) AS orderId, 
                Regexp_extract(message, '(.*):.*', 1)            AS log_level 
         FROM 
     "lambda:cloudwatch"."/var/ecommerce-engine/order-processor".all_log_streams 
         WHERE  Regexp_extract(message, '(.*):.*', 1) != 'WARN'), 
     active_orders 
     AS (SELECT * 
         FROM   redis.redis_db.redis_customer_orders), 
     order_processors 
     AS (SELECT instanceid, 
                publicipaddress, 
                state.NAME 
         FROM   awscmdb.ec2.ec2_instances), 
     customer 
     AS (SELECT id, 
                email 
         FROM   docdb.customers.customer_info), 
     addresses 
     AS (SELECT id, 
                is_residential, 
                address.street AS street 
         FROM   docdb.customers.customer_addresses),
     shipments 
     AS ( SELECT order_id, 
                 shipment_id, 
                 from_unixtime(cast(shipped_date as double)) as shipment_time,
                 carrier
        FROM lambda_ddb.default.order_shipments),
     payments
     AS ( SELECT "summary:order_id", 
                 "summary:status", 
                 "summary:cc_id", 
                 "details:network" 
        FROM "hbase".hbase_payments.transactions)

SELECT _key_            AS redis_order_id, 
       customer_id, 
       customer.email   AS cust_email, 
       "summary:cc_id"  AS credit_card,
       "details:network" AS CC_type,
       "summary:status" AS payment_status,
       status           AS redis_status, 
       addresses.street AS street_address, 
       shipments.shipment_time as shipment_time,
       shipments.carrier as shipment_carrier,
       publicipaddress  AS ec2_order_processor, 
       NAME             AS ec2_state, 
       log_level, 
       order_processor_log 
FROM   active_orders 
       LEFT JOIN logs 
              ON logs.orderid = active_orders._key_ 
       LEFT JOIN order_processors 
              ON logs.log_stream = order_processors.instanceid 
       LEFT JOIN customer 
              ON customer.id = customer_id 
       LEFT JOIN addresses 
              ON addresses.id = address_id 
       LEFT JOIN shipments
              ON shipments.order_id = active_orders._key_
       LEFT JOIN payments
              ON payments."summary:order_id" = active_orders._key_

License

This project is licensed under the Apache-2.0 License.

Extension points exported contracts — how you extend this code

Credentials (Interface)
Represents a set of credentials required to authenticate and connect to a database. Implementations may provide credenti [9 …
athena-federation-sdk/src/main/java/com/amazonaws/athena/connector/credentials/Credentials.java
TableProvider (Interface)
Defines the functionality required to supply the metadata and data required for the Athena AWS CMDB connector to to allo [11 …
athena-aws-cmdb/src/main/java/com/amazonaws/athena/connectors/aws/cmdb/tables/TableProvider.java
JdbcConnectionFactory (Interface)
Factory abstracts creation of JDBC connection to database. [5 implementers]
athena-jdbc/src/main/java/com/amazonaws/athena/connectors/jdbc/connection/JdbcConnectionFactory.java
CellWriter (Interface)
(no doc) [13 implementers]
athena-tpcds/src/main/java/com/amazonaws/athena/connectors/tpcds/TPCDSRecordHandler.java
MskRecordProcessor (Interface)
(no doc) [4 implementers]
athena-msk/src/main/java/com/amazonaws/athena/connectors/msk/consumer/MskRecordProcessor.java
ResultProcessor (Interface)
Used to define a class which is capable of processing entries returned from an HBase scan operation. @param The typ [1 …
athena-hbase/src/main/java/com/amazonaws/athena/connectors/hbase/connection/ResultProcessor.java
RdsGenericStackProps (Interface)
(no doc)
validation_testing/cdk_federation_infra_provisioning/app/lib/stacks/rds-generic-stack.ts
EncryptionKeyFactory (Interface)
Defines a factory that can be used to create AES-GCM compatible encryption keys. [13 implementers]
athena-federation-sdk/src/main/java/com/amazonaws/athena/connector/lambda/security/EncryptionKeyFactory.java

Core symbols most depended-on inside this repo

Shape

Method 8,216
Class 1,379
Function 109
Interface 68
Enum 33

Languages

Java96%
Python3%
TypeScript1%

Modules by API surface

athena-federation-sdk/src/main/java/com/amazonaws/athena/connector/lambda/serde/v2/ArrowTypeSerDe.java125 symbols
athena-jdbc/src/test/java/com/amazonaws/athena/connectors/jdbc/manager/JdbcSplitQueryBuilderTest.java63 symbols
athena-neptune/src/test/java/com/amazonaws/athena/connectors/neptune/propertygraph/rowwriters/CustomSchemaRowWriterTest.java58 symbols
athena-dynamodb/src/test/java/com/amazonaws/athena/connectors/dynamodb/DDBTypeUtilsTest.java52 symbols
athena-federation-integ-test/src/main/java/com/amazonaws/athena/connector/integ/IntegrationTestBase.java49 symbols
athena_federation_testing/infra/federated_source.py44 symbols
athena-redis/src/test/java/com/amazonaws/athena/connectors/redis/integ/RedisIntegTest.java44 symbols
athena-jdbc/src/test/java/com/amazonaws/athena/connectors/jdbc/manager/JdbcFederationExpressionParserTest.java44 symbols
athena-federation-sdk/src/test/java/com/amazonaws/athena/connector/lambda/handlers/UserDefinedFunctionHandlerTest.java44 symbols
athena-federation-sdk/src/test/java/com/amazonaws/athena/connector/lambda/handlers/FederationRequestHandlerTest.java43 symbols
athena_federation_testing/testing/federated_testing.py41 symbols
athena-kafka/src/test/java/com/amazonaws/athena/connectors/kafka/KafkaRecordHandlerTest.java40 symbols

Datastores touched

(mongodb)Database · 1 repos
(mysql)Database · 1 repos
postgresDatabase · 1 repos
defaultDatabase · 1 repos
mysqlDatabase · 1 repos
devDatabase · 1 repos
test_dbDatabase · 1 repos
testdbDatabase · 1 repos

For agents

$ claude mcp add aws-athena-query-federation \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page