huaxingao commented on code in PR #18629:
URL: https://github.com/apache/iceberg/pull/18629#discussion_r4449894644


##########
api/src/main/java/org/apache/iceberg/expressions/FunctionReference.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package org.apache.iceberg.expressions;
+
+import org.apache.iceberg.catalog.CatalogObjectIdentifier;
+
+public class FunctionReference {

Review Comment:
   `Expression` is `Serializable`, but `FunctionReference`, 
`BoundFunctionReference`, and `CatalogObjectIdentifier` are not. Should these 
classes implement `Serializable`? Spark and Flink serialize filters, so a 
predicate with a function would fail with `NotSerializableException`.



##########
api/src/main/java/org/apache/iceberg/expressions/UnboundPredicate.java:
##########
@@ -123,6 +206,51 @@ public Expression bind(StructType struct, boolean 
caseSensitive) {
     return bindLiteralOperation(bound);
   }
 
+  /**
+   * Bind this UnboundPredicate, using a function binder to resolve function 
applications.
+   *
+   * @param struct The {@link StructType struct type} to resolve references by 
name.
+   * @param caseSensitive A boolean flag to control whether the bind should 
enforce case
+   *     sensitivity.
+   * @param functionBinder a {@link FunctionBinder} used to resolve functions
+   * @return an {@link Expression}
+   * @throws ValidationException if literals do not match bound references, or 
if comparison on
+   *     expression is invalid
+   */
+  public Expression bind(StructType struct, boolean caseSensitive, 
FunctionBinder functionBinder) {
+    Preconditions.checkNotNull(functionBinder, "Function binder cannot be 
null");
+    if (term() != null) {
+      return bind(struct, caseSensitive);
+    }
+
+    BoundExpression<T> boundLeft = bindOperand(left, struct, caseSensitive, 
functionBinder);

Review Comment:
   Should the new bind also check and convert types, like the old bind does?
   
   For example, if `x` is a long:
   - `x < 5` binds to a `LongLiteral`.
   - `f(x) < 5`, where `f` returns long: the `5` stays an int 
(`IntegerLiteral`). It is not converted to long.
   
   Also, `upper(name) == 5` binds without error, but the old form `name == 5` 
gives a `ValidationException`.
   



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