- Newest
- Most votes
- Most comments
When working with decimal values in AWS Athena, there are specific considerations for how to properly use them in WHERE clauses.
For your case with a decimal column of type decimal(6,0), the issue might be related to how you're specifying the decimal values in your WHERE clause. In Athena, you should explicitly specify the DECIMAL type when using decimal literals in queries.
Instead of writing:
WHERE decimal_column = 123
Try using the DECIMAL keyword with the value in single quotes:
WHERE decimal_column = DECIMAL '123'
This explicit typing helps Athena properly compare the values. If you're using Athena engine version 3, it has stricter type validation compared to version 2, which might explain why your query works in the source database but not in Athena.
Additionally, ensure that your IAM role has the necessary permissions to access both the Athena service and the AWS Glue Data Catalog (specifically the glue:Get permission), as missing permissions can sometimes cause unexpected query behavior.
Sources
How to Display Decimal Values with 3 Decimal Places in Athena Table from Integer JSON Data Stored in S3? | AWS re:Post
Athena Query Error using Python | AWS re:Post
Considerations for data types - Amazon Athena
Relevant content
- AWS OFFICIALUpdated 8 months ago
