-
Notifications
You must be signed in to change notification settings - Fork 29.2k
[SPARK-26990][SQL]FileIndex: use user specified field names if possible #23894
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 1 commit
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 |
|---|---|---|
|
|
@@ -65,6 +65,21 @@ class FileIndexSuite extends SharedSQLContext { | |
| } | ||
| } | ||
|
|
||
| test("SPARK-26990: use user specified field names if possible") { | ||
| withTempDir { dir => | ||
| val partitionDirectory = new File(dir, "a=foo") | ||
| partitionDirectory.mkdir() | ||
| val file = new File(partitionDirectory, "text.txt") | ||
| stringToFile(file, "text") | ||
| val path = new Path(dir.getCanonicalPath) | ||
| val schema = StructType(Seq(StructField("A", StringType, false))) | ||
| withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") { | ||
|
Member
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. Also test the behavior when the conf is on.
Member
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. When the conf is on, the schema will be |
||
| val fileIndex = new InMemoryFileIndex(spark, Seq(path), Map.empty, Some(schema)) | ||
| assert(fileIndex.partitionSchema.length == 1 && fileIndex.partitionSchema.head.name == "A") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-26230: if case sensitive, validate partitions with original column names") { | ||
| withTempDir { dir => | ||
| val partitionDirectory = new File(dir, "a=1") | ||
|
|
||
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.
just a nit: we can maybe separate the
userSpecifiedNamesmap creation in order to improve code readability. Moreover we need it only if!caseSensitive. So what about: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.
Thanks! I have revised the code.