数据如下:



我正在运行的查询是:

add jar /home/student/hive-0.11.0-bin/lib/json-serde-1.3.7-jar-with-dependencies.jar;

CREATE EXTERNAL TABLE movie_json
( custId INT, movieId INT, genreId INT,
time STRING, recommended STRING, activity INT, rating INT, price FLOAT )
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
LOCATION '/user/oracle/movie/';

遇到的错误是:



我使用了各种JsonSerder jar ,但是得到了相同的错误。请帮我。

最佳答案

不确定您使用的JsonSerDe。您可以在此处使用此JsonSerDe

Hive-JSON-Serde

hive> add jar /User/User1/json-serde-1.3.8-SNAPSHOT-jar-with-dependencies.jar;
Added [/User/User1/json-serde-1.3.8-SNAPSHOT-jar-with-dependencies.jar] to class path
Added resources: [/User/User1/json-serde-1.3.8-SNAPSHOT-jar-with-dependencies.jar]
hive>CREATE EXTERNAL TABLE movie_json ( custId INT, movieId INT, genreId INT, time STRING, recommended STRING, activity INT, rating INT, price FLOAT ) ROW FORMAT SERDE'org.openx.data.jsonserde.JsonSerDe'
LOCATION'/user/oracle/movie/';
OK
Time taken: 0.097 seconds

你可以通过使用来构建Jar
C:\Users\User1\Downloads\Hive-JSON-Serde-develop\Hive-JSON-Serde-develop>mvn -Phdp23 clean package.
-Phdp23 is hdp2.3 it should be replaced with your hadoop version.

您还可以使用内置的jsonserde get_json_object json_tuple如果您正在寻找例如如何使用内置的jsonserde的示例,请查看此示例
Example

我建议您验证Json Validate JSON

08-28 04:39