我有一个HIVE表,用于存储以下示例定义的json对象:
{bpy:[{bpyNr:string,anr:string}]
我加载了3个文件,如下所示:
文件1
{"bpy":[
{"bpyNr":"","anr":"BESHPR","al1Te":"123 BELWAFFLE","al2Te":"ADDR LINE2","al3Te":"ADDR LINE3","ctcNa":"FROMBE LAGO","cnyCd":"ES","cnySdvCd":"","divNa":"BRUSSELS","emlTe":"","faxNr":"","munNa":"","na":"BELGUIM SHIPPER","phnNr":"18889991234","pslCd":"1000","bpyRlCd":"01"}]}
文件2:
{"bpy": [
{"bpyNr":"","anr":"00005483WW","al1Te":"14 RICH WAY","al2Te":"REC ADDR2","al3Te":"REC ADDR3","ctcNa":"IAMRECEIVER","cnyCd":"ES","cnySdvCd":"","divNa":"PORT ELIZABETH","emlTe":"CONS-EMAIL@YAHOO.NET","faxNr":"7747747774","munNa":"","na":"AFRICAN SHIPPERS","phnNr":"2018289999","pslCd":"6001","bpyRlCd":"02"}, {"bpyNr":"","anr":"UPS11111","al1Te":"","al2Te":"","al3Te":"3","ctcNa":"","cnyCd":"US","cnySdvCd":"","divNa":"","emlTe":"","faxNr":"","munNa":"","na":"THIRD PARTY SHIPPXX","phnNr":"2018289999","pslCd":"","bpyRlCd":"05"}
]}
他们被加载到一个hive外部表businessparty_tbl 当我查询表时,我得到了这个结果
hive> select bpy.anr from businessparty_tbl;
OK
NULL
NULL
NULL
NULL
["BESHPR"]
["00005483WW","UPS11111"]
有没有办法让我得到这样的结果:
[NULL, NULL, NULL, NULL, "BESHPR", "00005483WW","UPS11111"]
更新:添加了businessparty_tbl定义
ADD JAR /opt/cloudera/parcels/CDH/jars/hive-hcatalog-core-1.1.0-cdh5.4.7.jar;
DROP TABLE IF EXISTS brokerage.businessparty_tbl;
CREATE EXTERNAL TABLE IF NOT EXISTS brokerage.businessparty_tbl (
bpy array<struct<bpyNr :STRING COMMENT "businessPartyNumber",
anr :STRING COMMENT "accountNumber",
al1Te :STRING COMMENT "addressLine1Text",
al2Te :STRING COMMENT "addressLine2Text",
al3Te :STRING COMMENT "addressLine3Text",
crrCd :STRING COMMENT "carrierCode",
ctcEmlAdTe :STRING COMMENT "contactEmailAddressText",
ctcFaxLinNr :STRING COMMENT "contactFaxLineNumber",
ctcNa :STRING COMMENT "contactName",
ctcPhnNr :STRING COMMENT "contactPhoneNumber",
ctcDepNa :STRING COMMENT "contactDepartmentName",
ctcDivNa :STRING COMMENT "contactDivisionName",
cnyCd :STRING COMMENT "countryCode",
cnySdvCd :STRING COMMENT "countrySubdivisionCode",
dunsNr :STRING COMMENT "dunsNumber",
depNa :STRING COMMENT "departmentName",
divNa :STRING COMMENT "divisionName",
emlTe :STRING COMMENT "emailText",
faxNr :STRING COMMENT "faxNumber",
munNa :STRING COMMENT "municipalityName",
na :STRING COMMENT "name",
phnNr :STRING COMMENT "telephoneNumber",
pslCd :STRING COMMENT "postalCode",
sutTe :STRING COMMENT "suiteText",
crrNa :STRING COMMENT "carrierName",
shrCrCrdNr :STRING COMMENT "shipperCreditCardNumber",
shrCrCrdExpDt :STRING COMMENT "shipperCreditCardExpirationDate"
>>
)
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe';
load data local inpath '/data/5/sys1deh/brokerage/testdata/BAS/SHIPMENTS/' OVERWRITE into table brokerage.businessparty_tbl;