Revanth14 opened a new pull request, #2191:
URL: https://github.com/apache/iceberg-go/pull/2191
## Problem
The expression JSON grammar (`format/expressions-spec.md`, Appendix B) lets
a literal be written bare or wrapped:
LITERAL: VALUE
| { "type": "literal", "value": VALUE }
| { "type": "literal", "value": VALUE, "data-type": DATA_TYPE }
Java's `ExpressionParser.literal()` accepts the wrapped form for a
predicate's `value` and for each item in `values`. `iceberg.ParseExpr` rejects
it with `cannot parse literal value`. The top-level
`{"type":"literal","value":<bool>}` form already parses; only the predicate
value position was missing.
## Fix
`decodeValue` unwraps a `{"type":"literal","value":...}` object, then
decodes the inner value exactly as a bare one, so it still takes the bound
field's type. As in Java, `data-type` is ignored and the field type decides. An
object whose type isn't `literal`, a missing or null `value`, and a wrapper
nested inside another wrapper are all rejected with `ErrInvalidArgument`.
## Testing
- `TestUnmarshalExpressionLiteralWrapper`: each wrapped form parses equal to
its bare form. Covers a date with a schema, `data-type` disagreeing with the
field, `values` mixing wrapped and bare items, and a value parsed without a
schema. All four subtests fail with the unwrap removed.
- `TestUnmarshalExpressionLiteralWrapperErrors`: the rejection cases above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]