Skip to content

[SPARK-39660][SQL] Support v2 DESCRIBE TABLE .. PARTITION#55064

Open
viirya wants to merge 5 commits intoapache:masterfrom
viirya:SPARK-39660-describe-table-partition-v2
Open

[SPARK-39660][SQL] Support v2 DESCRIBE TABLE .. PARTITION#55064
viirya wants to merge 5 commits intoapache:masterfrom
viirya:SPARK-39660-describe-table-partition-v2

Conversation

@viirya
Copy link
Copy Markdown
Member

@viirya viirya commented Mar 27, 2026

What changes were proposed in this pull request?

Enable DESCRIBE [EXTENDED] TABLE <v2_table> PARTITION (col=val, ...) for V2 tables that implement SupportsPartitionManagement, bringing parity with the V1/Hive behavior.

Previously any partition spec on a V2 table threw unconditionally:
"DESCRIBE does not support partition for v2 tables."

Changes:

  • DataSourceV2Strategy: replaced blanket error throw with a capability check (SupportsPartitionManagement); passes partitionSpec through to DescribeTableExec.
  • DescribeTableExec: added partitionSpec parameter and new addPartitionDetails() method that normalizes the spec, converts it to a typed InternalRow, validates partition existence via loadPartitionMetadata(), and (for EXTENDED) appends a # Detailed Partition Information section.
  • QueryCompilationErrors / error-conditions.json: replaced legacy _LEGACY_ERROR_TEMP_1111 with named error DESCRIBE_PARTITION_NOT_SUPPORTED_FOR_V2_TABLE.
  • Resolve partition spec at analysis time for DESCRIBE TABLE PARTITION: Use Option[PartitionSpec] in DescribeRelation and extend V2PartitionCommand so ResolvePartitionSpec handles UnresolvedPartitionSpec -> ResolvedPartitionSpec resolution automatically during analysis, consistent with other partition commands.

Why are the changes needed?

DESCRIBE TABLE .. PARTITION was not supported for V2 tables. This adds the missing support by integrating with the existing V2 partition infrastructure: DescribeRelation now extends V2PartitionCommand so partition specs are resolved at analysis time through ResolvePartitionSpec, consistent with how other partition commands (e.g., SHOW PARTITIONS, ALTER TABLE .. DROP PARTITION) work.

Does this PR introduce any user-facing change?

Yes. DESCRIBE TABLE .. PARTITION supports V2 table after this PR.

How was this patch tested?

Replaced the single "not supported" test in v2/DescribeTableSuite with four targeted tests: partition validation, extended partition info, non-existent partition error, and capability error for tables without partition management. All 29 V2 + 66 V1 DescribeTableSuite tests pass.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Sonnet 4.6

@viirya viirya force-pushed the SPARK-39660-describe-table-partition-v2 branch 2 times, most recently from e2f7bc6 to 9152840 Compare March 28, 2026 16:08
viirya and others added 2 commits March 28, 2026 17:13
## What changes were proposed in this pull request?

Enable `DESCRIBE [EXTENDED] TABLE <v2_table> PARTITION (col=val, ...)` for
V2 tables that implement `SupportsPartitionManagement`, bringing parity with
the V1/Hive behavior.

Previously any partition spec on a V2 table threw unconditionally:
  "DESCRIBE does not support partition for v2 tables."

### Changes:
- `DataSourceV2Strategy`: replaced blanket error throw with a capability
  check (`SupportsPartitionManagement`); passes `partitionSpec` through to
  `DescribeTableExec`.
- `DescribeTableExec`: added `partitionSpec` parameter and new
  `addPartitionDetails()` method that normalizes the spec, converts it to a
  typed `InternalRow`, validates partition existence via
  `loadPartitionMetadata()`, and (for EXTENDED) appends a
  `# Detailed Partition Information` section.
- `QueryCompilationErrors` / `error-conditions.json`: replaced legacy
  `_LEGACY_ERROR_TEMP_1111` with named error
  `DESCRIBE_PARTITION_NOT_SUPPORTED_FOR_V2_TABLE`.

## How was this patch tested?

Replaced the single "not supported" test in `v2/DescribeTableSuite` with
four targeted tests: partition validation, extended partition info, non-
existent partition error, and capability error for tables without partition
management. All 29 V2 + 66 V1 `DescribeTableSuite` tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…BE TABLE PARTITION

Use Option[PartitionSpec] in DescribeRelation and extend V2PartitionCommand
so ResolvePartitionSpec handles UnresolvedPartitionSpec -> ResolvedPartitionSpec
resolution automatically during analysis, consistent with other partition commands.

Move the non-partition-management error check from DataSourceV2Strategy into
CheckAnalysis so it is raised as an AnalysisException at analysis time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@viirya viirya force-pushed the SPARK-39660-describe-table-partition-v2 branch from 9152840 to 01a7d46 Compare March 29, 2026 00:13
viirya and others added 3 commits March 29, 2026 13:46
Fix alphabetical ordering of DESCRIBE_PARTITION_NOT_SUPPORTED_FOR_V2_TABLE
in error-conditions.json (must come after DESCRIBE_JSON_NOT_EXTENDED).

Update describe.sql analyzer golden file to reflect new UnresolvedPartitionSpec
toString format after DescribeRelation.partitionSpec changed from
TablePartitionSpec to Option[PartitionSpec].

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…] renders with double brackets

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…s from DescribeRelation arg

Option[PartitionSpec] renders without surrounding brackets in the plan string,
unlike the previous Map[String, String] which rendered as [k=v, ...].

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
EXPLAIN DESCRIBE t PARTITION (c='Us', d=2)
-- !query analysis
ExplainCommand 'DescribeRelation [c=Us, d=2], false, [col_name#x, data_type#x, comment#x], SimpleMode
ExplainCommand 'DescribeRelation unresolvedpartitionspec((c,Us), (d,2), None), false, [col_name#x, data_type#x, comment#x], SimpleMode
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

At the first glance, this looks a little strange. However, since this is EXPLAIN on DESCRIBE statement, this unresolvedpartitionspec seems fine to me, too.

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.

2 participants