如何用{"root":[json array]}
之类的名称来封装json数组
我受命在MongoDB的JSON数据之上创建一个外部蜂巢表,该表看起来像[array of objects]
,因此如果没有该数组的名称(例如{ {1}}每次出现上述情况时,我都不允许更改JSON数据
已经引用了a similar situation,但我不想将JSON文件加载为{"root:"[array of objects]}
并在其上使用String
。
配置单元表结构
regexp_replace
因此,有什么方法可以在使用 CREATE EXTERNAL TABLE IF NOT EXISTS sify_cvs_output.json(
data:Array <
candidatedob bigint,
candidateemail string,
candidateid string,
candidatename string,
candidatephone string,
candidatephoto string,
createdby string,
createdtime bigint,
deleted boolean,
eventref string,
examdate bigint,
fingerprintdata struct<fingerprints:array<struct<enrolledTime:bigint, fingerid:bigint, isotemplate:string, sessionkey:string>>, userid:string>,
id string,
labname string,
locationname string,
locationref string,
registeredby string,
registereddate bigint,
seatno string,
updatedby string,
updatedtime bigint,
walkincandidate boolean)
PARTITIONED BY (event String,dt String,centercode String)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
WITH SERDEPROPERTIES ( "ignore.malformed.json" = "true","input.regex" ="*.json")
LOCATION 'hdfs://172.16.2.191:8020/tmp/candidatelist/';
或以其他方式将数据加载到表以及添加时在前缀后缀{"root":
和在后缀}
后面添加内容新的分区。
谢谢