【发布时间】:2018-11-30 16:33:04
【问题描述】:
这不起作用:
ALTER TABLE 'table' SET SERDEPROPERTIES( "ignore.malformed.json" = "true");
【问题讨论】:
标签: json hive amazon-athena
这不起作用:
ALTER TABLE 'table' SET SERDEPROPERTIES( "ignore.malformed.json" = "true");
【问题讨论】:
标签: json hive amazon-athena
您遇到的问题是 Athena uses the presto language 不是 DDL 的配置单元语言。将 Athen(Presto) 视为subset of the Hive language,同时仍然是一门功能齐全的 ansi-SQL 语言。遗憾的是,您尝试使用的命令是 not a supported DDL statement。
您必须重新创建表格添加属性:
CREATE EXTERNAL TABLE impressions (
id string,
awesomeness struct<
modellookup:string,
requesttime:string>
) PARTITIONED BY (dt string)
ROW FORMAT serde 'org.openx.data.jsonserde.JsonSerDe'
with serdeproperties ( 'ignore.malformed.json'='true' )
LOCATION 's3://myregion.awesome/awesome';
不是这个(ignore.malformed.json 不可用)
CREATE EXTERNAL TABLE impressions (
id string,
awesomeness struct<
modellookup:string,
requesttime:string>
) PARTITIONED BY (dt string)
ROW FORMAT serde 'org.apache.hive.hcatalog.data.JsonSerDe'
with serdeproperties ( 'paths'='id' )
LOCATION 's3://myregion.awesome/awesome';
为了完整起见,我将添加latest SerDe documentation
Hive JSON SerDe
Hive JSON SerDe 用于处理 JSON 数据,大多数 常见的事件。这些事件表示为块 JSON 编码的文本,以换行符分隔。
您还可以使用 Hive JSON SerDe 来解析更复杂的 具有嵌套结构的 JSON 编码数据。然而,这需要 具有表示复杂数据类型的匹配 DDL。
OpenX JSON SerDe
此 SerDe 有一个有用的属性,您可以在何时指定 在 Athena 中创建表,以帮助处理 数据:
- 'ignore.malformed.json' 如果设置为 TRUE,则允许您跳过格式错误的 JSON 语法。
【讨论】: