Amazon Athena failed query editor

0

Hi Aws team, Getting error after running query and selecting default table also. Any solution.

Enter image description here

profile picture
Fahad
asked a month ago447 views
2 Answers
0

Hi Fahad,

It seems like you're encountering a syntax error in your Athena SQL query. The error message is indicating that it's not expecting the keyword 'EXTERNAL' at the point where it's used. Without seeing the exact query, it's a bit difficult to provide a precise solution, but here are a few general tips:

  1. Ensure that you're using the correct syntax for the CREATE EXTERNAL TABLE statement according to the Athena documentation.
  2. Verify that you don't have any typos or misplaced keywords in your query.
  3. Check that you have the necessary permissions to create external tables in the designated S3 location linked to Athena.

If you've checked these points and the error persists, try running a simpler CREATE EXTERNAL TABLE statement to see if the problem is with the query complexity.

If you continue to have issues, providing the full query might be the best next step.

Hope this helps!

profile picture
answered a month ago
profile picture
EXPERT
reviewed a month ago
  • CREATE EXTERNAL TABLE covid( patient number bigint, state patient number string, date announced string, estimated onset date string, age bracket string, Gender string, detected city string, detected district string, detected state string, state code string, current status string, notes string, contracted from which patient (suspected) string, nationality string, type of transmission string, support@k21academy.com 19 status change date string, source_1 string, source_2 string, source_3 string, backup notes string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS INPUTFORMAT 'org.apache.hadoop.mapred.TextInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' LOCATION 's3://Yoursourcebucketname/covid/' Note: replace the source bucket Name

    Hi Vitor, I'm copying and pasting the above Data Definition language with out any spaces and running the query which is giving the error

  • See if you can paste in Athena and run the query. If error is showing up any other DDL New table?

    1. Make sure all strings, such as Gender, string, and suspected, are enclosed in single quotes (') if they are meant to be string literals.
    2. Check that the data types for each field match the data in your S3 files. For instance, bigint should only be used for numerical values without quotes.
    3. The presence of support@k21academy.com 19 within the DDL looks out of place. If this is not a part of a field definition or a comment, it should be removed.
    4. Athena is sensitive to the format of your data. The DDL states FIELDS TERMINATED BY ',', so ensure your data in S3 is CSV format and uses commas to separate fields.
    5. Athena requires column names not to have spaces. Ensure all column names, such as patient number, state patient number, date announced, etc., are either concatenated (e.g., patient_number) or use underscores.
    6. Confirm that Athena has the necessary permissions to access the S3 bucket.
    7. The Athena parser is strict with syntax. The error from the parser suggests there could be a syntactical issue. Make sure every line ends with a comma except the last line before the ROW FORMAT definition, and there are no trailing commas or other syntax errors.
  • Try something like this checking all items above.

    CREATE EXTERNAL TABLE covid( patient_number bigint, state_patient_number string, date_announced string, estimated_onset_date string, age_bracket string, gender string, detected_city string, detected_district string, detected_state string, state_code string, current_status string, notes string, contracted_from_which_patient_suspected string, nationality string, type_of_transmission string, status_change_date string, source_1 string, source_2 string, source_3 string, backup_notes string ) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS INPUTFORMAT 'org.apache.hadoop.mapred.TextInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' LOCATION 's3://bucket-name/covid/';

0

Assuming you are not using iceberg, you are correct as you should use external.

https://docs.aws.amazon.com/athena/latest/ug/creating-tables.html

I would check into some typo, comma or similar, as the error message could be misleading and just indicate a different reason.

profile picture
EXPERT
answered a month ago
  • Hi Antio You can check the above message regarding the error which is posted.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions