Skip to content
This repository was archived by the owner on May 3, 2019. It is now read-only.

Commit 335fc36

Browse files
committed
Add errors.ignore serde property
1 parent 38d63d3 commit 335fc36

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/main/java/com/proofpoint/hive/serde/JsonSerde.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class JsonSerde
5454
private ObjectInspector rowObjectInspector;
5555
protected StructTypeInfo rootTypeInfo;
5656
protected ColumnNameMap columnNameMap;
57+
private boolean ignoreErrors;
5758

5859
@Override
5960
public void initialize(Configuration configuration, Properties table)
@@ -78,6 +79,8 @@ public void initialize(Configuration configuration, Properties table)
7879
rowObjectInspector = getStandardJavaObjectInspectorFromTypeInfo(rootTypeInfo);
7980

8081
columnNameMap = new ColumnNameMap(rootTypeInfo);
82+
83+
ignoreErrors = Boolean.parseBoolean(table.getProperty("errors.ignore"));
8184
}
8285

8386
@Override
@@ -100,8 +103,21 @@ public Object deserialize(Writable writable)
100103
if (!(writable instanceof BinaryComparable)) {
101104
throw new SerDeException("expected BinaryComparable: " + writable.getClass().getName());
102105
}
103-
BinaryComparable binary = (BinaryComparable) writable;
104106

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+
{
105121
try {
106122
JsonParser jsonParser = jsonFactory.createJsonParser(binary.getBytes(), 0, binary.getLength());
107123
return buildStruct(jsonParser.readValueAsTree());

0 commit comments

Comments
 (0)