Skip to content
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

[SPARK-21085] [SQL] Failed to read the partitioned table created by Spark 2.1 #18295

Closed
wants to merge 1 commit into from

Conversation

gatorsmile
Copy link
Member

What changes were proposed in this pull request?

Before the PR, Spark is unable to read the partitioned table created by Spark 2.1 when the table schema does not put the partitioning column at the end of the schema.
assert(partitionFields.map(_.name) == partitionColumnNames)

When reading the table metadata from the metastore, we also need to reorder the columns.

How was this patch tested?

Added test cases to check both Hive-serde and data source tables.

@gatorsmile
Copy link
Member Author

cc @cloud-fan

@SparkQA
Copy link

SparkQA commented Jun 14, 2017

Test build #78028 has finished for PR 18295 at commit 719ecf2.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

schema = schemaFromTableProps,
partitionColumnNames = getPartitionColumnsFromTableProperties(table),
schema = reorderedSchema,
partitionColumnNames = partColumnNames,
bucketSpec = getBucketSpecFromTableProperties(table))
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the case below that Hive metastore changes the table schema, can we pass that assert always?

@cloud-fan
Copy link
Contributor

LGTM, merging to master/2.2!

asfgit pushed a commit that referenced this pull request Jun 14, 2017
…ark 2.1

### What changes were proposed in this pull request?
Before the PR, Spark is unable to read the partitioned table created by Spark 2.1 when the table schema does not put the partitioning column at the end of the schema.
[assert(partitionFields.map(_.name) == partitionColumnNames)](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/interface.scala#L234-L236)

When reading the table metadata from the metastore, we also need to reorder the columns.

### How was this patch tested?
Added test cases to check both Hive-serde and data source tables.

Author: gatorsmile <gatorsmile@gmail.com>

Closes #18295 from gatorsmile/reorderReadSchema.

(cherry picked from commit 0c88e8d)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
@asfgit asfgit closed this in 0c88e8d Jun 14, 2017
dataknocker pushed a commit to dataknocker/spark that referenced this pull request Jun 16, 2017
…ark 2.1

### What changes were proposed in this pull request?
Before the PR, Spark is unable to read the partitioned table created by Spark 2.1 when the table schema does not put the partitioning column at the end of the schema.
[assert(partitionFields.map(_.name) == partitionColumnNames)](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/interface.scala#L234-L236)

When reading the table metadata from the metastore, we also need to reorder the columns.

### How was this patch tested?
Added test cases to check both Hive-serde and data source tables.

Author: gatorsmile <gatorsmile@gmail.com>

Closes apache#18295 from gatorsmile/reorderReadSchema.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants