- Newest
- Most votes
- Most comments
Tried the suggested approach and here is the updated query I tried. But again got the same error. Query ID: b2a1a5ba-f43b-4fee-854f-0ffbbd9c2a23
Error:
GENERIC_USER_ERROR: Encountered an exception[java.lang.RuntimeException] from your LambdaFunction[arn:aws:lambda:us-west-2:063173320901:function:eventbus-rds-athena-connector] executed in context[S3SpillLocation{bucket='eventbus-athena-spill-bucket', key='athena-spill/b2a1a5ba-f43b-4fee-854f-0ffbbd9c2a23/33635a51-634f-43f2-8743-4872777ed77c', directory=true}] with message[org.postgresql.util.PSQLException: ERROR: operator does not exist: uuid >= character varying Hint: No operator matches the given name and argument types. You might need to add explicit type casts. Position: 117]
Query:
SELECT
das.dev_manager_name AS manager_Name,
das.dev_manager_email AS dev_manager_email,
SUM(CASE WHEN kcv.verified THEN 1 ELSE 0 END) AS verifiedClientCount,
SUM(CASE WHEN NOT kcv.verified THEN 1 ELSE 0 END) AS unverifiedClientCount,
SUM(CASE WHEN kcv.client_migration_status = 'COMPLETED' THEN 1 ELSE 0 END) AS migratedClientCount,
SUM(CASE WHEN kcv.client_migration_status <> 'COMPLETED' THEN 1 ELSE 0 END) AS nonMigratedClientCount
FROM
"eventbus".kafka_client_view kcv
JOIN
"eventbus".aws_resource_source ars
ON CAST(kcv.aws_resource_source_id AS VARCHAR) = CAST(ars.aws_resource_source_id AS VARCHAR)
JOIN
"eventbus".devportal_asset_source das
ON CAST(ars.devportal_asset AS VARCHAR) = CAST(das.devportal_asset_id AS VARCHAR)
GROUP BY
das.dev_manager_name, das.dev_manager_email
ORDER BY
das.dev_manager_name;
answered 2 years ago
The error you're encountering suggests that there's a type mismatch in your query when it's being executed in AWS Athena. Specifically, the error indicates that Athena is trying to compare a UUID type with a character varying (string) type, which is not a valid operation.
This issue is likely occurring because Athena and PostgreSQL handle data types differently, particularly when it comes to UUIDs. While PostgreSQL might be able to implicitly cast between UUID and string types, Athena is more strict and requires explicit type casting.
To resolve this, you should try to explicitly cast the UUID to a string (VARCHAR) in your query. Look for any joins or comparisons involving UUID fields and add an explicit cast. For example, if 'aws_resource_source_id' is a UUID field, you might modify the join condition like this:
JOIN "eventbus".aws_resource_source ars ON CAST(kcv.aws_resource_source_id AS VARCHAR) = CAST(ars.aws_resource_source_id AS VARCHAR)
Similarly, if 'devportal_asset' or 'devportal_asset_id' is a UUID, you may need to cast it as well:
JOIN "eventbus".devportal_asset_source das ON CAST(ars.devportal_asset AS VARCHAR) = CAST(das.devportal_asset_id AS VARCHAR)
If you're unsure which field is causing the issue, you may need to review the schema of your tables in Athena and identify any UUID fields that are being compared or joined with other fields.
Remember that while this solution should resolve the immediate error, it may impact query performance. If possible, it's generally better to ensure that joined fields have matching data types in your table definitions to avoid the need for casting during queries.
Sources
Athena Query Error using Python | AWS re:Post
Athena engine version 3 - Amazon Athena
answered 2 years ago
Relevant content
- AWS OFFICIALUpdated a year ago
