AWS Athena Error: INTERNAL_ERROR_QUERY_ENGINE on CREATE TABLE

Viewed 1488

I'm trying to execute the following query on AWS Athena:

CREATE TABLE IF NOT EXISTS salesforce_processed."case"
WITH (
    format = 'JSON',
    external_location = 's3://path/to/my/bucket/',
    partitioned_by = ARRAY['dt_obs']
)
AS
SELECT
    nullif(trim("case".id), '') AS "id" , 
    try(cast(date_parse("case".dt_obs, '%Y-%m-%d') as date)) as "dt_obs"
FROM salesforce_raw."case" as "case"

But it returns this error message: [ErrorCode: INTERNAL_ERROR_QUERY_ENGINE] Amazon Athena experienced an internal error while executing this query. Please contact AWS support for further assistance. You will not be charged for this query. We apologize for the inconvenience.

There's no other error info, and if I execute the select statement alone, it runs with success.

1 Answers

I just ran into this problem on Athena engine version 2. The try() function was the culprit in my query. My query previously ran on the v1 engine, so I suspect the upgrade to v2 is to blame.

The only solution I found was to rewrite the query to avoid try().

Related