如何解决 Athena 中的错误“FAILED: ParseException line 1:X missing EOF at '-' near 'keyword'”?

1 分钟阅读
0

在 Amazon Athena 中运行 MSCK REPAIR TABLE 或 SHOW CREATE TABLE 语句时,收到了与以下类似的错误:“FAILED: ParseException line 1:X missing EOF at '-' near 'keyword'”。

解决方法

当 DDL 语句中指定的数据库名称包含连字符("-")时,会发生这种错误。AWS Glue 允许使用包含连字符的数据库名称。但是,下划线 (_) 是 Athena 在数据库、表、视图和列名称中支持的唯一特殊字符。

在下面的示例中,数据库名称为 alb-database1。当您运行 MSCK REPAIR TABLESHOW CREATE TABLE 时,Athena 会返回 ParseException 错误:

Your query has the following error(s):
FAILED: ParseException line 1:7 missing EOF at '-' near 'alb'
This query ran against the "alb-database1" database, unless qualified by the query. Please post the error message on our forum or contact customer support with Query Id: cc5c1234-4c12-4dcb-a123-bff954b305eb.

要解决此问题,请使用不包含除下划线(_)外的特殊字符的名称重新创建数据库。


相关信息

表、数据库和列的名称

相关视频

AWS 官方
AWS 官方已更新 2 年前