Skip to content

[SPARK-56390][SQL] Avoid throwing away resolved child when constructing V1 command variants of ShowColumns and DescribeRelation#55247

Open
dhruvarya-db wants to merge 4 commits intoapache:masterfrom
dhruvarya-db:childInV1DescribeCommand
Open

[SPARK-56390][SQL] Avoid throwing away resolved child when constructing V1 command variants of ShowColumns and DescribeRelation#55247
dhruvarya-db wants to merge 4 commits intoapache:masterfrom
dhruvarya-db:childInV1DescribeCommand

Conversation

@dhruvarya-db
Copy link
Copy Markdown

@dhruvarya-db dhruvarya-db commented Apr 7, 2026

What changes were proposed in this pull request?

ResolveSessionCatalog transforms DescribeRelation (DESCRIBE TABLE) to DescribeTableCommand and ShowColumns to ShowColumnsCommand in some scenarios. While doing so, it throws away the resolved entity information. This PR, adds a child LogicalPlan to ShowColumnsCommand and DescribeTableCommand to store this resolved entity just like their V2 counterparts ShowColumns and DescribeRelation.

Why are the changes needed?

By storing the resolved entity in the V1 command variants, we can avoid throwing away useful info that can help us avoid extra catalog lookups.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Ran PlanResolutionSuite and SQLQueryTestSuite

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

No

@cloud-fan cloud-fan changed the title Avoid throwing away resolved child when constructing V1 command variants of ShowColumns and DescribeRelation [SPARK-56390][SQL] Avoid throwing away resolved child when constructing V1 command variants of ShowColumns and DescribeRelation Apr 8, 2026
@dhruvarya-db dhruvarya-db force-pushed the childInV1DescribeCommand branch from afe5022 to 3ae3040 Compare April 8, 2026 04:42
@cloud-fan
Copy link
Copy Markdown
Contributor

let's use the resolved child in the def run method.

val catalog = sparkSession.sessionState.catalog
// V2SessionCatalog.loadTable uses getTableMetadata which replaces char/varchar with string
// in the CatalogTable schema. Restore the original types from field metadata so that
// DESCRIBE TABLE reports char(n)/varchar(n) instead of string.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is a good catch! shall we do CharVarcharUtils.getRawSchema in the util function ResolvedChildHelper.getTableMetadata? SHOW COLUMNS should report char/varchar instead of string as well.

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.

3 participants