Skip to content

Commit

Permalink
[SPARK-36213][SQL] Normalize PartitionSpec for DescTable with Partiti…
Browse files Browse the repository at this point in the history
…onSpec
  • Loading branch information
yaooqinn committed Jul 19, 2021
1 parent c7ccc60 commit afa5539
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
Expand Up @@ -658,7 +658,12 @@ case class DescribeTableCommand(
throw QueryCompilationErrors.descPartitionNotAllowedOnView(table.identifier)
}
DDLUtils.verifyPartitionProviderIsHive(spark, metadata, "DESC PARTITION")
val partition = catalog.getPartition(table, partitionSpec)
val normalizedPartSpec = PartitioningUtils.normalizePartitionSpec(
partitionSpec,
metadata.partitionSchema,
table.quotedString,
spark.sessionState.conf.resolver)
val partition = catalog.getPartition(table, normalizedPartSpec)
if (isExtended) describeFormattedDetailedPartitionInfo(table, metadata, partition, result)
}

Expand Down
2 changes: 2 additions & 0 deletions sql/core/src/test/resources/sql-tests/inputs/describe.sql
Expand Up @@ -43,6 +43,8 @@ DESC EXTENDED t PARTITION (c='Us', d=1);

DESC FORMATTED t PARTITION (c='Us', d=1);

DESC EXTENDED t PARTITION (C='Us', D=1);

-- NoSuchPartitionException: Partition not found in table
DESC t PARTITION (c='Us', d=2);

Expand Down
33 changes: 32 additions & 1 deletion sql/core/src/test/resources/sql-tests/results/describe.sql.out
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 41
-- Number of queries: 42


-- !query
Expand Down Expand Up @@ -324,6 +324,37 @@ Location [not included in comparison]/{warehouse_dir}/t
Storage Properties [a=1, b=2]


-- !query
DESC EXTENDED t PARTITION (C='Us', D=1)
-- !query schema
struct<col_name:string,data_type:string,comment:string>
-- !query output
a string
b int
c string
d string
# Partition Information
# col_name data_type comment
c string
d string

# Detailed Partition Information
Database default
Table t
Partition Values [c=Us, d=1]
Location [not included in comparison]/{warehouse_dir}/t/c=Us/d=1
Storage Properties [a=1, b=2]
Created Time [not included in comparison]
Last Access [not included in comparison]

# Storage Information
Num Buckets 2
Bucket Columns [`a`]
Sort Columns [`b`]
Location [not included in comparison]/{warehouse_dir}/t
Storage Properties [a=1, b=2]


-- !query
DESC t PARTITION (c='Us', d=2)
-- !query schema
Expand Down

0 comments on commit afa5539

Please sign in to comment.