-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-48314][SS] Don't double cache files for FileStreamSource using Trigger.AvailableNow #46627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c907d94
Don't cache files for availableNow trigger
Kimahriman 90d8ec5
Add test
Kimahriman f4c425b
Cleanup
Kimahriman 38a7859
Merge branch 'master' into available-now-no-cache
Kimahriman 8879afe
Check files in batch and use new setting to test skipping cache
Kimahriman a7e0198
Remove extra newline
Kimahriman 4c33fef
Remove comment to go along with undo-ing visibility change
Kimahriman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2357,6 +2357,46 @@ class FileStreamSourceSuite extends FileStreamSourceTest { | |
| } | ||
| } | ||
|
|
||
| test("SPARK-48314: Don't cache unread files when using Trigger.AvailableNow") { | ||
| withCountListingLocalFileSystemAsLocalFileSystem { | ||
| withThreeTempDirs { case (src, meta, tmp) => | ||
| val options = Map("latestFirst" -> "true", "maxFilesPerTrigger" -> "5") | ||
| val scheme = CountListingLocalFileSystem.scheme | ||
| val source = new FileStreamSource(spark, s"$scheme:///${src.getCanonicalPath}/*/*", "text", | ||
| StructType(Nil), Seq.empty, meta.getCanonicalPath, options) | ||
|
|
||
| source.prepareForTriggerAvailableNow() | ||
|
|
||
| CountListingLocalFileSystem.resetCount() | ||
|
|
||
| // provide 20 files in src, with sequential "last modified" to guarantee ordering | ||
| (0 to 19).map { idx => | ||
| val f = createFile(idx.toString, new File(src, idx.toString), tmp) | ||
| f.setLastModified(idx * 10000) | ||
| f | ||
| } | ||
|
|
||
| source.latestOffset(FileStreamSourceOffset(-1L), ReadLimit.maxFiles(5)) | ||
| .asInstanceOf[FileStreamSourceOffset] | ||
|
|
||
| // All files are already tracked in allFilesForTriggerAvailableNow | ||
| assert(0 === CountListingLocalFileSystem.pathToNumListStatusCalled | ||
| .get(src.getCanonicalPath).map(_.get()).getOrElse(0)) | ||
|
|
||
| // Unread files should be empty | ||
| assert(source.unreadFiles == null) | ||
|
|
||
| // Reading again leverages the files already tracked in allFilesForTriggerAvailableNow, | ||
| // so no more listings need to happen | ||
| source.latestOffset(FileStreamSourceOffset(-1L), ReadLimit.maxFiles(5)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
| .asInstanceOf[FileStreamSourceOffset] | ||
|
|
||
| assert(0 === CountListingLocalFileSystem.pathToNumListStatusCalled | ||
| .get(src.getCanonicalPath).map(_.get()).getOrElse(0)) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-31962: file stream source shouldn't allow modifiedBefore/modifiedAfter") { | ||
| def formatTime(time: LocalDateTime): String = { | ||
| time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss")) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we check the result just for completeness sake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to check files returned, and used the new setting from #45362 to verify correct number of files based on not caching