xuanyuanking commented on a change in pull request #29256:
URL: https://github.com/apache/spark/pull/29256#discussion_r463506970



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamingQuerySuite.scala
##########
@@ -1106,6 +1107,54 @@ class StreamingQuerySuite extends StreamTest with 
BeforeAndAfter with Logging wi
     }
   }
 
+  test("union in streaming query of append mode without watermark") {
+    val inputData1 = MemoryStream[Int]
+    val inputData2 = MemoryStream[Int]
+    withTempView("s1", "s2") {
+      inputData1.toDF().createOrReplaceTempView("s1")
+      inputData2.toDF().createOrReplaceTempView("s2")
+      val unioned = spark.sql(
+        "select s1.value from s1 union select s2.value from s2")
+      checkExceptionMessage(unioned)
+    }
+  }
+
+  test("distinct in streaming query of append mode without watermark") {
+    val inputData = MemoryStream[Int]
+    withTempView("deduptest") {
+      inputData.toDF().toDF("value").createOrReplaceTempView("deduptest")
+      val distinct = spark.sql("select distinct value from deduptest")
+      checkExceptionMessage(distinct)
+    }
+  }
+
+  test("distinct in streaming query of complete mode") {
+    val inputData = MemoryStream[Int]
+    withTempView("deduptest") {
+      inputData.toDF().toDF("value").createOrReplaceTempView("deduptest")
+      val distinct = spark.sql("select distinct value from deduptest")
+
+      testStream(distinct, Complete)(
+        AddData(inputData, 1, 2, 3, 3, 4),
+        CheckAnswer(Row(1), Row(2), Row(3), Row(4))

Review comment:
       ```
   What result would we expect if there's another batch (3, 3, 4, 5)?
   ```
   It should be `1,2,3,4,5`.
   I only add one batch here just want to show the distinct in complete can 
pass the analyzer. Because without this change, we'll get an exception of 
`Complete output mode not supported when there are no streaming aggregations on 
streaming DataFrames/Datasets;`.
   Let me add this in the test, maybe it's more clear to explain the behavior 
of `distinct` for multiple batches. The distinct operation should both distinct 
within a single batch and cross multi-batches.
   
   Is this make sense to you?
   ```
   testStream(distinct, Complete)(
       AddData(inputData, 1, 2, 3, 3, 4),
       CheckAnswer(Row(1), Row(2), Row(3), Row(4)),
       AddData(inputData, 3, 3, 4, 5),
       CheckAnswer(Row(1), Row(2), Row(3), Row(4), Row(5))
   )
   ```




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



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

Reply via email to