1

我有 JSON 文件要加载到 hive 表,但它包含重复键,使所有数据为空或无法在 Hive 上选择查询。

那些 JSON 文件有这样的东西:

{"timeSeries":"17051233123","id":"123","timeseries":"17051233123","name":"sample"}

我尝试创建配置单元表

CREATE EXTERNAL TABLE table_hive (`id` 
STRING, `name` STRING, `timeseries` STRING,`timeseries2` STRING)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
WITH SERDEPROPERTIES ( "mapping.timeseries2" = "timeSeries") 
LOCATION 'app/jsonfile.json';

如何使其成为可查询的配置单元表?

4

1 回答 1

0

与 Hive 发行版附带的 JSON SerDe 一起工作正常

create external table table_hive 
(
    id          string
   ,name        string   
   ,timeseries  string
)
row format serde 'org.apache.hive.hcatalog.data.JsonSerDe'
stored as textfile
;

select * from table_hive
;

+-----+--------+-------------+
| id  |  name  | timeseries  |
+-----+--------+-------------+
| 123 | sample | 17051233123 |
+-----+--------+-------------+
于 2017-05-26T10:56:36.983 回答