Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16160#discussion_r90980149
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/ForeachSinkSuite.scala
 ---
    @@ -204,6 +204,55 @@ class ForeachSinkSuite extends StreamTest with 
SharedSQLContext with BeforeAndAf
           query.stop()
         }
       }
    +
    +  test("foreach with watermark: append") {
    +    val inputData = MemoryStream[Int]
    +
    +    val windowedAggregation = inputData.toDF()
    +      .withColumn("eventTime", $"value".cast("timestamp"))
    +      .withWatermark("eventTime", "10 seconds")
    +      .groupBy(window($"eventTime", "5 seconds") as 'window)
    +      .agg(count("*") as 'count)
    +      .select($"count".as[Long])
    +      .map(_.toInt)
    +      .repartition(1)
    +
    +    val query = windowedAggregation
    +      .writeStream
    +      .outputMode(OutputMode.Append)
    +      .foreach(new TestForeachWriter())
    +      .start()
    +    try {
    +      inputData.addData(10, 11, 12)
    +      query.processAllAvailable()
    +      inputData.addData(25) // Advance watermark to 15 seconds
    +      query.processAllAvailable()
    +      inputData.addData(25) // Evict items less than previous watermark
    +      query.processAllAvailable()
    +
    +      // There should be 3 batches and only does the last batch contain a 
value.
    +      val allEvents = ForeachSinkSuite.allEvents()
    +      assert(allEvents.size === 3)
    +      val expectedEvents = Seq(
    +        Seq(
    +          ForeachSinkSuite.Open(partition = 0, version = 0),
    +          ForeachSinkSuite.Close(None)
    +        ),
    +        Seq(
    +          ForeachSinkSuite.Open(partition = 0, version = 1),
    +          ForeachSinkSuite.Close(None)
    +        ),
    +        Seq(
    +          ForeachSinkSuite.Open(partition = 0, version = 2),
    +          ForeachSinkSuite.Process(value = 3),
    +          ForeachSinkSuite.Close(None)
    +        )
    +      )
    +      assert(allEvents === expectedEvents)
    +    } finally {
    +      query.stop()
    +    }
    +  }
    --- End diff --
    
    I dont see a test that verifies whether the metrics are correct


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to