Github user zsxwing commented on the issue:

    https://github.com/apache/spark/pull/13513
  
    @jerryshao here is a test case to show the issue about `getBatch`:
    
    ```Scala
      test("getBatch") {
        withTempDirs { case (src, tmp) =>
          withSQLConf(
            SQLConf.FILE_SOURCE_LOG_COMPACT_INTERVAL.key -> "2",
            // Force deleting the old logs
            SQLConf.FILE_SOURCE_LOG_CLEANUP_DELAY.key -> "1"
          ) {
            val fileStream = createFileStream("text", src.getCanonicalPath)
            val filtered = fileStream.filter($"value" contains "keep")
    
            testStream(filtered)(
              AddTextFileData("keep1", src, tmp),
              CheckAnswer("keep1"),
              AddTextFileData("keep2", src, tmp),
              CheckAnswer("keep1", "keep2"),
              AddTextFileData("keep3", src, tmp),
              CheckAnswer("keep1", "keep2", "keep3"),
              AssertOnQuery("check getBatch") { execution: StreamExecution =>
                val _sources = PrivateMethod[Seq[Source]]('sources)
                val fileSource =
                  (execution invokePrivate 
_sources()).head.asInstanceOf[FileStreamSource]
                assert(fileSource.getBatch(None, 
LongOffset(2)).as[String].collect() ===
                  List("keep1", "keep2", "keep3"))
                assert(fileSource.getBatch(Some(LongOffset(0)), 
LongOffset(2)).as[String].collect() ===
                  List("keep2", "keep3"))
                assert(fileSource.getBatch(Some(LongOffset(1)), 
LongOffset(2)).as[String].collect() ===
                  List("keep3"))
              }
            )
          }
        }
      }
    ```


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to