uros-b commented on code in PR #17511: URL: https://github.com/apache/iceberg/pull/17511#discussion_r3712410742
########## api/src/main/java/org/apache/iceberg/expressions/StrictEvalVisitor.java: ########## @@ -0,0 +1,492 @@ +/* + * 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 java.util.Collection; +import java.util.Comparator; +import java.util.Set; +import java.util.stream.Collectors; +import org.apache.iceberg.types.Comparators; +import org.apache.iceberg.types.Types.StructType; +import org.apache.iceberg.util.NaNUtil; + +abstract class StrictEvalVisitor extends ExpressionVisitors.BoundExpressionVisitor<Boolean> { + protected static final boolean ROWS_MUST_MATCH = true; + protected static final boolean ROWS_MIGHT_NOT_MATCH = false; + + private final StructType struct; + + StrictEvalVisitor(StructType struct) { + this.struct = struct; + } + + /** Return true if null count is non-zero or is unknown, false if null count is 0. */ + protected abstract boolean mayContainNull(int id); + + /** Return true if null count is known and equal to value count, false otherwise. */ + protected abstract boolean containsNullsOnly(int id); + + /** + * Return true if null counts are unavailable or if the null count is non-zero, false otherwise. + * + * <p>Unlike {@link #mayContainNull(int)}, this returns false when a null count is unavailable for + * the field but is available for other fields. + */ + protected abstract boolean canContainNulls(int id); Review Comment: There might be abstract-method contract asymmetry with the inclusive twin. StrictEvalVisitor declares 8 abstract methods; whereas the merged InclusiveEvalVisitor declares only 4. The two extra semantic methods (canContainNulls(int id) and canContainNaNs(int id)) carry a subtly stricter contract than their mayContain* counterparts: canContainNulls returns false when the nullCounts map exists but has no entry for the field (where mayContainNull returns true in that case), and canContainNaNs returns false whenever a NaN count is unavailable. Can this create friction when the downstream v4 strict ContentStats evaluator is written, since its author must satisfy a materially larger contract than the corresponding inclusive visitor? Perhaps we should either add a comment to StrictEvalVisitor explaining why the strict visitor's contract diverges from InclusiveEvalVisitor's, or if the inclusive stats path will also need these finer-grained predicates then adding canContainNulls/canContainNaNs to InclusiveEvalVisitor now while both visitors are being actively designed. WDYT? @nastra -- 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]
