Skip to content

Allow staging table creation with the same name. - #1230

Merged
tdas merged 1 commit into
unitycatalog:mainfrom
yili-db:staging_table_dup
Nov 20, 2025
Merged

tdas merged 1 commit into
unitycatalog:mainfrom
yili-db:staging_table_dup

Conversation

@yili-db

@yili-db yili-db commented Nov 19, 2025 •

Copy link
Copy Markdown
Collaborator

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

This is to fix a bug that UC didn't allow a 2nd staging table to be created using the same name. However this is actually a valid use case. When the table creation failed after the staging table is created but before the table creation, the dangling staging table would prevent retrying effort to create the table using the same name again. We have to allow the staging table to be created again using the same name to get it through. The new staging table will have new ID and location so it won't be a problem anyway.

Related issue
#1143

@Table(
name = "uc_staging_tables",
indexes = {
@Index(name = "idx_name", columnList = "name"),

@yili-db yili-db Nov 20, 2025 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Name no longer matters. We no longer query by name. It's OK to have multiple entries with the same name too.

This is to fix a bug that UC didn't allow a 2nd staging table to be created using the same name. However this is actually a valid use case. When the table creation failed after the staging table is created by before the table creation, the dangling staging table would prevent retrying effort to create the table using the same name again. We have to allow the staging table to be created again using the same name to get it through. The new staging table will have new ID and location so it won't be a problem anyway.

Signed-off-by: Yi Li <[email protected]>
this.serverProperties = serverProperties;
}

private StagingTableDAO findBySchemaIdAndName(Session session, UUID schemaId, String name) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No longer need to query by name.

Session session, UUID schemaId, String tableName, String stagingLocation) {
// check if staging table or table by the same name already exists
// Also ensure that no staging table exists at the same location
StagingTableDAO existingStagingTable = findBySchemaIdAndName(session, schemaId, tableName);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is the actual change. Skip searching for staging table by name. Allow duplicate names to be used again.

@yili-db yili-db closed this Nov 20, 2025
@yili-db yili-db reopened this Nov 20, 2025
@yili-db yili-db closed this Nov 20, 2025
@yili-db yili-db reopened this Nov 20, 2025
@yili-db yili-db closed this Nov 20, 2025
@yili-db yili-db reopened this Nov 20, 2025
@tdas
tdas merged commit 6de5acb into unitycatalog:main Nov 20, 2025
yili-db added a commit to yili-db/unitycatalog that referenced this pull request Nov 20, 2025
**PR Checklist**

- [X] A description of the changes is added to the description of this
PR.
- [X] If there is a related issue, make sure it is linked to this PR.
- [ ] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated

**Description of changes**

This is to fix a bug that UC didn't allow a 2nd staging table to be
created using the same name. However this is actually a valid use case.
When the table creation failed after the staging table is created but
before the table creation, the dangling staging table would prevent
retrying effort to create the table using the same name again. We have
to allow the staging table to be created again using the same name to
get it through. The new staging table will have new ID and location so
it won't be a problem anyway.

**Related issue**
unitycatalog#1143

Signed-off-by: Yi Li <[email protected]>
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