World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#15302] feat(storage): Add ontology tables (#15304)
mchadesa23b03b51b7f
diff --git a/scripts/h2/schema-2.0.0-h2.sql b/scripts/h2/schema-2.0.0-h2.sqlindex 65e385d9cd..48b0181b21 100644--- a/scripts/h2/schema-2.0.0-h2.sql+++ b/scripts/h2/schema-2.0.0-h2.sql@@ -873,3 +873,32 @@ CREATE TABLE IF NOT EXISTS iceberg_idempotency_generation_meta (stripe INT NOT NULL PRIMARY KEY,generation BIGINT NOT NULL) ENGINE=InnoDB;++CREATE TABLE IF NOT EXISTS `ontology_meta` (+ `ontology_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'ontology id',+ `ontology_name` VARCHAR(128) NOT NULL COMMENT 'ontology name',+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',+ `audit_info` MEDIUMTEXT NOT NULL COMMENT 'ontology 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 'ontology deleted at',+ PRIMARY KEY (`ontology_id`),+ UNIQUE KEY `uk_onm_mid_name_del` (`metalake_id`, `ontology_name`, `deleted_at`),+ KEY `idx_onm_deleted` (`deleted_at`)+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'ontology identity';++CREATE TABLE IF NOT EXISTS `ontology_version_info` (+ `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',+ `ontology_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'ontology id',+ `version` INT UNSIGNED NOT NULL COMMENT 'version',+ `ontology_comment` TEXT DEFAULT NULL COMMENT 'comment snapshot',+ `definition` MEDIUMTEXT NOT NULL COMMENT 'normalized OntologyDefinition (JSON)',+ `properties` MEDIUMTEXT DEFAULT NULL COMMENT 'properties snapshot (JSON)',+ `audit_info` MEDIUMTEXT NOT NULL COMMENT 'version audit info',+ `deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'version deleted at',+ PRIMARY KEY (`id`),+ UNIQUE KEY `uk_onvi_oid_ver_del` (`ontology_id`, `version`, `deleted_at`),+ KEY `idx_onvi_mid` (`metalake_id`, `deleted_at`),+ KEY `idx_onvi_deleted` (`deleted_at`)+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'ontology versions';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.sqlindex 30d84691d0..0e5750c940 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@@ -472,3 +472,32 @@ CREATE INDEX IF NOT EXISTS `idx_tag_relation_meta_live` ON `tag_relation_meta` (CREATE INDEX IF NOT EXISTS `idx_role_meta_securable_object_live` ON `role_meta_securable_object` (`metadata_object_id`, `type`, `deleted_at`);CREATE INDEX IF NOT EXISTS `idx_user_role_rel_live` ON `user_role_rel` (`role_id`, `deleted_at`);CREATE INDEX IF NOT EXISTS `idx_policy_tag_relation_meta_live` ON `policy_tag_relation_meta` (`tag_id`, `deleted_at`);++CREATE TABLE IF NOT EXISTS `ontology_meta` (+ `ontology_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'ontology id',+ `ontology_name` VARCHAR(128) NOT NULL COMMENT 'ontology name',+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',+ `audit_info` MEDIUMTEXT NOT NULL COMMENT 'ontology 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 'ontology deleted at',+ PRIMARY KEY (`ontology_id`),+ UNIQUE KEY `uk_onm_mid_name_del` (`metalake_id`, `ontology_name`, `deleted_at`),+ KEY `idx_onm_deleted` (`deleted_at`)+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'ontology identity';++CREATE TABLE IF NOT EXISTS `ontology_version_info` (+ `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',+ `ontology_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'ontology id',+ `version` INT UNSIGNED NOT NULL COMMENT 'version',+ `ontology_comment` TEXT DEFAULT NULL COMMENT 'comment snapshot',+ `definition` MEDIUMTEXT NOT NULL COMMENT 'normalized OntologyDefinition (JSON)',+ `properties` MEDIUMTEXT DEFAULT NULL COMMENT 'properties snapshot (JSON)',+ `audit_info` MEDIUMTEXT NOT NULL COMMENT 'version audit info',+ `deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'version deleted at',+ PRIMARY KEY (`id`),+ UNIQUE KEY `uk_onvi_oid_ver_del` (`ontology_id`, `version`, `deleted_at`),+ KEY `idx_onvi_mid` (`metalake_id`, `deleted_at`),+ KEY `idx_onvi_deleted` (`deleted_at`)+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'ontology versions';diff --git a/scripts/mysql/schema-2.0.0-mysql.sql b/scripts/mysql/schema-2.0.0-mysql.sqlindex 2f5f2e93a2..2976e62e9e 100644--- a/scripts/mysql/schema-2.0.0-mysql.sql+++ b/scripts/mysql/schema-2.0.0-mysql.sql@@ -861,3 +861,32 @@ CREATE TABLE IF NOT EXISTS iceberg_idempotency_generation_meta (stripe INT NOT NULL PRIMARY KEY,generation BIGINT NOT NULL) ENGINE=InnoDB;++CREATE TABLE IF NOT EXISTS `ontology_meta` (+ `ontology_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'ontology id',+ `ontology_name` VARCHAR(128) NOT NULL COMMENT 'ontology name',+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',+ `audit_info` MEDIUMTEXT NOT NULL COMMENT 'ontology 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 'ontology deleted at',+ PRIMARY KEY (`ontology_id`),+ UNIQUE KEY `uk_onm_mid_name_del` (`metalake_id`, `ontology_name`, `deleted_at`),+ KEY `idx_onm_deleted` (`deleted_at`)+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'ontology identity';++CREATE TABLE IF NOT EXISTS `ontology_version_info` (+ `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',+ `ontology_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'ontology id',+ `version` INT UNSIGNED NOT NULL COMMENT 'version',+ `ontology_comment` TEXT DEFAULT NULL COMMENT 'comment snapshot',+ `definition` MEDIUMTEXT NOT NULL COMMENT 'normalized OntologyDefinition (JSON)',+ `properties` MEDIUMTEXT DEFAULT NULL COMMENT 'properties snapshot (JSON)',+ `audit_info` MEDIUMTEXT NOT NULL COMMENT 'version audit info',+ `deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'version deleted at',+ PRIMARY KEY (`id`),+ UNIQUE KEY `uk_onvi_oid_ver_del` (`ontology_id`, `version`, `deleted_at`),+ KEY `idx_onvi_mid` (`metalake_id`, `deleted_at`),+ KEY `idx_onvi_deleted` (`deleted_at`)+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'ontology versions';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.sqlindex 1cedda7f78..92e2ed4479 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@@ -1025,3 +1025,32 @@ SET @ddl = IF(EXISTS(SELECT 1 FROM information_schema.statisticsPREPARE stmt FROM @ddl;EXECUTE stmt;DEALLOCATE PREPARE stmt;++CREATE TABLE IF NOT EXISTS `ontology_meta` (+ `ontology_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'ontology id',+ `ontology_name` VARCHAR(128) NOT NULL COMMENT 'ontology name',+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',+ `audit_info` MEDIUMTEXT NOT NULL COMMENT 'ontology 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 'ontology deleted at',+ PRIMARY KEY (`ontology_id`),+ UNIQUE KEY `uk_onm_mid_name_del` (`metalake_id`, `ontology_name`, `deleted_at`),+ KEY `idx_onm_deleted` (`deleted_at`)+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'ontology identity';++CREATE TABLE IF NOT EXISTS `ontology_version_info` (+ `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',+ `metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',+ `ontology_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'ontology id',+ `version` INT UNSIGNED NOT NULL COMMENT 'version',+ `ontology_comment` TEXT DEFAULT NULL COMMENT 'comment snapshot',+ `definition` MEDIUMTEXT NOT NULL COMMENT 'normalized OntologyDefinition (JSON)',+ `properties` MEDIUMTEXT DEFAULT NULL COMMENT 'properties snapshot (JSON)',+ `audit_info` MEDIUMTEXT NOT NULL COMMENT 'version audit info',+ `deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'version deleted at',+ PRIMARY KEY (`id`),+ UNIQUE KEY `uk_onvi_oid_ver_del` (`ontology_id`, `version`, `deleted_at`),+ KEY `idx_onvi_mid` (`metalake_id`, `deleted_at`),+ KEY `idx_onvi_deleted` (`deleted_at`)+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'ontology versions';diff --git a/scripts/postgresql/schema-2.0.0-postgresql.sql b/scripts/postgresql/schema-2.0.0-postgresql.sqlindex 93b3bfdf6d..3d9ef78a7c 100644--- a/scripts/postgresql/schema-2.0.0-postgresql.sql+++ b/scripts/postgresql/schema-2.0.0-postgresql.sql@@ -1482,3 +1482,53 @@ CREATE TABLE IF NOT EXISTS iceberg_idempotency_generation_meta (stripe INT NOT NULL PRIMARY KEY,generation BIGINT NOT NULL);++CREATE TABLE IF NOT EXISTS ontology_meta (+ ontology_id BIGINT NOT NULL,+ ontology_name VARCHAR(128) NOT NULL,+ metalake_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 (ontology_id),+ CONSTRAINT uk_onm_mid_name_del UNIQUE (metalake_id, ontology_name, deleted_at)+);++CREATE INDEX IF NOT EXISTS idx_onm_deleted ON ontology_meta (deleted_at);+COMMENT ON TABLE ontology_meta IS 'ontology identity';+COMMENT ON COLUMN ontology_meta.ontology_id IS 'ontology id';+COMMENT ON COLUMN ontology_meta.ontology_name IS 'ontology name';+COMMENT ON COLUMN ontology_meta.metalake_id IS 'metalake id';+COMMENT ON COLUMN ontology_meta.audit_info IS 'ontology identity audit info';+COMMENT ON COLUMN ontology_meta.current_version IS 'current version';+COMMENT ON COLUMN ontology_meta.last_version IS 'last allocated version';+COMMENT ON COLUMN ontology_meta.deleted_at IS 'ontology deleted at';++CREATE TABLE IF NOT EXISTS ontology_version_info (+ id BIGSERIAL,+ metalake_id BIGINT NOT NULL,+ ontology_id BIGINT NOT NULL,+ version INT NOT NULL,+ ontology_comment TEXT DEFAULT NULL,+ definition TEXT NOT NULL,+ properties TEXT DEFAULT NULL,+ audit_info TEXT NOT NULL,+ deleted_at BIGINT NOT NULL DEFAULT 0,+ PRIMARY KEY (id),+ CONSTRAINT uk_onvi_oid_ver_del UNIQUE (ontology_id, version, deleted_at)+);++CREATE INDEX IF NOT EXISTS idx_onvi_mid ON ontology_version_info (metalake_id) WHERE deleted_at = 0;++CREATE INDEX IF NOT EXISTS idx_onvi_deleted ON ontology_version_info (deleted_at);+COMMENT ON TABLE ontology_version_info IS 'ontology versions';+COMMENT ON COLUMN ontology_version_info.id IS 'auto increment id';+COMMENT ON COLUMN ontology_version_info.metalake_id IS 'metalake id';+COMMENT ON COLUMN ontology_version_info.ontology_id IS 'ontology id';+COMMENT ON COLUMN ontology_version_info.version IS 'version';+COMMENT ON COLUMN ontology_version_info.ontology_comment IS 'comment snapshot';+COMMENT ON COLUMN ontology_version_info.definition IS 'normalized OntologyDefinition (JSON)';+COMMENT ON COLUMN ontology_version_info.properties IS 'properties snapshot (JSON)';+COMMENT ON COLUMN ontology_version_info.audit_info IS 'version audit info';+COMMENT ON COLUMN ontology_version_info.deleted_at IS 'version deleted at';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.sqlindex 66587f9d18..af34666550 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@@ -623,3 +623,53 @@ CREATE INDEX IF NOT EXISTS idx_tag_relation_meta_live ON tag_relation_meta (metaCREATE INDEX IF NOT EXISTS idx_role_meta_securable_object_live ON role_meta_securable_object (metadata_object_id, type) WHERE deleted_at = 0;CREATE INDEX IF NOT EXISTS idx_user_role_rel_live ON user_role_rel (role_id) WHERE deleted_at = 0;CREATE INDEX IF NOT EXISTS idx_policy_tag_relation_meta_live ON policy_tag_relation_meta (tag_id) WHERE deleted_at = 0;++CREATE TABLE IF NOT EXISTS ontology_meta (+ ontology_id BIGINT NOT NULL,+ ontology_name VARCHAR(128) NOT NULL,+ metalake_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 (ontology_id),+ CONSTRAINT uk_onm_mid_name_del UNIQUE (metalake_id, ontology_name, deleted_at)+);++CREATE INDEX IF NOT EXISTS idx_onm_deleted ON ontology_meta (deleted_at);+COMMENT ON TABLE ontology_meta IS 'ontology identity';+COMMENT ON COLUMN ontology_meta.ontology_id IS 'ontology id';+COMMENT ON COLUMN ontology_meta.ontology_name IS 'ontology name';+COMMENT ON COLUMN ontology_meta.metalake_id IS 'metalake id';+COMMENT ON COLUMN ontology_meta.audit_info IS 'ontology identity audit info';+COMMENT ON COLUMN ontology_meta.current_version IS 'current version';+COMMENT ON COLUMN ontology_meta.last_version IS 'last allocated version';+COMMENT ON COLUMN ontology_meta.deleted_at IS 'ontology deleted at';++CREATE TABLE IF NOT EXISTS ontology_version_info (+ id BIGSERIAL,+ metalake_id BIGINT NOT NULL,+ ontology_id BIGINT NOT NULL,+ version INT NOT NULL,+ ontology_comment TEXT DEFAULT NULL,+ definition TEXT NOT NULL,+ properties TEXT DEFAULT NULL,+ audit_info TEXT NOT NULL,+ deleted_at BIGINT NOT NULL DEFAULT 0,+ PRIMARY KEY (id),+ CONSTRAINT uk_onvi_oid_ver_del UNIQUE (ontology_id, version, deleted_at)+);++CREATE INDEX IF NOT EXISTS idx_onvi_mid ON ontology_version_info (metalake_id) WHERE deleted_at = 0;++CREATE INDEX IF NOT EXISTS idx_onvi_deleted ON ontology_version_info (deleted_at);+COMMENT ON TABLE ontology_version_info IS 'ontology versions';+COMMENT ON COLUMN ontology_version_info.id IS 'auto increment id';+COMMENT ON COLUMN ontology_version_info.metalake_id IS 'metalake id';+COMMENT ON COLUMN ontology_version_info.ontology_id IS 'ontology id';+COMMENT ON COLUMN ontology_version_info.version IS 'version';+COMMENT ON COLUMN ontology_version_info.ontology_comment IS 'comment snapshot';+COMMENT ON COLUMN ontology_version_info.definition IS 'normalized OntologyDefinition (JSON)';+COMMENT ON COLUMN ontology_version_info.properties IS 'properties snapshot (JSON)';+COMMENT ON COLUMN ontology_version_info.audit_info IS 'version audit info';+COMMENT ON COLUMN ontology_version_info.deleted_at IS 'version deleted at';