singhpk234 opened a new pull request, #17343:
URL: https://github.com/apache/iceberg/pull/17343

   PR Description
   
   ## Summary
   
   Updates the Java `ExpressionParser` to serialize predicates in the new
   form defined in 
[`format/expressions-spec.md`](https://github.com/apache/iceberg/blob/main/format/expressions-spec.md#appendix-b-json-serialization),
   while continuing to accept the deprecated term-based form for backward
   compatibility.
   
   This is the Java-side counterpart to #17138, which updates the REST
   OpenAPI spec to the new `Predicate` / `ValueExpression` model.
   
   ## Changes
   
   ### New model classes (`api` module)
   - `FunctionReference` — value class for function references, supporting
     the four spec forms: bare name, name array, `{identifier}`, and
     `{catalog, identifier}`.
   - `UnboundApply<T>` — implements `UnboundTerm<T>` to represent general
     function applications. `bind()` delegates to `UnboundTransform` for
     known Iceberg transforms (identity, year, month, day, hour, bucket,
     truncate, void); other functions currently throw at bind time.
   
   ### Parser changes (`core` module)
   - **Writer** now emits the new form only:
     - Predicates use `child` / `left` / `right` instead of `term` / `value`
     - References serialize as `{"type": "reference", "name": ...}` for
       unbound and `{"type": "reference", "id": N}` for bound
     - Transforms serialize as `apply` with the
       arguments (e.g. `bucket[100](id)` → `{"type": "apply",
       "function": "bucket", "arguments": [100, {"type": "reference",
       "name": "id"}]}`)
   - **Reader** detects the format from the payload and accepts both:
     - If a predicate has a `term` field, the deprecated path parses it
       (existing behavior)
     - Otherwise the new path parses `child` / `left` / `right`,
       references (`name` or deprecated `term`), and `apply` expressions
     - Known Iceberg transforms parsed from `apply` are converted back to
       `UnboundTransform` so downstream binding paths are unchanged
   
   ### Tests
   - Updated existing round-trip and expected-JSON assertions in
     `TestExpressionParser`, `TestPlanTableScanRequestParser`,
     `TestFileScanTaskParser`, `TestPlanTableScanResponseParser`,
     `TestFetchPlanningResultResponseParser`,
     `TestFetchScanTasksResponseParser`,
     `TestAllManifestsTableTaskParser`, and `TestFilesTableTaskParser` to
     the new writer output.
   - Added backward-compatibility reader tests for each deprecated
     predicate form (`testReadDeprecatedUnaryPredicate`,
     `testReadDeprecatedComparisonPredicate`,
     `testReadDeprecatedSetPredicate`,
     `testReadDeprecatedTransformPredicate`,
     `testReadDeprecatedObjectReference`).
   - Added new-format tests: `testNewFormatRoundTrip`,
     `testApplySimpleFunctionName`, `testApplyWithCatalogFunction`,
     `testNewFormatNamedReference`, `testNewFormatTypedLiteral`.
   
   ## Test plan
   
   - [x] `./gradlew :iceberg-api:test`
   - [x] `./gradlew :iceberg-core:test --tests 
"org.apache.iceberg.expressions.*"`
   - [x] `./gradlew :iceberg-core:test --tests "org.apache.iceberg.rest.*"`
   - [x] `./gradlew :iceberg-core:test --tests "org.apache.iceberg.metrics.*"`
   - [x] `./gradlew :iceberg-core:test --tests 
"org.apache.iceberg.TestFileScanTaskParser"`
   - [x] `./gradlew spotlessApply`
   


-- 
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]

Reply via email to