Skip to content

[SPARK-52272][SQL] V2SessionCatalog does not alter schema on Hive Catalog #51007

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

szehon-ho
Copy link
Contributor

@szehon-ho szehon-ho commented May 24, 2025

What changes were proposed in this pull request?

V2SessionCatalog delegates alterTable to SessionCatalog (V1) alterTable. In the case of "hive", this should be changed to delegate to either alterTable or alterTableDataSchema.

Why are the changes needed?

SessionCatalog has two API's, alterTable and alterTableDataSchema.

alterTable will silently ignore schema changes in Hive implementation (the API Javadoc: If the underlying implementation does not support altering a certain field, this becomes a no-op. ).

So for Hive case, V2SessionCatalog needs to delegate schema changes to V1 alterTableDataSchema

Does this PR introduce any user-facing change?

No

How was this patch tested?

Add new test in HiveDDLSuite, verify functionality and which method is called.

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

No

catalogTable.copy(
properties = finalProperties, schema = schema, owner = owner, comment = comment,
collation = collation, storage = storage))
if (SQLConf.get.getConf(StaticSQLConf.CATALOG_IMPLEMENTATION).equals("hive")) {
Copy link
Contributor Author

@szehon-ho szehon-ho May 24, 2025

Choose a reason for hiding this comment

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

Note: SessionCatalog (V1) alterTableDataSchema explicitly does not support 'drop column'. https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala#L499

So to avoid regression in InMemoryCatalog, in which alterTable can alter the schema including 'drop column', I make the change only for "hive". Following the config check for CATALOG_IMPLEMENTATION in other parts of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant