This may be the issue with the input data file, have you created this file manually , you need to insert the delimited characters inside the file correctly , i would suggest you can download the sample text file from the book website (i assume you are referring programming hive book) and then give a try . the input file is available there and i am able to load that so...
How to load a complex datastructure like struct ,map in HIVE table
Question
I am trying insert below data in to an hive table:
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
This is the query I am using:
CREATE TABLE employees (
name STRING,
salary FLOAT,
subordinates ARRAY,
deductions MAP,
address STRUCT ) ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\001'
COLLECTION ITEMS TERMINATED BY '\002'
MAP KEYS TERMINATED BY '\003'
LINES TERMINATED BY '\n'
STORED AS TEXTFILE
LOAD LOCAL INPATH '/home/cloudera/a.txt';
BUT the all the detail stored in one column.Can anybody please explain the reason.
John Doe^A100000.0^AMary Smith^BTodd Jones^AFederal Taxes^C.2^BState NULL null null null Taxes^C.05^BInsurance^C.1^A1 Michigan Ave.^BChicago^BIL^B60600 NULL null null null Mary Smith^A80000.0^ABill King^AFederal Taxes^C.2^BState Taxes^C. NULL null null null 05^BInsurance^C.1^A100 Ontario St.^BChicago^BIL^B60601 NULL null null null Todd Jones^A70000.0^AFederal Taxes^C.15^BState Taxes^C.03^BInsurance^C. NULL null null null 1^A200 Chicago Ave.^BOak Park^BIL^B60700 NULL null null null Bill King^A60000.0^AFederal Taxes^C.15^BState Taxes^C.03^BInsurance^C. NULL null null null 1^A300 Obscure Dr.^BObscuria^BIL^B60100 NULL null null null
Solution
OTHER TIPS
meet the same problem.
solved by when create your table, change default ROW FORMAT DELIMITED, '\001' -> ',' '\002' -> ';' '\003' -> ':'
then you can prepare your text file using the above chars to split.