Package io.trino.hive.formats.line.json
Class JsonDeserializer
java.lang.Object
io.trino.hive.formats.line.json.JsonDeserializer
- All Implemented Interfaces:
LineDeserializer
Deserializer that is bug for bug compatible with Hive JsonSerDe where possible. Known exceptions are:
- When a scalar value is actually a json object, Hive will process the open curly bracket for BOOLEAN, DECIMAL, CHAR, VARCHAR, and VARBINARY. Then it continues processing field inside of the json object as if they are part of the outer json object. When the closing curly bracket is encountered it pops a level, which can end parsing early. This is clearly a bug resulting in corrupted data, and instead we throw an exception.
- Duplicate json object fields are supported, and like Hive. Hive parses each of these duplicate values, but this code only process the last value. This means if one of the duplicates is invalid, Hive will fail, and this code will not.
-
Field Summary
Fields inherited from interface io.trino.hive.formats.line.LineDeserializer
EMPTY_LINE_DESERIALIZER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeserialize(LineBuffer lineBuffer, PageBuilder builder) Deserialize the line into the page builder.getTypes()Required types for the deserialize page builder.
-
Constructor Details
-
JsonDeserializer
-
-
Method Details
-
getTypes
Description copied from interface:LineDeserializerRequired types for the deserialize page builder.- Specified by:
getTypesin interfaceLineDeserializer
-
deserialize
Description copied from interface:LineDeserializerDeserialize the line into the page builder. The implementation will declare the added positions in the page builder. The implementation is allowed to add zero or more positions to the builder.- Specified by:
deserializein interfaceLineDeserializer- Parameters:
lineBuffer- the line which may be emptybuilder- page builder for the declared types- Throws:
IOException- if line can not be decoded and processing should stop
-