Skip to content

[#10770] feat(cache): Add 1.3.0 relational schema#10912

Open
yuqi1129 wants to merge 5 commits intoapache:mainfrom
yuqi1129:feat/cache-db-schema-1.3
Open

[#10770] feat(cache): Add 1.3.0 relational schema#10912
yuqi1129 wants to merge 5 commits intoapache:mainfrom
yuqi1129:feat/cache-db-schema-1.3

Conversation

@yuqi1129
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Add the 1.3.0 relational schema and upgrade scripts for H2, MySQL, and PostgreSQL, and bump the current script version to 1.3.0.

Why are the changes needed?

This is the database schema foundation for the cache improvement work. It only includes SQL and version changes.

Fix: #

Does this PR introduce any user-facing change?

No user-facing API change. This updates backend relational storage schema scripts.

How was this patch tested?

Ran targeted relational tests in the stacked branches after rebasing on this schema branch.

Comment thread scripts/h2/schema-1.3.0-h2.sql Outdated
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`metalake_name` VARCHAR(128) NOT NULL,
`entity_type` VARCHAR(32) NOT NULL,
`full_name` VARCHAR(512) NOT NULL,
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.

Why do u use full name here?

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.

Do you have a good suggestion here? I need to recode the name of an entity( in fact, full name).

Copy link
Copy Markdown
Contributor

@roryqi roryqi Apr 30, 2026

Choose a reason for hiding this comment

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

Should we use entity id here? Name will change.

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.

This is the change log, and it's okay to store the name. Using ID will make us query the database to get the names, so I'm relunctant to use ID here.

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.

Name will involve the order issues. If two tables rename the same table, what will it happen?

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.

The table will record the old name and invalid the cache related to it

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.

Just feel that id will be better than name. Name relies on the correct order. It's ok for us now at least.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds the 1.3.0 relational storage schema/upgrade steps across PostgreSQL, MySQL, and H2 to support upcoming cache consistency improvements (via updated_at tracking and an entity change log table).

Changes:

  • Add updated_at columns to user_meta, role_meta, group_meta, and owner_meta.
  • Add entity_change_log table (plus created_at index).
  • Add additional covering indexes in upgrade scripts to support updated_at-based polling/lookups.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
scripts/postgresql/upgrade-1.2.0-to-1.3.0-postgresql.sql Adds updated_at columns, new indexes, and entity_change_log for PostgreSQL upgrades.
scripts/postgresql/schema-1.3.0-postgresql.sql Updates PostgreSQL baseline schema with updated_at columns and entity_change_log.
scripts/mysql/upgrade-1.2.0-to-1.3.0-mysql.sql Adds updated_at columns (with detailed comments), new covering indexes, and entity_change_log for MySQL upgrades.
scripts/mysql/schema-1.3.0-mysql.sql Updates MySQL baseline schema with updated_at columns and entity_change_log.
scripts/h2/upgrade-1.2.0-to-1.3.0-h2.sql Adds updated_at columns, new indexes, and entity_change_log for H2 upgrades.
scripts/h2/schema-1.3.0-h2.sql Updates H2 baseline schema with updated_at columns and entity_change_log.

Comment thread scripts/postgresql/upgrade-1.2.0-to-1.3.0-postgresql.sql Outdated
Comment thread scripts/postgresql/schema-1.3.0-postgresql.sql
Comment thread scripts/postgresql/schema-1.3.0-postgresql.sql
Comment thread scripts/postgresql/schema-1.3.0-postgresql.sql
Comment thread scripts/postgresql/upgrade-1.2.0-to-1.3.0-postgresql.sql Outdated
Comment thread scripts/mysql/schema-1.3.0-mysql.sql
Comment thread scripts/mysql/schema-1.3.0-mysql.sql
Comment thread scripts/h2/schema-1.3.0-h2.sql
Comment thread scripts/postgresql/schema-1.3.0-postgresql.sql
Comment thread scripts/postgresql/schema-1.3.0-postgresql.sql
@yuqi1129 yuqi1129 force-pushed the feat/cache-db-schema-1.3 branch 2 times, most recently from bee9ef1 to 9a272fa Compare April 30, 2026 09:01
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 30, 2026

Code Coverage Report

Overall Project 65.59% 🟢
Files changed No Java source files changed -

Module Coverage
aliyun 1.73% 🔴
api 47.13% 🟢
authorization-common 85.96% 🟢
aws 1.1% 🔴
azure 2.6% 🔴
catalog-common 10.2% 🔴
catalog-fileset 80.02% 🟢
catalog-glue 82.47% 🟢
catalog-hive 81.83% 🟢
catalog-jdbc-clickhouse 79.06% 🟢
catalog-jdbc-common 43.93% 🟢
catalog-jdbc-doris 80.28% 🟢
catalog-jdbc-hologres 54.03% 🟢
catalog-jdbc-mysql 79.23% 🟢
catalog-jdbc-oceanbase 78.38% 🟢
catalog-jdbc-postgresql 82.05% 🟢
catalog-jdbc-starrocks 78.27% 🟢
catalog-kafka 77.01% 🟢
catalog-lakehouse-generic 45.07% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 86.98% 🟢
catalog-lakehouse-paimon 77.71% 🟢
catalog-model 77.72% 🟢
cli 44.51% 🟢
client-java 77.63% 🟢
common 48.75% 🟢
core 81.6% 🟢
filesystem-hadoop3 76.97% 🟢
flink 40.55% 🟢
flink-runtime 0.0% 🔴
gcp 14.2% 🔴
hadoop-common 10.39% 🔴
hive-metastore-common 46.83% 🟢
iceberg-common 55.24% 🟢
iceberg-rest-server 68.05% 🟢
integration-test-common 0.0% 🔴
jobs 66.17% 🟢
lance-common 23.88% 🔴
lance-rest-server 57.84% 🟢
lineage 53.02% 🟢
optimizer 82.95% 🟢
optimizer-api 21.95% 🔴
server 85.6% 🟢
server-common 70.01% 🟢
spark 32.79% 🔴
spark-common 39.09% 🔴
trino-connector 35.14% 🔴

@yuqi1129 yuqi1129 force-pushed the feat/cache-db-schema-1.3 branch 2 times, most recently from c0c1be1 to c9bbd22 Compare April 30, 2026 10:42
@yuqi1129 yuqi1129 force-pushed the feat/cache-db-schema-1.3 branch from c9bbd22 to 7948604 Compare April 30, 2026 11:37
yuqi1129 and others added 2 commits April 30, 2026 20:07
- MySQL upgrade: add ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
  on entity_change_log so upgraded installs match fresh-install storage engine.
- MySQL upgrade and schema: add 'auto increment id' column COMMENT and
  'metalake name' column COMMENT for parity with H2.
- MySQL upgrade: align table COMMENT with schema-1.3.0.
- H2 / PostgreSQL upgrade: fix license header typos in NOTICE line.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Index leads with PK column role_id, so it provides no faster access
than the clustered index for the only consumer (batchGetRoleUpdatedAt:
WHERE role_id IN (...) AND deleted_at = 0). It also lacks role_name,
forcing a bookmark lookup back to the clustered index. The PK already
serves this query optimally.
@yuqi1129 yuqi1129 changed the title feat(cache): Add 1.3.0 relational schema [#10770] feat(cache): Add 1.3.0 relational schema Apr 30, 2026
yuqi1129 added 2 commits May 1, 2026 09:52
PG schema-1.3.0 carried short generic comments while MySQL/H2 schema
and the PG upgrade script carried the descriptive ones. Sync PG schema
to use the same comments as the rest, and fix a leftover double-space
typo on the license header.
@yuqi1129 yuqi1129 requested review from diqiu50 and roryqi May 6, 2026 06:11
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