srowen commented on a change in pull request #24890: [SPARK-28074][SS] Log warn 
message on possible correctness issue for multiple stateful operations in 
single query
URL: https://github.com/apache/spark/pull/24890#discussion_r329153642
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala
 ##########
 @@ -41,8 +42,57 @@ object UnsupportedOperationChecker {
     }
   }
 
-  def checkForStreaming(plan: LogicalPlan, outputMode: OutputMode): Unit = {
+  def checkStreamingQueryGlobalWatermarkLimit(
+      plan: LogicalPlan,
+      outputMode: OutputMode,
+      failWhenDetected: Boolean): Unit = {
+    def isStatefulOperationPossiblyEmitLateRows(p: LogicalPlan): Boolean = p 
match {
+      case s: Aggregate
+        if s.isStreaming && outputMode == InternalOutputModes.Append => true
+      case Join(left, right, joinType, _, _)
+        if left.isStreaming && right.isStreaming && joinType != Inner => true
+      case f: FlatMapGroupsWithState
+        if f.isStreaming && f.outputMode == OutputMode.Append() => true
+      case _ => false
+    }
+
+    def isStatefulOperation(p: LogicalPlan): Boolean = p match {
+      case s: Aggregate if s.isStreaming => true
+      case _ @ Join(left, right, _, _, _) if left.isStreaming && 
right.isStreaming => true
+      case f: FlatMapGroupsWithState if f.isStreaming => true
+      case d: Deduplicate if d.isStreaming => true
+      case _ => false
+    }
+
+    var loggedWarnMessage = false
+    plan.foreach { subPlan =>
+      if (isStatefulOperation(subPlan)) {
+        subPlan.find { p =>
+          (p ne subPlan) && isStatefulOperationPossiblyEmitLateRows(p)
+        } match {
+          case Some(_) =>
+            val errorMsg = "Detected pattern of possible 'correctness' issue " 
+
+              "due to global watermark. " +
+              "The query contains stateful operation which can possibly emit 
late rows, and " +
 
 Review comment:
   See above suggestions about editing this text

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to