Skip to content

Conversation

@gatorsmile
Copy link
Member

What changes were proposed in this pull request?

For Hive-serde tables, we always respect the schema stored in Hive metastore, because the schema could be altered by the other engines that share the same metastore. Thus, we always trust the metastore-controlled schema for Hive-serde tables when the schemas are different (without considering the nullability and cases). However, in some scenarios, Hive metastore also could INCORRECTLY overwrite the schemas when the serde and Hive metastore built-in serde are different.

The proposed solution is to introduce a table-specific option for such scenarios. For a specific table, users can make Spark always respect Spark-inferred/controlled schema instead of trusting metastore-controlled schema. By default, we trust Hive metastore-controlled schema.

How was this patch tested?

Added a cross-version test case

@SparkQA
Copy link

SparkQA commented Aug 20, 2017

Test build #80882 has finished for PR 19003 at commit 4c7349f.

  • This patch fails SparkR unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class SourceOptions(

@SparkQA
Copy link

SparkQA commented Aug 20, 2017

Test build #80899 has finished for PR 19003 at commit 4c7349f.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class SourceOptions(

| INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'
| OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'
|LOCATION '$location'
|TBLPROPERTIES ('avro.schema.literal' = '$avroSchema')
Copy link
Member Author

Choose a reason for hiding this comment

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

For such an example that requires users setting TBLPROPERTIES, it sounds like we are unable to use the CREATE TABLE USING command. cc @cloud-fan

Copy link
Contributor

Choose a reason for hiding this comment

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

There was an argument about whether we should add TBLPROPERTIES, and we decided to not add it. I'm totally fine to add it if it's necessary.

@gatorsmile
Copy link
Member Author

cc @sameeragarwal @cloud-fan

@cloud-fan
Copy link
Contributor

LGTM

@gatorsmile
Copy link
Member Author

retest this please

import org.apache.spark.sql.catalyst.util.CaseInsensitiveMap

/**
* Options for the Parquet data source.
Copy link
Member

Choose a reason for hiding this comment

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

nit: update docs

@sameeragarwal
Copy link
Member

LGTM, thanks! Are these table properties documented somewhere?

@gatorsmile
Copy link
Member Author

We might need a dedicated section for documenting all the table-specific conf options.

@gatorsmile gatorsmile closed this Aug 22, 2017
@gatorsmile gatorsmile reopened this Aug 22, 2017
@SparkQA
Copy link

SparkQA commented Aug 22, 2017

Test build #80999 has finished for PR 19003 at commit 4c7349f.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class SourceOptions(

@sameeragarwal
Copy link
Member

Merging to master, thanks!

@asfgit asfgit closed this in 01a8e46 Aug 22, 2017
@SparkQA
Copy link

SparkQA commented Aug 22, 2017

Test build #81001 has finished for PR 19003 at commit 36339c8.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants