-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-18464][SQL] support old table which doesn't store schema in metastore #15900
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
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 |
|---|---|---|
|
|
@@ -1371,4 +1371,26 @@ class MetastoreDataSourcesSuite extends QueryTest with SQLTestUtils with TestHiv | |
| } | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-18464: support old table which doesn't store schema in table properties") { | ||
| withTable("old") { | ||
| withTempPath { path => | ||
| Seq(1 -> "a").toDF("i", "j").write.parquet(path.getAbsolutePath) | ||
| val tableDesc = CatalogTable( | ||
| identifier = TableIdentifier("old", Some("default")), | ||
| tableType = CatalogTableType.EXTERNAL, | ||
| storage = CatalogStorageFormat.empty.copy( | ||
| properties = Map("path" -> path.getAbsolutePath) | ||
| ), | ||
| schema = new StructType(), | ||
| properties = Map( | ||
| HiveExternalCatalog.DATASOURCE_PROVIDER -> "parquet")) | ||
| hiveClient.createTable(tableDesc, ignoreIfExists = false) | ||
|
|
||
| checkAnswer(spark.table("old"), Row(1, "a")) | ||
|
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. Can we also test |
||
|
|
||
| checkAnswer(sql("DESC old"), Row("i", "int", null) :: Row("j", "string", null) :: Nil) | ||
| } | ||
| } | ||
| } | ||
|
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. It will be good to actually create a set of compatibility tests to make sure a new version of Spark can access table metadata created by a older version (starting from Spark 1.3) without problem. Let's create a follow-up jira for this task and do it during the QA period of spark 2.1.
Contributor
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. |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
btw, a clarification question. This function is only needed for data source tables, right?
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.
no, since we also store schema for hive table, hive table will also call this function. But hive table will never go into this branch, as it always has a schema.(the removal of runtime schema inference happened before we store schema of hive table)