简体   繁体   中英

Hive issue's with querying potentially malformed JSON files even whileusing JSON serde

I have json files stored on Hadoop and as part of an etl process, I put a basic structure table on them using the json serde

json-serde-1.3-jar-with-dependencies_ss.jar

while using the following code to ignore malformed json files:

ALTER TABLE localytics_staging.sportsbook SET SERDEPROPERTIES( "ignore.malformed.json" = "true");

This puts the files into a staging table and from there I try doing a insert into another create table that is the final destination for the data, while correctly formatting the data from the staging table in the process

This results in a error:

Your query has the following error(s):

Error while processing statement: FAILED: Execution Error, return code 2 
from org.apache.hadoop.hive.ql.exec.tez.TezTask

Here's an extract from the logs:

INFO  : Session is already open
INFO  : Tez session was closed. Reopening...
INFO  : Session re-established.
INFO  : 

INFO  : Status: Running (Executing on YARN cluster with App id     application_1428668005272_1845)

INFO  : Map 1: -/-  
INFO  : Map 1: 0/15 
INFO  : Map 1: 0(+3)/15 
INFO  : Map 1: 0(+4)/15 
INFO  : Map 1: 0(+8)/15 
INFO  : Map 1: 0(+12)/15    
INFO  : Map 1: 0(+14)/15    
INFO  : Map 1: 0(+15)/15    
INFO  : Map 1: 0(+15)/15    
INFO  : Map 1: 0(+15)/15    
INFO  : Map 1: 0(+15,-1)/15 
INFO  : Map 1: 0(+15,-1)/15 
INFO  : Map 1: 1(+14,-1)/15 
INFO  : Map 1: 2(+13,-1)/15 
INFO  : Map 1: 3(+12,-1)/15 
INFO  : Map 1: 3(+12,-1)/15 
INFO  : Map 1: 3(+12,-2)/15 
INFO  : Map 1: 3(+12,-2)/15 
INFO  : Map 1: 5(+10,-3)/15 
INFO  : Map 1: 6(+9,-3)/15  
INFO  : Map 1: 6(+9,-3)/15  
INFO  : Map 1: 7(+8,-3)/15  
ERROR : Status: Failed
ERROR : Vertex failed, vertexName=Map 1,     vertexId=vertex_1428668005272_1845_1_00, diagnostics=[Task failed,     taskId=task_1428668005272_1845_1_00_000008, diagnostics=[TaskAttempt 0 failed, info=[Error: Failure while running task:java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: java.io.IOException: java.io.EOFException: Unexpected end of input stream
at org.apache.hadoop.hive.ql.exec.tez.TezProcessor.initializeAndRunProcessor(TezProcessor.java:186)
at org.apache.hadoop.hive.ql.exec.tez.TezProcessor.run(TezProcessor.java:138)
at org.apache.tez.runtime.LogicalIOProcessorRuntimeTask.run(LogicalIOProcessorRuntimeTask.java:324)
at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable$1.run(TezTaskRunner.java:176)
at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable$1.run(TezTaskRunner.java:168)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628)
at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable.call(TezTaskRunner.java:168)
at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable.call(TezTaskRunner.java:163)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

I believe this is still an issue with the json files but I thought I had catered for this with the ignore.malformed.json line.

I guess the JAR you are using does not support properly the 'malformed' option. By changing it, you can make your table ALTER working on malformed JSONs:

ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
WITH SERDEPROPERTIES ("ignore.malformed.json" = "true")
LOCATION ...

Include the JAR using the 'hive.aux.jars.path' property in 'hive-site.xml' or the 'ADD JAR' Hive instruction. You can find the JAR here , or compile it from this source . Note also that the source code is very recent (updated one month ago at the time of this post).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM