This is an automated email from the ASF dual-hosted git repository.
jerryshao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 391da6f9c8 [#12539] feat(store): Add Semantic Model relational schema
(#12540)
391da6f9c8 is described below
commit 391da6f9c8abcfacf6ee440d2a2098c8c238d3ae
Author: mchades <[email protected]>
AuthorDate: Tue Aug 25 15:26:19 2026 +0800
[#12539] feat(store): Add Semantic Model relational schema (#12540)
### What changes were proposed in this pull request?
Add `semantic_model_meta` and `semantic_model_version_info` to the H2,
MySQL, and PostgreSQL relational schemas, covering both fresh 2.0.0
installations and 1.3.0-to-2.0.0 upgrades.
### Why are the changes needed?
These tables provide the persistence foundation for Semantic Model
identity and version metadata defined by #12210.
Fix: #12539
### Does this PR introduce _any_ user-facing change?
No. This PR adds internal relational database schema definitions only.
### How was this patch tested?
- `git diff --check origin/main...HEAD`
- `dockerTest=true GRAVITINO_HOME="$PWD" ./gradlew :core:test --tests
org.apache.gravitino.storage.TestSQLScripts -PskipITs
-PskipDockerTests=false --rerun-tasks`
---
scripts/h2/schema-2.0.0-h2.sql | 36 +++++++++++++
scripts/h2/upgrade-1.3.0-to-2.0.0-h2.sql | 36 +++++++++++++
scripts/mysql/schema-2.0.0-mysql.sql | 36 +++++++++++++
scripts/mysql/upgrade-1.3.0-to-2.0.0-mysql.sql | 36 +++++++++++++
scripts/postgresql/schema-2.0.0-postgresql.sql | 63 ++++++++++++++++++++++
.../upgrade-1.3.0-to-2.0.0-postgresql.sql | 63 ++++++++++++++++++++++
6 files changed, 270 insertions(+)
diff --git a/scripts/h2/schema-2.0.0-h2.sql b/scripts/h2/schema-2.0.0-h2.sql
index 214d6f3af8..ff8aaa3d50 100644
--- a/scripts/h2/schema-2.0.0-h2.sql
+++ b/scripts/h2/schema-2.0.0-h2.sql
@@ -569,6 +569,42 @@ CREATE TABLE IF NOT EXISTS `view_version_info` (
KEY `idx_vvsid` (`schema_id`)
) ENGINE=InnoDB;
+CREATE TABLE IF NOT EXISTS `semantic_model_meta` (
+ `semantic_model_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'semantic model
id',
+ `semantic_model_name` VARCHAR(128) NOT NULL COMMENT 'semantic model name',
+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
+ `catalog_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'catalog id',
+ `schema_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'schema id',
+ `audit_info` CLOB NOT NULL COMMENT 'semantic model identity audit info',
+ `current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'current
version',
+ `last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'last allocated
version',
+ `deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'semantic
model deleted at',
+ PRIMARY KEY (`semantic_model_id`),
+ UNIQUE KEY `uk_sid_smn_del` (`schema_id`, `semantic_model_name`,
`deleted_at`),
+ KEY `idx_smm_mid` (`metalake_id`),
+ KEY `idx_smm_cid` (`catalog_id`)
+) ENGINE=InnoDB COMMENT 'semantic model metadata';
+
+CREATE TABLE IF NOT EXISTS `semantic_model_version_info` (
+ `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment
id',
+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
+ `catalog_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'catalog id',
+ `schema_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'schema id',
+ `semantic_model_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'semantic model
id',
+ `version` INT UNSIGNED NOT NULL COMMENT 'semantic model version',
+ `semantic_model_name` VARCHAR(128) NOT NULL COMMENT 'semantic model name
snapshot',
+ `semantic_model_comment` CLOB DEFAULT NULL COMMENT 'semantic model comment
snapshot',
+ `semantic_model_definition` CLOB NOT NULL COMMENT 'structured definition
snapshot (JSON)',
+ `properties` CLOB DEFAULT NULL COMMENT 'semantic model properties snapshot
(JSON)',
+ `audit_info` CLOB NOT NULL COMMENT 'semantic model version audit info',
+ `deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'version
deleted at',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `uk_smid_ver_del` (`semantic_model_id`, `version`,
`deleted_at`),
+ KEY `idx_smvi_mid` (`metalake_id`),
+ KEY `idx_smvi_cid` (`catalog_id`),
+ KEY `idx_smvi_sid` (`schema_id`)
+) ENGINE=InnoDB COMMENT 'semantic model version information';
+
-- This schema extends version 1.1.0 with partition statistics storage support
-- The partition_statistic_meta table stores partition-level statistics for
tables
diff --git a/scripts/h2/upgrade-1.3.0-to-2.0.0-h2.sql
b/scripts/h2/upgrade-1.3.0-to-2.0.0-h2.sql
index e9b03c2996..677341c49c 100644
--- a/scripts/h2/upgrade-1.3.0-to-2.0.0-h2.sql
+++ b/scripts/h2/upgrade-1.3.0-to-2.0.0-h2.sql
@@ -40,3 +40,39 @@ CREATE UNIQUE INDEX IF NOT EXISTS `uk_ti_mi_mo_tv_del` ON
`tag_relation_meta` (`
CREATE INDEX IF NOT EXISTS `idx_tid_value` ON `tag_relation_meta` (`tag_id`,
`tag_value`);
ALTER TABLE `job_run_meta` ADD COLUMN `job_started_at` BIGINT(20) UNSIGNED NOT
NULL DEFAULT 0 COMMENT 'job started at' AFTER `job_run_status`;
+
+CREATE TABLE IF NOT EXISTS `semantic_model_meta` (
+ `semantic_model_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'semantic model
id',
+ `semantic_model_name` VARCHAR(128) NOT NULL COMMENT 'semantic model name',
+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
+ `catalog_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'catalog id',
+ `schema_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'schema id',
+ `audit_info` CLOB NOT NULL COMMENT 'semantic model identity audit info',
+ `current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'current
version',
+ `last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'last allocated
version',
+ `deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'semantic
model deleted at',
+ PRIMARY KEY (`semantic_model_id`),
+ UNIQUE KEY `uk_sid_smn_del` (`schema_id`, `semantic_model_name`,
`deleted_at`),
+ KEY `idx_smm_mid` (`metalake_id`),
+ KEY `idx_smm_cid` (`catalog_id`)
+) ENGINE=InnoDB COMMENT 'semantic model metadata';
+
+CREATE TABLE IF NOT EXISTS `semantic_model_version_info` (
+ `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment
id',
+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
+ `catalog_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'catalog id',
+ `schema_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'schema id',
+ `semantic_model_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'semantic model
id',
+ `version` INT UNSIGNED NOT NULL COMMENT 'semantic model version',
+ `semantic_model_name` VARCHAR(128) NOT NULL COMMENT 'semantic model name
snapshot',
+ `semantic_model_comment` CLOB DEFAULT NULL COMMENT 'semantic model comment
snapshot',
+ `semantic_model_definition` CLOB NOT NULL COMMENT 'structured definition
snapshot (JSON)',
+ `properties` CLOB DEFAULT NULL COMMENT 'semantic model properties snapshot
(JSON)',
+ `audit_info` CLOB NOT NULL COMMENT 'semantic model version audit info',
+ `deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'version
deleted at',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `uk_smid_ver_del` (`semantic_model_id`, `version`,
`deleted_at`),
+ KEY `idx_smvi_mid` (`metalake_id`),
+ KEY `idx_smvi_cid` (`catalog_id`),
+ KEY `idx_smvi_sid` (`schema_id`)
+) ENGINE=InnoDB COMMENT 'semantic model version information';
diff --git a/scripts/mysql/schema-2.0.0-mysql.sql
b/scripts/mysql/schema-2.0.0-mysql.sql
index c591af5e34..7f0c35a060 100644
--- a/scripts/mysql/schema-2.0.0-mysql.sql
+++ b/scripts/mysql/schema-2.0.0-mysql.sql
@@ -560,6 +560,42 @@ CREATE TABLE IF NOT EXISTS `view_version_info` (
KEY `idx_vvsid` (`schema_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'view
version info';
+CREATE TABLE IF NOT EXISTS `semantic_model_meta` (
+ `semantic_model_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'semantic model
id',
+ `semantic_model_name` VARCHAR(128) NOT NULL COMMENT 'semantic model name',
+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
+ `catalog_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'catalog id',
+ `schema_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'schema id',
+ `audit_info` MEDIUMTEXT NOT NULL COMMENT 'semantic model identity audit
info',
+ `current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'current
version',
+ `last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'last allocated
version',
+ `deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'semantic
model deleted at',
+ PRIMARY KEY (`semantic_model_id`),
+ UNIQUE KEY `uk_sid_smn_del` (`schema_id`, `semantic_model_name`,
`deleted_at`),
+ KEY `idx_smm_mid` (`metalake_id`),
+ KEY `idx_smm_cid` (`catalog_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'semantic
model metadata';
+
+CREATE TABLE IF NOT EXISTS `semantic_model_version_info` (
+ `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment
id',
+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
+ `catalog_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'catalog id',
+ `schema_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'schema id',
+ `semantic_model_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'semantic model
id',
+ `version` INT UNSIGNED NOT NULL COMMENT 'semantic model version',
+ `semantic_model_name` VARCHAR(128) NOT NULL COMMENT 'semantic model name
snapshot',
+ `semantic_model_comment` TEXT DEFAULT NULL COMMENT 'semantic model comment
snapshot',
+ `semantic_model_definition` MEDIUMTEXT NOT NULL COMMENT 'structured
definition snapshot (JSON)',
+ `properties` MEDIUMTEXT DEFAULT NULL COMMENT 'semantic model properties
snapshot (JSON)',
+ `audit_info` MEDIUMTEXT NOT NULL COMMENT 'semantic model version audit
info',
+ `deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'version
deleted at',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `uk_smid_ver_del` (`semantic_model_id`, `version`,
`deleted_at`),
+ KEY `idx_smvi_mid` (`metalake_id`),
+ KEY `idx_smvi_cid` (`catalog_id`),
+ KEY `idx_smvi_sid` (`schema_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'semantic
model version information';
+
-- This schema extends version 1.1.0 with partition statistics storage support
-- The partition_statistic_meta table stores partition-level statistics for
tables
diff --git a/scripts/mysql/upgrade-1.3.0-to-2.0.0-mysql.sql
b/scripts/mysql/upgrade-1.3.0-to-2.0.0-mysql.sql
index 71b17ed5de..654f6bb45a 100644
--- a/scripts/mysql/upgrade-1.3.0-to-2.0.0-mysql.sql
+++ b/scripts/mysql/upgrade-1.3.0-to-2.0.0-mysql.sql
@@ -99,3 +99,39 @@ ALTER TABLE `table_version_info`
ALTER TABLE `job_run_meta`
ADD COLUMN `job_started_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT
'job started at' AFTER `job_run_status`;
+
+CREATE TABLE IF NOT EXISTS `semantic_model_meta` (
+ `semantic_model_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'semantic model
id',
+ `semantic_model_name` VARCHAR(128) NOT NULL COMMENT 'semantic model name',
+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
+ `catalog_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'catalog id',
+ `schema_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'schema id',
+ `audit_info` MEDIUMTEXT NOT NULL COMMENT 'semantic model identity audit
info',
+ `current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'current
version',
+ `last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'last allocated
version',
+ `deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'semantic
model deleted at',
+ PRIMARY KEY (`semantic_model_id`),
+ UNIQUE KEY `uk_sid_smn_del` (`schema_id`, `semantic_model_name`,
`deleted_at`),
+ KEY `idx_smm_mid` (`metalake_id`),
+ KEY `idx_smm_cid` (`catalog_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'semantic
model metadata';
+
+CREATE TABLE IF NOT EXISTS `semantic_model_version_info` (
+ `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment
id',
+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
+ `catalog_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'catalog id',
+ `schema_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'schema id',
+ `semantic_model_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'semantic model
id',
+ `version` INT UNSIGNED NOT NULL COMMENT 'semantic model version',
+ `semantic_model_name` VARCHAR(128) NOT NULL COMMENT 'semantic model name
snapshot',
+ `semantic_model_comment` TEXT DEFAULT NULL COMMENT 'semantic model comment
snapshot',
+ `semantic_model_definition` MEDIUMTEXT NOT NULL COMMENT 'structured
definition snapshot (JSON)',
+ `properties` MEDIUMTEXT DEFAULT NULL COMMENT 'semantic model properties
snapshot (JSON)',
+ `audit_info` MEDIUMTEXT NOT NULL COMMENT 'semantic model version audit
info',
+ `deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'version
deleted at',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `uk_smid_ver_del` (`semantic_model_id`, `version`,
`deleted_at`),
+ KEY `idx_smvi_mid` (`metalake_id`),
+ KEY `idx_smvi_cid` (`catalog_id`),
+ KEY `idx_smvi_sid` (`schema_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'semantic
model version information';
diff --git a/scripts/postgresql/schema-2.0.0-postgresql.sql
b/scripts/postgresql/schema-2.0.0-postgresql.sql
index 0f3b39eeb8..28bbdf77d3 100644
--- a/scripts/postgresql/schema-2.0.0-postgresql.sql
+++ b/scripts/postgresql/schema-2.0.0-postgresql.sql
@@ -990,6 +990,69 @@ COMMENT ON COLUMN view_version_info.representations IS
'view representations (JS
COMMENT ON COLUMN view_version_info.audit_info IS 'view version audit info';
COMMENT ON COLUMN view_version_info.deleted_at IS 'view version deleted at';
+CREATE TABLE IF NOT EXISTS semantic_model_meta (
+ semantic_model_id BIGINT NOT NULL,
+ semantic_model_name VARCHAR(128) NOT NULL,
+ metalake_id BIGINT NOT NULL,
+ catalog_id BIGINT NOT NULL,
+ schema_id BIGINT NOT NULL,
+ audit_info TEXT NOT NULL,
+ current_version INT NOT NULL DEFAULT 1,
+ last_version INT NOT NULL DEFAULT 1,
+ deleted_at BIGINT NOT NULL DEFAULT 0,
+ PRIMARY KEY (semantic_model_id),
+ UNIQUE (schema_id, semantic_model_name, deleted_at)
+);
+
+CREATE INDEX IF NOT EXISTS semantic_model_meta_idx_metalake_id ON
semantic_model_meta (metalake_id);
+CREATE INDEX IF NOT EXISTS semantic_model_meta_idx_catalog_id ON
semantic_model_meta (catalog_id);
+COMMENT ON TABLE semantic_model_meta IS 'semantic model metadata';
+
+COMMENT ON COLUMN semantic_model_meta.semantic_model_id IS 'semantic model id';
+COMMENT ON COLUMN semantic_model_meta.semantic_model_name IS 'semantic model
name';
+COMMENT ON COLUMN semantic_model_meta.metalake_id IS 'metalake id';
+COMMENT ON COLUMN semantic_model_meta.catalog_id IS 'catalog id';
+COMMENT ON COLUMN semantic_model_meta.schema_id IS 'schema id';
+COMMENT ON COLUMN semantic_model_meta.audit_info IS 'semantic model identity
audit info';
+COMMENT ON COLUMN semantic_model_meta.current_version IS 'current version';
+COMMENT ON COLUMN semantic_model_meta.last_version IS 'last allocated version';
+COMMENT ON COLUMN semantic_model_meta.deleted_at IS 'semantic model deleted
at';
+
+CREATE TABLE IF NOT EXISTS semantic_model_version_info (
+ id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ metalake_id BIGINT NOT NULL,
+ catalog_id BIGINT NOT NULL,
+ schema_id BIGINT NOT NULL,
+ semantic_model_id BIGINT NOT NULL,
+ version INT NOT NULL,
+ semantic_model_name VARCHAR(128) NOT NULL,
+ semantic_model_comment TEXT DEFAULT NULL,
+ semantic_model_definition TEXT NOT NULL,
+ properties TEXT DEFAULT NULL,
+ audit_info TEXT NOT NULL,
+ deleted_at BIGINT NOT NULL DEFAULT 0,
+ PRIMARY KEY (id),
+ UNIQUE (semantic_model_id, version, deleted_at)
+);
+
+CREATE INDEX IF NOT EXISTS semantic_model_version_info_idx_metalake_id ON
semantic_model_version_info (metalake_id);
+CREATE INDEX IF NOT EXISTS semantic_model_version_info_idx_catalog_id ON
semantic_model_version_info (catalog_id);
+CREATE INDEX IF NOT EXISTS semantic_model_version_info_idx_schema_id ON
semantic_model_version_info (schema_id);
+COMMENT ON TABLE semantic_model_version_info IS 'semantic model version
information';
+
+COMMENT ON COLUMN semantic_model_version_info.id IS 'auto increment id';
+COMMENT ON COLUMN semantic_model_version_info.metalake_id IS 'metalake id';
+COMMENT ON COLUMN semantic_model_version_info.catalog_id IS 'catalog id';
+COMMENT ON COLUMN semantic_model_version_info.schema_id IS 'schema id';
+COMMENT ON COLUMN semantic_model_version_info.semantic_model_id IS 'semantic
model id';
+COMMENT ON COLUMN semantic_model_version_info.version IS 'semantic model
version';
+COMMENT ON COLUMN semantic_model_version_info.semantic_model_name IS 'semantic
model name snapshot';
+COMMENT ON COLUMN semantic_model_version_info.semantic_model_comment IS
'semantic model comment snapshot';
+COMMENT ON COLUMN semantic_model_version_info.semantic_model_definition IS
'structured definition snapshot (JSON)';
+COMMENT ON COLUMN semantic_model_version_info.properties IS 'semantic model
properties snapshot (JSON)';
+COMMENT ON COLUMN semantic_model_version_info.audit_info IS 'semantic model
version audit info';
+COMMENT ON COLUMN semantic_model_version_info.deleted_at IS 'version deleted
at';
+
-- This schema extends version 1.1.0 with partition statistics storage support
-- The partition_statistic_meta table stores partition-level statistics for
tables
diff --git a/scripts/postgresql/upgrade-1.3.0-to-2.0.0-postgresql.sql
b/scripts/postgresql/upgrade-1.3.0-to-2.0.0-postgresql.sql
index 90ce5bc69a..59b4c9e7ae 100644
--- a/scripts/postgresql/upgrade-1.3.0-to-2.0.0-postgresql.sql
+++ b/scripts/postgresql/upgrade-1.3.0-to-2.0.0-postgresql.sql
@@ -48,3 +48,66 @@ CREATE INDEX IF NOT EXISTS
tag_relation_meta_idx_tag_id_value ON tag_relation_me
ALTER TABLE job_run_meta ADD COLUMN IF NOT EXISTS job_started_at BIGINT NOT
NULL DEFAULT 0;
COMMENT ON COLUMN job_run_meta.job_started_at IS 'job run started at';
+
+CREATE TABLE IF NOT EXISTS semantic_model_meta (
+ semantic_model_id BIGINT NOT NULL,
+ semantic_model_name VARCHAR(128) NOT NULL,
+ metalake_id BIGINT NOT NULL,
+ catalog_id BIGINT NOT NULL,
+ schema_id BIGINT NOT NULL,
+ audit_info TEXT NOT NULL,
+ current_version INT NOT NULL DEFAULT 1,
+ last_version INT NOT NULL DEFAULT 1,
+ deleted_at BIGINT NOT NULL DEFAULT 0,
+ PRIMARY KEY (semantic_model_id),
+ UNIQUE (schema_id, semantic_model_name, deleted_at)
+);
+
+CREATE INDEX IF NOT EXISTS semantic_model_meta_idx_metalake_id ON
semantic_model_meta (metalake_id);
+CREATE INDEX IF NOT EXISTS semantic_model_meta_idx_catalog_id ON
semantic_model_meta (catalog_id);
+COMMENT ON TABLE semantic_model_meta IS 'semantic model metadata';
+
+COMMENT ON COLUMN semantic_model_meta.semantic_model_id IS 'semantic model id';
+COMMENT ON COLUMN semantic_model_meta.semantic_model_name IS 'semantic model
name';
+COMMENT ON COLUMN semantic_model_meta.metalake_id IS 'metalake id';
+COMMENT ON COLUMN semantic_model_meta.catalog_id IS 'catalog id';
+COMMENT ON COLUMN semantic_model_meta.schema_id IS 'schema id';
+COMMENT ON COLUMN semantic_model_meta.audit_info IS 'semantic model identity
audit info';
+COMMENT ON COLUMN semantic_model_meta.current_version IS 'current version';
+COMMENT ON COLUMN semantic_model_meta.last_version IS 'last allocated version';
+COMMENT ON COLUMN semantic_model_meta.deleted_at IS 'semantic model deleted
at';
+
+CREATE TABLE IF NOT EXISTS semantic_model_version_info (
+ id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ metalake_id BIGINT NOT NULL,
+ catalog_id BIGINT NOT NULL,
+ schema_id BIGINT NOT NULL,
+ semantic_model_id BIGINT NOT NULL,
+ version INT NOT NULL,
+ semantic_model_name VARCHAR(128) NOT NULL,
+ semantic_model_comment TEXT DEFAULT NULL,
+ semantic_model_definition TEXT NOT NULL,
+ properties TEXT DEFAULT NULL,
+ audit_info TEXT NOT NULL,
+ deleted_at BIGINT NOT NULL DEFAULT 0,
+ PRIMARY KEY (id),
+ UNIQUE (semantic_model_id, version, deleted_at)
+);
+
+CREATE INDEX IF NOT EXISTS semantic_model_version_info_idx_metalake_id ON
semantic_model_version_info (metalake_id);
+CREATE INDEX IF NOT EXISTS semantic_model_version_info_idx_catalog_id ON
semantic_model_version_info (catalog_id);
+CREATE INDEX IF NOT EXISTS semantic_model_version_info_idx_schema_id ON
semantic_model_version_info (schema_id);
+COMMENT ON TABLE semantic_model_version_info IS 'semantic model version
information';
+
+COMMENT ON COLUMN semantic_model_version_info.id IS 'auto increment id';
+COMMENT ON COLUMN semantic_model_version_info.metalake_id IS 'metalake id';
+COMMENT ON COLUMN semantic_model_version_info.catalog_id IS 'catalog id';
+COMMENT ON COLUMN semantic_model_version_info.schema_id IS 'schema id';
+COMMENT ON COLUMN semantic_model_version_info.semantic_model_id IS 'semantic
model id';
+COMMENT ON COLUMN semantic_model_version_info.version IS 'semantic model
version';
+COMMENT ON COLUMN semantic_model_version_info.semantic_model_name IS 'semantic
model name snapshot';
+COMMENT ON COLUMN semantic_model_version_info.semantic_model_comment IS
'semantic model comment snapshot';
+COMMENT ON COLUMN semantic_model_version_info.semantic_model_definition IS
'structured definition snapshot (JSON)';
+COMMENT ON COLUMN semantic_model_version_info.properties IS 'semantic model
properties snapshot (JSON)';
+COMMENT ON COLUMN semantic_model_version_info.audit_info IS 'semantic model
version audit info';
+COMMENT ON COLUMN semantic_model_version_info.deleted_at IS 'version deleted
at';