Skip to content

Doc: Added missing instructions for schema upgrade from v4 to v5 in 1.7.0 doc - #5437

Open
MonkeyCanCode wants to merge 3 commits into
apache:versioned-docsfrom
MonkeyCanCode:fix_schema_update_doc
Open

Doc: Added missing instructions for schema upgrade from v4 to v5 in 1.7.0 doc#5437
MonkeyCanCode wants to merge 3 commits into
apache:versioned-docsfrom
MonkeyCanCode:fix_schema_update_doc

Conversation

@MonkeyCanCode

Copy link
Copy Markdown
Contributor

Follow up on #5349 where the current SQL instructions missed the drop for table idempotency_records and its indices.

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

@github-project-automation github-project-automation Bot moved this to PRs In Progress in Basic Kanban Board Sep 3, 2026
@MonkeyCanCode MonkeyCanCode changed the title Added missing instructions for schema upgrade from v4 to v5 in 1.7.0 doc Doc: Added missing instructions for schema upgrade from v4 to v5 in 1.7.0 doc Sep 3, 2026
@MonkeyCanCode
MonkeyCanCode deleted the fix_schema_update_doc branch September 3, 2026 07:46
@github-project-automation github-project-automation Bot moved this from PRs In Progress to Done in Basic Kanban Board Sep 3, 2026
@MonkeyCanCode
MonkeyCanCode restored the fix_schema_update_doc branch September 3, 2026 16:00
@MonkeyCanCode MonkeyCanCode reopened this Sep 3, 2026
@github-project-automation github-project-automation Bot moved this from Done to PRs In Progress in Basic Kanban Board Sep 3, 2026

@ayushtkn ayushtkn left a comment

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.

Thanx @MonkeyCanCode for the fix.

DROP TABLE IF EXISTS polaris_schema.idempotency_records;
ALTER TABLE polaris_schema.events ALTER COLUMN catalog_id DROP NOT NULL;
UPDATE polaris_schema.events SET catalog_id = NULL WHERE catalog_id = '__realm__';
DROP TABLE IF EXISTS polaris_schema.idempotency_records;

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.

This DROP TABLE is a duplicate of the one above the ALTER.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hello @ayushtkn ,

Yes, this had been updated. Copy/Paste issue. Same responded to the current on-going PR: https://github.com/apache/polaris/pull/5349/changes#r3942654660.

Thanks,
Yong

CockroachDB, and H2), then restart Polaris:

```sql
DROP INDEX IF EXISTS polaris_schema.idx_idemp_realm_expires;

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.

Is DROP INDEX intentional? I think dropping the table drops its index on Postgres, CockroachDB and H2 alike.
this index is created on idempotency_records

CREATE INDEX IF NOT EXISTS idx_idemp_realm_expires
ON idempotency_records (realm_id, expires_at);

which we are dropping below

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.

FYI I suggested to @MonkeyCanCode dropping the index too, mostly for completeness. I'm fine not dropping it explicitly though, if you think that's better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @adutra and @ayushtkn ,

Yes, this is for matching to https://github.com/adutra/polaris/blob/0668f5d5279e1cb367e16cc9991966d01352666b/site/content/in-dev/unreleased/metastores/relational-jdbc.md.

With implicitly drops, I do think it is easier if people want to revert the changes (as now they see the implicit removal of tables and indices). However, it does make the instructions more lengthy as drop a table would drop the index as well. I am fine with both way. This is mainly created to match to above PR.

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.

Thanx @adutra and @MonkeyCanCode for sharing the context. I was just curious if there is some functionality difference which I wasn’t aware. I am happy both ways, whichever everyone feels better

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In PSQL, there is none. Drop tables will drop indices (along with all other constraints). This PR was mainly to follow the same pattern that @adutra has in the single SQL PR.

IMO, if we don't want to support fall-back (down-upgrade), we should remove the drop index parts. If we do want to support some fall-back, the approach @adutra has is good. The only thing we may sign ourself up for is to keep those been implicit for other things such as relations etc. later on if certain tables has relations constraints and got dropped in the schema evolution.


```sql
DROP INDEX IF EXISTS polaris_schema.idx_idemp_realm_expires;
DROP INDEX IF EXISTS polaris_schema.idempotency_records;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The duplicate is gone, but the replacement now tries to DROP INDEX on idempotency_records, which is a table in schema v4. PostgreSQL rejects this even with IF EXISTS, so running the upgrade with ON_ERROR_STOP enabled stops before the remaining migration statements. Could we remove that line and keep the DROP TABLE below so the v4 upgrade runs without errors?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hello @flyingImer ,

Those were copied from https://github.com/adutra/polaris/blob/0668f5d5279e1cb367e16cc9991966d01352666b/site/content/in-dev/unreleased/metastores/relational-jdbc.md#migration-from-schema-v4-to-v5 (on-going PR from @adutra).

I hasn't try this on my setup but I can test it later this week. We should not merge this PR until the on-going one from @adutra is resolved. This is primary to match to what @adutra has in the on-going PR.

Thanks,
Yong Zheng

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.

4 participants