简体   繁体   English

Amazon Athena CREATE EXTERNAL TABLE 不匹配的输入“外部”无效请求异常

[英]Amazon Athena CREATE EXTERNAL TABLE mismatched input 'external' invalidrequestexception

I am trying to create an external table in Amazon Athena.我正在尝试在 Amazon Athena 中创建一个外部表。 My query is the following:我的查询如下:

CREATE EXTERNAL TABLE priceTable (
  WeekDay STRING,
  MonthDay INT,
  price00 FLOAT,
  price01 FLOAT,
  price02 FLOAT,
  price03 FLOAT,
  price04 FLOAT,
  price05 FLOAT,
  price06 FLOAT,
  price07 FLOAT,
  price08 FLOAT,
  price09 FLOAT,
  price10 FLOAT,
  price11 FLOAT,
  price12 FLOAT,
  price13 FLOAT,
  price14 FLOAT,
  price15 FLOAT,
  price16 FLOAT,
  price17 FLOAT,
  price18 FLOAT,
  price19 FLOAT,
  price20 FLOAT,
  price21 FLOAT,
  price22 FLOAT,
  price23 FLOAT,
  )

  ROW FORMAT DELIMITED
  FIELDS TERMINATED BY ';'
  LINES TERMINATED BY '\n'
  LOCATION 's3://myquicksighttestbucket/C1_SphdemDD_CANARIAS_20190501_20190531_v2'

Where the file in S3 is just a csv deliminted by semicolons. S3 中的文件只是一个用分号分隔的 csv。 However, I get the following error:但是,我收到以下错误:

line 1:8: mismatched input 'external'. expecting: 'or', 'schema', 'table', 'view' (service: amazonathena; status code: 400; error code: invalidrequestexception; request id: e524f7e6-39ca-4af7-9e39-f86a4d0a36c8; proxy: null)

Can anybody tell what I am doing wrong?谁能告诉我我做错了什么? Any help is much appreciated.任何帮助深表感谢。

Oooh, I am sorry, the error was the comma after the last field!!哦,对不起,错误是最后一个字段后面的逗号!

And, also, instead of:而且,还有,而不是:

FIELDS TERMINATED BY ';'

I should have used the delimiter's OCT code (073) like this:我应该像这样使用分隔符的 OCT 代码(073):

FIELDS TERMINATED BY '073'

I had invalid field names which included - chars.我有无效的字段名称,其中包括-字符。 A rather easy mistake when copying names like flow-direction directly from flow logs definitions.直接从流日志定义复制flow-direction等名称时,一个相当容易的错误。

I had the same error today, and unlike others, I had a partitioned by clause where I didn't submit the type for the column:我今天遇到了同样的错误,与其他人不同,我有一个 partitioned by 子句,我没有提交列的类型:

CREATE EXTERNAL TABLE IF NOT EXISTS table_name(
  creationtime string,
  anumber bigint,
  somearray array<struct<...>>,
  somestring string)
  PARTITIONED BY (creation_date string)
                                ^^^^^^ <--- 'string' was missing
ROW FORMAT SERDE
'org.openx.data.jsonserde.JsonSerDe'
LOCATION
's3://location/';

Once I added the type, the error vanished and the query was successful.添加类型后,错误消失并且查询成功。

Make sure table name does not have "-", spaces, or any other character not allowed in table names.确保表名没有“-”、空格或任何其他不允许在表名中使用的字符。

Lots of answers here already, but I just wanted to summarize and say it seems like any syntax error in the statement can cause this error.这里已经有很多答案了,但我只是想总结一下,似乎语句中的任何语法错误都可能导致此错误。

In my case I had a trailing comma after the last item of my TBLPROPERTIES在我的情况下,我的TBLPROPERTIES的最后一项后面有一个逗号

I got same error,changing column datatype INTEGER to INT resolved this error for me.我遇到了同样的错误,将列数据类型 INTEGER 更改为 INT 为我解决了这个错误。

https://docs.aws.amazon.com/athena/latest/ug/data-types.html int and integer – Athena uses different expressions for integer depending on the type of query.https://docs.aws.amazon.com/athena/latest/ug/data-types.html int 和 integer – Athena 根据查询类型对 integer 使用不同的表达式。 int – In Data Definition Language (DDL) queries like CREATE TABLE, use the int data type. int – 在 CREATE TABLE 等数据定义语言 (DDL) 查询中,使用 int 数据类型。 integer – In DML queries like SELECT * FROM, use the integer data type. integer – 在像 SELECT * FROM 这样的 DML 查询中,使用 integer 数据类型。 integer is represented as a 32-bit signed value in two's complement format, with a minimum value of -231 and a maximum value of 231-1. integer 表示为二进制补码格式的 32 位有符号值,最小值为 -231,最大值为 231-1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Athena 创建外部表 ParseException - Athena Create External Table ParseException 输入“外部”不匹配。 期望:'OR'、'SCHEMA'、'TABLE'、'VIEW' - mismatched input 'EXTERNAL'. Expecting: 'OR', 'SCHEMA', 'TABLE', 'VIEW' Amazon Athena 外部 lambda function (udf) - 创建视图 - Amazon Athena external lambda function (udf) - create view 以下查询返回第 1:8 行:输入“EXTERNAL”不匹配。 期望:'OR'、'SCHEMA'、'TABLE'、'VIEW' - The following query returns line 1:8: mismatched input 'EXTERNAL'. Expecting: 'OR', 'SCHEMA', 'TABLE', 'VIEW' Amazon Athena - 创建 Iceberg 表时出错 - Amazon Athena - Error Create Iceberg table 即使 AWS s3 中没有文件,AWS Athena 创建外部表也会成功吗? - AWS Athena create external table succeeds even if AWS s3 doesn't have file in it? Redshift 显示外部表的 0 行,但在 Athena 中可以查看数据 - Redshift showing 0 rows for external table, though data is viewable in Athena 在 AWS Athena 中创建桶表 - create bucket table in AWS Athena 为什么我在 Athena 上的 unpivot 查询不起作用? 我只是在网上关注样本,但我总是得到“输入不匹配......” - Why is my unpivot query on Athena not working? I just followed the samples online but i always get `mismatched input ...` 无法访问 Athena 外部的 Redshift 中的某些表 - Unable to access some tables in Redshift which are external from Athena
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM