0

数据如下:

{"custId":1185972,"movieId":null,"genreId":null,"time":"2012-07-01:00:00:07","re​​commended":null,"activity":8}

我正在运行的查询是:

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/';

遇到的错误是:

java.lang.NoSuchFieldError: org.openx.data.jsonserde.objectinspector.primitive.JavaStringJsonObjectInspector.(JavaStringJsonObjectInspector.java:14) 处 org.openx.data.jsonserde.objectinspector.primitive.TypeEntryShim.(TypeEntryShim.java:27) 处的 byteTypeInfo )在 org.openx.data.jsonserde.objectinspector.JsonObjectInspectorFactory.(JsonObjectInspectorFactory.java:196) 在 org.openx.data.jsonserde.JsonSerDe.initialize(JsonSerDe.java:125) 在 org.apache.hadoop.hive.metastore .MetaStoreUtils.getDeserializer(MetaStoreUtils.java:215) 在 org.apache.hadoop.hive.ql.metadata.Table.getDeserializerFromMetaStore(Table.java:268) 在 org.apache.hadoop.hive.ql.metadata.Table.getDeserializer (Table.java:261) 在 org.apache.hadoop.hive.ql.metadata.Hive 的 org.apache.hadoop.hive.ql.metadata.Table.getCols(Table.java:587)。在 org.apache.hadoop.hive.ql.exec.DDLTask.execute(DDLTask. java:256) 在 org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:144) 在 org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:57)在 org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1355) 在 org.apache.hadoop.hive.ql.Driver.execute(Driver.java:1139) 在 org.apache.hadoop.hive .ql.Driver.run(Driver.java:945) 在 org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:259) 在 org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver .java:216) 在 org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:413) 在 org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:756) 在 org.阿帕奇。hadoop.hive.cli.CliDriver.main(CliDriver.java:614) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在 sun.reflect.DelegatingMethodAccessorImpl。在 org.apache.hadoop.util.RunJar.main(RunJar.java:156) 的 java.lang.reflect.Method.invoke(Method.java:597) 处调用(DelegatingMethodAccessorImpl.java:25) 失败:执行错误,返回来自 org.apache.hadoop.hive.ql.exec.DDLTask 的代码 -101597)在 org.apache.hadoop.util.RunJar.main(RunJar.java:156)失败:执行错误,从 org.apache.hadoop.hive.ql.exec.DDLTask 返回代码 -101597)在 org.apache.hadoop.util.RunJar.main(RunJar.java:156)失败:执行错误,从 org.apache.hadoop.hive.ql.exec.DDLTask 返回代码 -101

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

4

1 回答 1

0

不确定JsonSerDe您使用的是 . Bu在这里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

于 2017-01-18T06:43:58.013 回答