-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-19748][SQL]refresh function has a wrong order to do cache invalidate and regenerate the inmemory var for InMemoryFileIndex with FileStatusCache #17079
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,6 +178,34 @@ class FileIndexSuite extends SharedSQLContext { | |
| assert(catalog2.allFiles().nonEmpty) | ||
| } | ||
| } | ||
|
|
||
| test("refresh for InMemoryFileIndex with FileStatusCache") { | ||
| withTempDir { dir => | ||
| val fileStatusCache = FileStatusCache.getOrCreate(spark) | ||
| val dirPath = new Path(dir.getAbsolutePath) | ||
| val catalog = new InMemoryFileIndex(spark, Seq(dirPath), Map.empty, | ||
| None, fileStatusCache) { | ||
| def leafFilePaths: Seq[Path] = leafFiles.keys.toSeq | ||
| def leafDirPaths: Seq[Path] = leafDirToChildrenFiles.keys.toSeq | ||
| } | ||
|
||
|
|
||
| assert(catalog.leafDirPaths.isEmpty) | ||
| assert(catalog.leafFilePaths.isEmpty) | ||
|
||
|
|
||
| val file = new File(dir, "text.txt") | ||
| stringToFile(file, "text") | ||
|
|
||
| catalog.refresh() | ||
|
|
||
| assert(catalog.leafFilePaths.size == 1) | ||
| assert(catalog.leafFilePaths.head.toString.stripSuffix("/") == | ||
| s"file:${file.getAbsolutePath.stripSuffix("/")}") | ||
|
||
|
|
||
| assert(catalog.leafDirPaths.size == 1) | ||
| assert(catalog.leafDirPaths.head.toString.stripSuffix("/") == | ||
| s"file:${dir.getAbsolutePath.stripSuffix("/")}") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| class FakeParentPathFileSystem extends RawLocalFileSystem { | ||
|
|
||
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.
nit: