This repository was archived by the owner on May 3, 2019. It is now read-only.
File tree 1 file changed +17
-1
lines changed
src/main/java/com/proofpoint/hive/serde
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ public class JsonSerde
54
54
private ObjectInspector rowObjectInspector ;
55
55
protected StructTypeInfo rootTypeInfo ;
56
56
protected ColumnNameMap columnNameMap ;
57
+ private boolean ignoreErrors ;
57
58
58
59
@ Override
59
60
public void initialize (Configuration configuration , Properties table )
@@ -78,6 +79,8 @@ public void initialize(Configuration configuration, Properties table)
78
79
rowObjectInspector = getStandardJavaObjectInspectorFromTypeInfo (rootTypeInfo );
79
80
80
81
columnNameMap = new ColumnNameMap (rootTypeInfo );
82
+
83
+ ignoreErrors = Boolean .parseBoolean (table .getProperty ("errors.ignore" ));
81
84
}
82
85
83
86
@ Override
@@ -100,8 +103,21 @@ public Object deserialize(Writable writable)
100
103
if (!(writable instanceof BinaryComparable )) {
101
104
throw new SerDeException ("expected BinaryComparable: " + writable .getClass ().getName ());
102
105
}
103
- BinaryComparable binary = (BinaryComparable ) writable ;
104
106
107
+ try {
108
+ return doDeserialize ((BinaryComparable ) writable );
109
+ }
110
+ catch (SerDeException e ) {
111
+ if (ignoreErrors ) {
112
+ return null ;
113
+ }
114
+ throw e ;
115
+ }
116
+ }
117
+
118
+ private Object doDeserialize (BinaryComparable binary )
119
+ throws SerDeException
120
+ {
105
121
try {
106
122
JsonParser jsonParser = jsonFactory .createJsonParser (binary .getBytes (), 0 , binary .getLength ());
107
123
return buildStruct (jsonParser .readValueAsTree ());
You can’t perform that action at this time.
0 commit comments