Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.38.0
-
None
Description
The JSON serialization of a RelDatatypeField of type STRUCT contains redundant fields and nullable entries along with unnecessary nesting.
Consider for example, a field "address" of type STRUCT composed from the following fields.
RelDataType type = typeFactory.builder() .add("street", SqlTypeName.VARCHAR, 50) .add("number", SqlTypeName.INTEGER) .add("building", SqlTypeName.VARCHAR, 20).nullable(true) .build(); RelDataTypeField address = new RelDataTypeFieldImpl("address", 0, type);
At the moment, the JSON serialization for the field "address" is shown below.
{ "fields": { "fields": [ { "type": "VARCHAR", "nullable": false, "precision": 50, "name": "street" }, { "type": "INTEGER", "nullable": false, "name": "number" }, { "type": "VARCHAR", "nullable": true, "precision": 20, "name": "building" } ], "nullable": false }, "nullable": false, "name": "address" }
Note that the "fields" key appears twice and there is an unnecessary wrapping of a JSON array (inner "fields") inside a JSON object (outer "fields"). The outer "fields" object cannot have more entries so it doesn't offer anything.
Moreover, observe that there are two "nullable":false entries and both reflect the nullability of the "address" field.
The redundancy leads to wasted space and more convoluted representation that is hard to follow especially when there are nested STRUCTS.
The same information could be represented using the following JSON serialization:
{ "fields": [ { "type": "VARCHAR", "nullable": false, "precision": 50, "name": "street" }, { "type": "INTEGER", "nullable": false, "name": "number" }, { "type": "VARCHAR", "nullable": true, "precision": 20, "name": "building" } ], "nullable": false, "name": "address" }
Attachments
Issue Links
- is related to
-
HIVE-28936 Redundant fields/nullable attributes in CBOPlan returned by EXPLAIN FORMATTED
-
- Resolved
-
- links to