Skip to content

[SPARK-56296][SQL] Pivot createTableLike to pass full TableInfo including schema, partitioning, constraints, and owner - #55101

Closed
viirya wants to merge 2 commits into
apache:masterfrom
viirya:create-table-like-prop-owner-fix
Closed

viirya wants to merge 2 commits into
apache:masterfrom
viirya:create-table-like-prop-owner-fix

Conversation

@viirya

@viirya viirya commented Mar 30, 2026

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

Previously createTableLike(ident, sourceTable, userSpecifiedOverrides) only passed user-specified TBLPROPERTIES to the connector via TableInfo, requiring connectors to call CurrentUserContext.getCurrentUser (a Catalyst internal) to set the owner.

We should not expose Catalyst internal to connectors. But putting owner to the TableInfo means that we will have to rename userProvidedOverrides to something else, meaning it no longer contains only user overrides.

This change pivots to createTableLike(ident, tableInfo, sourceTable) where tableInfo contains all explicit information for the new table:

  • columns and partitioning copied from the source
  • constraints copied from the source
  • user-specified TBLPROPERTIES, LOCATION, and USING provider (if given)
  • PROP_OWNER set to the current user

Source table properties are intentionally excluded from tableInfo; connectors receive sourceTable to clone any format-specific or custom state they need. This matches the pattern used by REPLACE TABLE in DSv2.

Update InMemoryTableCatalog, CatalogSuite, and CreateTableLikeSuite accordingly.

Why are the changes needed?

This pivot is necessary to keep a balance between API consistency and internal exposure.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Unit tests

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

Generated-by: Claude Sonnet 4.6

…ding schema, partitioning, constraints, and owner

Previously createTableLike(ident, sourceTable, userSpecifiedOverrides) only
passed user-specified TBLPROPERTIES to the connector via TableInfo, requiring
connectors to (1) call CurrentUserContext.getCurrentUser (a Catalyst internal)
to set the owner, and (2) read columns/partitioning/constraints themselves from
sourceTable.

This change pivots to createTableLike(ident, tableInfo, sourceTable) where
tableInfo contains all explicit information for the new table:
- columns and partitioning copied from the source
- constraints copied from the source
- user-specified TBLPROPERTIES, LOCATION, and USING provider (if given)
- PROP_OWNER set to the current user

Source table properties are intentionally excluded from tableInfo; connectors
receive sourceTable to clone any format-specific or custom state they need.
This matches the pattern used by REPLACE TABLE in DSv2.

Update InMemoryTableCatalog, CatalogSuite, and CreateTableLikeSuite accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@viirya
viirya requested a review from aokolnychyi March 31, 2026 00:14

@aokolnychyi aokolnychyi left a comment

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.

+1 with one minor style suggestion.

…() on getters

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@viirya viirya closed this in 0f0c0e2 Apr 1, 2026
@viirya

viirya commented Apr 1, 2026

Copy link
Copy Markdown
Member Author

Merged to master. Thanks @aokolnychyi

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