beliefer commented on code in PR #37040:
URL: https://github.com/apache/spark/pull/37040#discussion_r917211765


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala:
##########
@@ -470,6 +470,52 @@ object BooleanSimplification extends Rule[LogicalPlan] 
with PredicateHelper {
   }
 }
 
+/**
+ * Optimize Rand expressions in binary comparison:
+ * 1. Converts the binary comparison to true when the comparison value must be 
true.
+ * 2. Converts the binary comparison to false when the comparison value must 
be false.
+ */
+object OptimizeRand extends Rule[LogicalPlan] with PredicateHelper {
+  val oneLiteral = Literal(1d)
+
+  def apply(plan: LogicalPlan): LogicalPlan = plan.transformWithPruning(
+    _.containsPattern(EXPRESSION_WITH_RANDOM_SEED), ruleId) {
+    case q: LogicalPlan => q.transformExpressionsUpWithPruning(
+      _.containsAnyPattern(EXPRESSION_WITH_RANDOM_SEED), ruleId) {
+      case GreaterThan(left, Rand(_, _))

Review Comment:
   Thank you for the reminder.



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