Revanth14 commented on code in PR #1213: URL: https://github.com/apache/iceberg-go/pull/1213#discussion_r3449119299
########## expression_json.go: ########## @@ -0,0 +1,48 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// This file is a PROPOSED public API surface for REST scan-planning +// expression JSON (apache/iceberg-go#1178). The bodies are intentionally +// unimplemented; the file exists so the API shape can be reviewed. +// +// The codec lives in the root iceberg package because expression internals +// are defined here and are not exported. Compatibility with Java's +// ExpressionParser is correctness-critical and every encoding must be +// confirmed against checked-in Java golden fixtures. +// +// Design decision: MarshalExpressionJSON emits Java ExpressionParser wire +// format, including bare JSON booleans for AlwaysTrue/AlwaysFalse (`true` and +// `false`). That intentionally differs from the REST OpenAPI Expression schema, +// where true/false are represented as objects (`{"type":"true"}` and +// `{"type":"false"}`). UnmarshalExpressionJSON must accept both forms so +// clients can read Java-compatible responses and strictly spec-shaped payloads. + +package iceberg + +// MarshalExpressionJSON serializes a boolean expression to the JSON format +// produced by Java's ExpressionParser, for use as a REST scan-planning filter. +func MarshalExpressionJSON(expr BooleanExpression) ([]byte, error) { Review Comment: Good question. I checked the Java reference and it points the other way. The REST server parses the request filter through `ExpressionParser.fromJson` (`PlanTableScanRequestParser` -> `ExpressionParser.fromJson`), so this is the same codec path as metadata expressions, not a separate REST-only parser. `ExpressionParser.toJson` emits bare booleans for always-true / always-false, and `ExpressionParser.fromJson` accepts bare `true` / `false`. I don’t see handling for the OpenAPI object form (`{"type":"true"}` / `{"type":"false"}`) in that parser, so emitting the object form would risk breaking against the Java reference / `iceberg-rest-fixture`. Given that, I’ll keep `MarshalExpressionJSON` Java/reference-compatible and emit bare booleans, keep `UnmarshalExpressionJSON` permissive, and pin the golden fixtures to the bare form. Refs: `ExpressionParser.java`, `PlanTableScanRequestParser.java`. -- 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]
