Member since
07-30-2020
3
Posts
0
Kudos Received
0
Solutions
07-30-2020
11:51 PM
Hello @DataGeek_Anish ,
Did you find the solution of this? I also stuck into the same problem and could not able to solve it.
I have JSON array data in HIVE tables. The data type of the column is ARRAY.
Could anyone please help me to resolve this issue or let me know the other solution to flatten the JSON array data would be really appreciate.
Data:
[{"ts":1403781896,"id":14,"log":"show"},{"ts":1403781896,"id":14,"log":"start"}]
[{"ts":1403781911,"id":14,"log":"press"},{"ts":1403781911,"id":14,"log":"press"}]
Logic Used:
SELECT
get_json_object(single_json_table.single_json, '$.ts') AS ts,get_json_object(single_json_table.single_json, '$.id') AS id,get_json_object(single_json_table.single_json, '$.log') AS log
FROM(SELECT explode(json_array_col) as single_json FROM jt) single_json_table;
Error:
Error while compiling statement: FAILED: SemanticException [Error 10014]: line 2:0 Wrong arguments ''$.td'': No matching method for class org.apache.hadoop.hive.ql.udf.UDFJson with (map<string,string>, string). Possible choices: FUNC(string, string)
PS: I can unfold the array with the explode function but can't able to flatten the JSON array data into columns.
Thank You.
... View more