A query that runs by itself in Amazon Athena fails to run when I add CREATE TABLE temp_table_name AS on top of it due to a GENERIC_INTERNAL_ERROR

huangapple go评论69阅读模式
英文:

A query that runs by itself in Amazon Athena fails to run when I add CREATE TABLE temp_table_name AS on top of it due to a GENERIC_INTERNAL_ERROR

问题

When I run the query below in Amazon Athena, it runs without any problems or error messages:

SELECT
   "loc id", "runway id", "icao id", "length", "width", "surface type condition", "edge light intensity"
FROM
  "runway_db_athena"."runway"
WHERE
  "loc id" IN ('09J','14A','18A','1V6','22S','2I0','2R4');

However, when I try to create a temporary session table with the same query, I encounter this error message:

GENERIC_INTERNAL_ERROR: field ended by ';': expected ';' but got 'id' at line 1: optional binary loc id. You may need to manually clean the data at location 's3://realagnifuegos3bucket/Athena-output/create%20dash_runs_table/2023/04/16/tables/230fe35a-e3fc-4b4c-aa46-b6c88efbd8f3' before retrying. Athena will not delete data in your account.

Subsequently, I attempted to add a semicolon after "loc id," which resulted in this error:

Only one sql statement is allowed. Got: CREATE TABLE dash_runs_table AS SELECT "loc id"; "runway id", "icao id",...

I expected to receive this error, but it confuses me because it asks for a semicolon and then complains when I provide one.

英文:

When I run the query (I have reduced the column names and airport codes in the query to reduce your scrolling time) below in Amazon Athena it runs and I get no problems or error messages:

SELECT
 "loc id", "runway id", "icao id", "length", "width", "surface type condition", "edge light intensity"
FROM
  "runway_db_athena"."runway"
WHERE
  "loc id" IN ('09J','14A','18A','1V6','22S','2I0','2R4');

However, whenever I then try to store this result as a temporary session table so I can perform joins on it with other queries and only have to download the results of those joins using this:

CREATE TABLE dash_runs_table AS
SELECT
     "loc id", "runway id", "icao id", "length", "width", "surface type condition", "edge light intensity"
    FROM
      "runway_db_athena"."runway"
    WHERE
      "loc id" IN ('09J','14A','18A','1V6','22S','2I0','2R4');

I end up with this:

GENERIC_INTERNAL_ERROR: field ended by ';': expected ';' but got 'id' at line 1: optional binary loc id. You may need to manually clean the data at location 's3://realagnifuegos3bucket/Athena-output/create%20dash_runs_table/2023/04/16/tables/230fe35a-e3fc-4b4c-aa46-b6c88efbd8f3' before retrying. Athena will not delete data in your account.
This query ran against the "runway_db_athena" database, unless qualified by the query. Please post the error message on our forum  or contact customer support  with Query Id: 230fe35a-e3fc-4b4c-aa46-b6c88efbd8f3

I have absolutely no idea what's going on there^^, I am still quite new to AWS. So, I went back and changed that first , after "loc id" to a ; just to see what would happen and this is the Error Message I got back this:

Only one sql statement is allowed. Got: CREATE TABLE dash_runs_table AS SELECT "loc id"; "runway id", "icao id",...

That^ is exactly what I was expecting to get, but not what I was hoping to get because that means I REALLY don't understand the error message! How is it expecting a semicolon, but then it complains when I give it one?

答案1

得分: 1

Amazon Athena似乎在“loc id”中的空格后面感到困惑。

由于它在使用“SELECT”时正常工作,但在使用“CREATE TABLE AS”时存在问题,因此它可能不喜欢创建具有名称中包含空格的表列的请求。

尝试使用别名重命名列:

CREATE TABLE dash_runs_table AS
SELECT
     "loc id" as loc_id,
     "runway id" as runway_id,
     "icao id" as icao_id,
     "length",
     "width", 
     "surface type condition" as surface_type_condition,
     "edge light intensity" as edge_light_intensity
    FROM
      "runway_db_athena"."runway"
    WHERE
      "loc id" IN ('09J','14A','18A','1V6','22S','2I0','2R4');
英文:

It would appear that Amazon Athena is being confused by the space after loc in "loc id".

Since it works fine with the SELECT, but has problems with CREATE TABLE AS, it is likely unhappy with the request to create a table column that has a space in its name.

Try renaming the columns by using an alias:

CREATE TABLE dash_runs_table AS
SELECT
     "loc id" as loc_id,
     "runway id" as runway_id,
     "icao id" as icao_id,
     "length",
     "width", 
     "surface type condition" as surface_type_condition,
     "edge light intensity" as edge_light_intensity
    FROM
      "runway_db_athena"."runway"
    WHERE
      "loc id" IN ('09J','14A','18A','1V6','22S','2I0','2R4');

huangapple
  • 本文由 发表于 2023年4月17日 10:28:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76031350.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定