-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-11500][SQL] Not deterministic order of columns when using merging schemas. #9517
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 all commits
b0e6ce2
08fc91c
bcf72d3
4f47063
32dfb87
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 |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ import com.google.common.io.Files | |
| import org.apache.hadoop.fs.Path | ||
|
|
||
| import org.apache.spark.deploy.SparkHadoopUtil | ||
| import org.apache.spark.sql.{execution, AnalysisException, SaveMode} | ||
| import org.apache.spark.sql._ | ||
| import org.apache.spark.sql.types._ | ||
|
|
||
|
|
||
|
|
@@ -155,4 +155,23 @@ class ParquetHadoopFsRelationSuite extends HadoopFsRelationTest { | |
| assert(physicalPlan.collect { case p: execution.Filter => p }.length === 1) | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-11500: Not deterministic order of columns when using merging schemas.") { | ||
| import testImplicits._ | ||
| withSQLConf(SQLConf.PARQUET_SCHEMA_MERGING_ENABLED.key -> "true") { | ||
| withTempPath { dir => | ||
| val pathOne = s"${dir.getCanonicalPath}/part=1" | ||
| Seq(1, 1).zipWithIndex.toDF("a", "b").write.parquet(pathOne) | ||
| val pathTwo = s"${dir.getCanonicalPath}/part=2" | ||
| Seq(1, 1).zipWithIndex.toDF("c", "b").write.parquet(pathTwo) | ||
| val pathThree = s"${dir.getCanonicalPath}/part=3" | ||
| Seq(1, 1).zipWithIndex.toDF("d", "b").write.parquet(pathThree) | ||
|
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. We should probably use a partitioned table here. Directories like
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. Thanks for commands! |
||
|
|
||
| // The schema consists of the leading columns of the first part-file | ||
| // in the lexicographic order. | ||
| assert(sqlContext.read.parquet(dir.getCanonicalPath).schema.map(_.name) | ||
| === Seq("a", "b", "c", "d", "part")) | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.
Does HDFS guarantee that the result of
listStatus()is always sorted? If not, we probably need to sort theseFileStatuses.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.
Yes, I think I should sort them.
It looks it is not really recommended just to use it as it is, although they are sorted, assuming from this link.