WweiL commented on code in PR #38503:
URL: https://github.com/apache/spark/pull/38503#discussion_r1016172080


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala:
##########
@@ -41,34 +42,58 @@ object UnsupportedOperationChecker extends Logging {
     }
   }
 
+  private def hasRangeExprAgainstEventTimeCol(e: Expression): Boolean = 
e.exists {
+    case neq @ (_: LessThanOrEqual | _: LessThan | _: GreaterThanOrEqual | _: 
GreaterThan) =>
+      hasEventTimeColNeq(neq)
+    case _ => false
+  }
+
+  private def hasEventTimeColNeq(neq: Expression): Boolean = {
+    val exp = neq.asInstanceOf[BinaryComparison]
+    hasEventTimeCol(exp.left) || hasEventTimeCol(exp.right)
+  }
+
+  private def hasEventTimeCol(exps: Expression): Boolean =
+    exps.exists {
+      case a: AttributeReference => 
a.metadata.contains(EventTimeWatermark.delayKey)
+      case _ => false
+    }
+
+  /**
+   * Check if the given logical plan is a streaming stateful operations.
+   * @param p: The logical plan to be checked.
+   */
+  def isStatefulOperation(p: LogicalPlan): Boolean = {
+    p match {
+      case s: Aggregate if s.isStreaming => true
+      // Since the Distinct node will be replaced to Aggregate in the 
optimizer rule
+      // [[ReplaceDistinctWithAggregate]], here we also need to check all 
Distinct node by
+      // assuming it as Aggregate.
+      case d @ Distinct(_: LogicalPlan) if d.isStreaming => true

Review Comment:
   This is borrowed from line 136 of `collectStreamingAggregates`. Note that in 
the original `isStatefulOperation`(was a function inside 
`checkStreamingQueryGlobalWatermarkLimit`) we do not check this. lmk if this is 
needed.



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