-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-39552][SQL] Unify v1 and v2 DESCRIBE TABLE
#36946
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 6 commits
ecec69b
4ffa242
c17b346
2224caa
227b99f
699e72e
c75e090
39ed298
d95ff9a
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 |
|---|---|---|
|
|
@@ -28,26 +28,6 @@ import org.apache.spark.util.Utils | |
| */ | ||
| class DescribeTableSuite extends command.DescribeTableSuiteBase with CommandSuiteBase { | ||
|
|
||
| test("DESCRIBE TABLE with non-'partitioned-by' clause") { | ||
| withNamespaceAndTable("ns", "table") { tbl => | ||
| spark.sql(s"CREATE TABLE $tbl (id bigint, data string) $defaultUsing") | ||
| val descriptionDf = spark.sql(s"DESCRIBE TABLE $tbl") | ||
| assert(descriptionDf.schema.map(field => (field.name, field.dataType)) === | ||
| Seq( | ||
| ("col_name", StringType), | ||
| ("data_type", StringType), | ||
| ("comment", StringType))) | ||
| QueryTest.checkAnswer( | ||
| descriptionDf, | ||
| Seq( | ||
| Row("data", "string", ""), | ||
| Row("id", "bigint", ""), | ||
| Row("", "", ""), | ||
| Row("# Partitioning", "", ""), | ||
| Row("Not partitioned", "", ""))) | ||
| } | ||
| } | ||
|
|
||
| test("Describing a partition is not supported") { | ||
| withNamespaceAndTable("ns", "table") { tbl => | ||
| spark.sql(s"CREATE TABLE $tbl (id bigint, data string) $defaultUsing " + | ||
|
|
@@ -74,11 +54,11 @@ class DescribeTableSuite extends command.DescribeTableSuiteBase with CommandSuit | |
| QueryTest.checkAnswer( | ||
| descriptionDf, | ||
| Seq( | ||
| Row("id", "bigint", ""), | ||
| Row("data", "string", ""), | ||
| Row("", "", ""), | ||
| Row("# Partitioning", "", ""), | ||
| Row("Part 0", "id", ""), | ||
| Row("id", "bigint", null), | ||
| Row("data", "string", null), | ||
| Row("# Partition Information", "", ""), | ||
| Row("# col_name", "data_type", "comment"), | ||
| Row("id", "bigint", null), | ||
|
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. just for curiosity: what's different between v1 and v2 DESC TABLE for this test
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. v2 (after the PR): v1 in memory:
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. v1 (hive):
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. I see, can we at least include
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. done |
||
| Row("", "", ""), | ||
| Row("# Metadata Columns", "", ""), | ||
| Row("index", "int", "Metadata column used to conflict with a data column"), | ||
|
|
||
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.
I think it's more tricky here, as the reference can be a nested field, e.g.
a.b. We can still keep the output in a v1 compatible way, but the code to find its type and comment will be a bit more complicated, as we need to useStructType.findNestedFieldThere 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.
I added a test for v2 implementation: partitioning by nested columns. Just in case, v1 doesn't support partitioning by nested columns. Also I fixed v2 impl to pass the new test.