rdblue commented on code in PR #4947:
URL: https://github.com/apache/iceberg/pull/4947#discussion_r889346113


##########
api/src/main/java/org/apache/iceberg/expressions/ExpressionUtil.java:
##########
@@ -66,6 +67,41 @@ 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
+   * @param caseSensitive whether to bind expressions using case-sensitive 
matching
+   * @return true if the expressions are equivalent
+   */
+  public static boolean equivalent(Expression left, Expression right, 
Types.StructType struct, boolean caseSensitive) {
+    return Binder.bind(struct, Expressions.rewriteNot(left), caseSensitive)
+        .isEquivalentTo(Binder.bind(struct, Expressions.rewriteNot(right), 
caseSensitive));
+  }
+
+  /**
+   * Returns whether an expression selects whole partitions for a partition 
spec.
+   * <p>
+   * For example, ts &lt; '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, 
boolean caseSensitive) {
+    return equivalent(
+        Projections.inclusive(spec).project(expr),

Review Comment:
   Fixed.



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