aokolnychyi commented on code in PR #4947:
URL: https://github.com/apache/iceberg/pull/4947#discussion_r889312374
##########
api/src/main/java/org/apache/iceberg/expressions/ExpressionUtil.java:
##########
@@ -66,6 +67,40 @@ public static String toSanitizedString(Expression expr) {
return ExpressionVisitors.visit(expr, StringSanitizer.INSTANCE);
}
+ /**
+ * Returns whether two unbound expressions will accept the same inputs.
+ * <p>
+ * If this returns true, the expressions are guaranteed to return the same
evaluation for the same input. However, if
+ * this returns false the expressions may return the same evaluation for the
same input. That is, expressions may
+ * be equivalent even if this returns false.
+ *
+ * @param left an unbound expression
+ * @param right an unbound expression
+ * @param struct a struct type for binding
+ * @return true if the expressions are equivalent
+ */
+ public static boolean equivalent(Expression left, Expression right,
Types.StructType struct) {
+ return Binder.bind(struct, Expressions.rewriteNot(left))
+ .isEquivalentTo(Binder.bind(struct, Expressions.rewriteNot(right)));
+ }
+
+ /**
+ * Returns whether an expression selects whole partitions for a partition
spec.
+ * <p>
+ * For example, ts < '2021-03-09T10:00:00.000' selects whole partitions
in an hourly spec, [hours(ts)], but does
+ * not select whole partitions in a daily spec, [days(ts)].
+ *
+ * @param expr an unbound expression
+ * @param spec a partition spec
+ * @return true if the expression will select whole partitions in the given
spec
+ */
+ public static boolean selectsPartitions(Expression expr, PartitionSpec spec)
{
Review Comment:
Am I correct this should allow us to optimize metadata-only deletes by
handling obvious cases without the need to plan files with potential matches
and invoking evaluators?
--
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]