Error importing dataset in Hive

2019-08-20 22:44发布

I have a dataset as follows,

John  Doe^A100000.0^AMary  Smith^BTodd  Jones^AFederal Taxes^C.2^BState Taxes^C.05^BInsurance^C.1^A1 Michigan Ave.^BChicago^BIL^B60600
Mary  Smith^A80000.0^ABill  King^AFederal  Taxes^C.2^BState Taxes^C.05^BInsurance^C.1^A100 Ontario St.^BChicago^BIL^B60601 Todd Jones^A70000.0^AFederal Taxes^C.15^BState Taxes^C.03^BInsurance^C.1^A200 Chicago Ave.^BOak Park^BIL^B60700
Bill  King^A60000.0^AFederal  Taxes^C.15^BState  Taxes^C.03^BInsurance^C.1^A300 Obscure Dr.^BObscuria^BIL^B60100

I have read in Hive documentation on "Text Encoding of Data values" on how hive decodes dataset having different "delimiters". For the above dataset, I have created a table with following schema,

CREATE TABLE employees
(
name STRING,
salary FLOAT,
subordinates ARRAY<STRING>,
deductions MAP<STRING, FLOAT>,
address STRUCT<street:STRING, city:STRING, state:STRING, zip:INT>
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\001'
COLLECTION ITEMS TERMINATED BY '\002'
MAP KEYS TERMINATED BY '\003'
LINES TERMINATED BY '\n'
STORED AS TEXTFILE;

But the dataset is not being imported properly into the table.

|employees.name|employees.salary|employees.subordinates|employees.deductions|employees.address|
|--------------|----------------|----------------------|--------------------|-----------------|
|John  Doe|NULL|["AMary  Smith"]|{"BTodd  Jones":null}|("street":"AFederal Taxes","city":null,"state":null,"zip":null}|
|Mary  Smith|NULL|["ABill  King"]|{"AFederal  Taxes":null}|{"street":"C.2","city":null,"state":null,"zip":null}|
|Bill  King|NULL|["AFederal  Taxes"]|{"C.15":null}|{"street":"BState  Taxes","city":null,"state":null,"zip":null} |

Can anyone please explain me why this is getting wrong though I am following as per documentation example in Page 45? Thanks in advance.

0条回答
登录 后发表回答