First of all, Athena cannot query directly to DynamoDB.
In order to do so, you need to make data available in another location that can be identified as a valid data source by AWS Glue;
The most common is actually S3 and Kinesis (due to performance and cost reasons), but there are other options as:
- JDBC
- Amazon RDS
- MongoDB
- Amazon DocumentDB
- Kafka
- (others options will be displayed according to the method you choose to map data)
For DynamoDb you must extract data from the desired table before it can be used. Or, as in the first example, use real-time streams.
Explaining each scenario.
First Scenario: Uses DynamoDb Streams directly connected to kinesis Firehouse which makes the data emitted by real-time DynamoDb streams available in S3. This way Athena could use S3 as a source for the data.
Second Scenario: Uses glue crawler to map data schema from DynamoDb and create a table in your Data Catalog containing the schema map of the object properties. And to extract data itself uses a glue job that points out to properties map table and extracts the data to S3, creating another table in your Data Catalog but this time pointing to S3, making it available for Athena to perform queries.
The DynamoDB data structure and storage are not optimized to perform relational queries as Athena expects, you could read more about it on DynamoDB docs.