World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file--
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"). You may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing,
-- software distributed under the License is distributed on an
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-- KIND, either express or implied. See the License for the
-- specific language governing permissions and limitations
-- under the License.
--
CREATE TABLE IF NOT EXISTS `metalake_meta` (
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
`metalake_name` VARCHAR(128) NOT NULL COMMENT 'metalake name',
`metalake_comment` VARCHAR(256) DEFAULT '' COMMENT 'metalake comment',
`properties` MEDIUMTEXT DEFAULT NULL COMMENT 'metalake properties',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'metalake audit info',
`schema_version` MEDIUMTEXT NOT NULL COMMENT 'metalake schema version info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'metalake current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'metalake last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'metalake deleted at',
PRIMARY KEY (`metalake_id`),
UNIQUE KEY `uk_mn_del` (`metalake_name`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'metalake metadata';
CREATE TABLE IF NOT EXISTS `catalog_meta` (
`catalog_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'catalog id',
`catalog_name` VARCHAR(128) NOT NULL COMMENT 'catalog name',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
`type` VARCHAR(64) NOT NULL COMMENT 'catalog type',
`provider` VARCHAR(64) NOT NULL COMMENT 'catalog provider',
`catalog_comment` VARCHAR(256) DEFAULT '' COMMENT 'catalog comment',
`properties` MEDIUMTEXT DEFAULT NULL COMMENT 'catalog properties',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'catalog audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'catalog current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'catalog last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'catalog deleted at',
PRIMARY KEY (`catalog_id`),
UNIQUE KEY `uk_mid_cn_del` (`metalake_id`, `catalog_name`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'catalog metadata';
CREATE TABLE IF NOT EXISTS `schema_meta` (
`schema_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'schema id',
`schema_name` VARCHAR(128) NOT NULL COMMENT 'schema name',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
`catalog_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'catalog id',
`schema_comment` VARCHAR(256) DEFAULT '' COMMENT 'schema comment',
`properties` MEDIUMTEXT DEFAULT NULL COMMENT 'schema properties',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'schema audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'schema current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'schema last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'schema deleted at',
PRIMARY KEY (`schema_id`, `deleted_at`),
UNIQUE KEY `uk_cid_sn_del` (`catalog_id`, `schema_name`, `deleted_at`),
KEY `schema_meta_idx_mid` (`metalake_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'schema metadata';
CREATE TABLE IF NOT EXISTS `table_meta` (
`table_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'table id',
`table_name` VARCHAR(128) NOT NULL COMMENT 'table 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 'table audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'table current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'table last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'table deleted at',
PRIMARY KEY (`table_id`, `deleted_at`),
UNIQUE KEY `table_meta_uk_sid_tn_del` (`schema_id`, `table_name`, `deleted_at`),
KEY `table_meta_idx_mid` (`metalake_id`),
KEY `table_meta_idx_cid` (`catalog_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'table metadata';
CREATE TABLE IF NOT EXISTS `table_column_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',
`table_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'table id',
`table_version` INT UNSIGNED NOT NULL COMMENT 'table version',
`column_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'column id',
`column_name` VARCHAR(300) NOT NULL COMMENT 'column name',
`column_position` INT UNSIGNED NOT NULL COMMENT 'column position, starting from 0',
`column_type` TEXT NOT NULL COMMENT 'column type',
`column_comment` VARCHAR(4096) DEFAULT '' COMMENT 'column comment',
`column_nullable` TINYINT(1) NOT NULL DEFAULT 1 COMMENT 'column nullable, 0 is not nullable, 1 is nullable',
`column_auto_increment` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'column auto increment, 0 is not auto increment, 1 is auto increment',
`column_default_value` TEXT DEFAULT NULL COMMENT 'column default value',
`column_op_type` TINYINT(1) NOT NULL COMMENT 'column operation type, 1 is create, 2 is update, 3 is delete',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'column deleted at',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'column audit info',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_tid_ver_cid_del` (`table_id`, `table_version`, `column_id`, `deleted_at`),
KEY `table_column_version_info_idx_mid` (`metalake_id`),
KEY `table_column_version_info_idx_cid` (`catalog_id`),
KEY `table_column_version_info_idx_sid` (`schema_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'table column version info';
CREATE TABLE IF NOT EXISTS `fileset_meta` (
`fileset_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'fileset id',
`fileset_name` VARCHAR(128) NOT NULL COMMENT 'fileset 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',
`type` VARCHAR(64) NOT NULL COMMENT 'fileset type',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'fileset audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'fileset current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'fileset last version',
`occ_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'fileset optimistic concurrency version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'fileset deleted at',
PRIMARY KEY (`fileset_id`),
UNIQUE KEY `fileset_meta_uk_sid_fn_del` (`schema_id`, `fileset_name`, `deleted_at`),
KEY `fileset_meta_idx_mid` (`metalake_id`),
KEY `fileset_meta_idx_cid` (`catalog_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'fileset metadata';
CREATE TABLE IF NOT EXISTS `fileset_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',
`fileset_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'fileset id',
`version` INT UNSIGNED NOT NULL COMMENT 'fileset info version',
`fileset_comment` VARCHAR(256) DEFAULT '' COMMENT 'fileset comment',
`properties` MEDIUMTEXT DEFAULT NULL COMMENT 'fileset properties',
`storage_location_name` VARCHAR(256) NOT NULL DEFAULT 'default' COMMENT 'fileset storage location name',
`storage_location` MEDIUMTEXT NOT NULL COMMENT 'fileset storage location',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'fileset deleted at',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_fid_ver_sto_del` (`fileset_id`, `version`, `storage_location_name`, `deleted_at`),
KEY `fileset_version_info_idx_mid` (`metalake_id`),
KEY `fileset_version_info_idx_cid` (`catalog_id`),
KEY `fileset_version_info_idx_sid` (`schema_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'fileset version info';
CREATE TABLE IF NOT EXISTS `topic_meta` (
`topic_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'topic id',
`topic_name` VARCHAR(128) NOT NULL COMMENT 'topic 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',
`comment` VARCHAR(256) DEFAULT '' COMMENT 'topic comment',
`properties` MEDIUMTEXT DEFAULT NULL COMMENT 'topic properties',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'topic audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'topic current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'topic last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'topic deleted at',
PRIMARY KEY (`topic_id`, `deleted_at`),
UNIQUE KEY `topic_meta_uk_sid_tn_del` (`schema_id`, `topic_name`, `deleted_at`),
KEY `topic_meta_idx_mid` (`metalake_id`),
KEY `topic_meta_idx_cid` (`catalog_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'topic metadata';
CREATE TABLE IF NOT EXISTS `user_meta` (
`user_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'user id',
`user_name` VARCHAR(128) NOT NULL COMMENT 'username',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'user audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'user current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'user last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'user deleted at',
`updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'updated at',
PRIMARY KEY (`user_id`),
UNIQUE KEY `uk_mid_us_del` (`metalake_id`, `user_name`, `deleted_at`),
KEY `idx_user_meta_name_del_upd` (`metalake_id`, `user_name`, `deleted_at`, `updated_at`),
KEY `idx_user_meta_live` (`metalake_id`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'user metadata';
CREATE TABLE IF NOT EXISTS `role_meta` (
`role_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'role id',
`role_name` VARCHAR(128) NOT NULL COMMENT 'role name',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
`properties` MEDIUMTEXT DEFAULT NULL COMMENT 'schema properties',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'role audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'role current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'role last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'role deleted at',
`updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'updated at',
PRIMARY KEY (`role_id`),
UNIQUE KEY `uk_mid_rn_del` (`metalake_id`, `role_name`, `deleted_at`),
KEY `idx_role_meta_live` (`metalake_id`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'role metadata';
CREATE TABLE IF NOT EXISTS `role_meta_securable_object` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`role_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'role id',
`metadata_object_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'The entity id of securable object',
`type` VARCHAR(128) NOT NULL COMMENT 'securable object type',
`privilege_names` TEXT(81920) NOT NULL COMMENT 'securable object privilege names',
`privilege_conditions` TEXT(81920) NOT NULL COMMENT 'securable object privilege conditions',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'securable object current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'securable object last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'securable object deleted at',
PRIMARY KEY (`id`),
KEY `idx_obj_rid` (`role_id`),
KEY `idx_obj_eid` (`metadata_object_id`),
KEY `idx_role_meta_securable_object_live` (`metadata_object_id`, `type`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'securable object meta';
CREATE TABLE IF NOT EXISTS `user_role_rel` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`user_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'user id',
`role_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'role id',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'relation audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'relation current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'relation last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'relation deleted at',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_ui_ri_del` (`user_id`, `role_id`, `deleted_at`),
KEY `user_role_rel_idx_rid` (`role_id`),
KEY `idx_user_role_rel_live` (`role_id`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'user role relation';
CREATE TABLE IF NOT EXISTS `group_meta` (
`group_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'group id',
`group_name` VARCHAR(128) NOT NULL COMMENT 'group name',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'group audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'group current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'group last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'group deleted at',
`updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'updated at',
PRIMARY KEY (`group_id`),
UNIQUE KEY `uk_mid_gr_del` (`metalake_id`, `group_name`, `deleted_at`),
KEY `idx_group_meta_name_del_upd` (`metalake_id`, `group_name`, `deleted_at`, `updated_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'group metadata';
CREATE TABLE IF NOT EXISTS `group_role_rel` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`group_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'group id',
`role_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'role id',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'relation audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'relation current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'relation last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'relation deleted at',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_gi_ri_del` (`group_id`, `role_id`, `deleted_at`),
KEY `group_role_rel_idx_rid` (`group_id`),
KEY `group_role_rel_idx_role_id` (`role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'group role relation';
CREATE TABLE IF NOT EXISTS `idp_user_meta` (
`user_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'idp user id',
`user_name` VARCHAR(128) NOT NULL COMMENT 'idp username',
`password_hash` VARCHAR(1024) NOT NULL COMMENT 'idp user password hash',
`enabled` TINYINT(1) NOT NULL DEFAULT 1 COMMENT 'whether the user is enabled, 0 is disabled, 1 is enabled',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'idp user audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'idp user current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'idp user last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'idp user deleted at',
PRIMARY KEY (`user_id`),
UNIQUE KEY `uk_iun_del` (`user_name`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'local IdP user metadata';
CREATE TABLE IF NOT EXISTS `idp_group_meta` (
`group_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'idp group id',
`group_name` VARCHAR(128) NOT NULL COMMENT 'idp group name',
`group_comment` VARCHAR(1024) DEFAULT '' COMMENT 'idp group comment',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'idp group audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'idp group current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'idp group last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'idp group deleted at',
PRIMARY KEY (`group_id`),
UNIQUE KEY `uk_ign_del` (`group_name`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'local IdP group metadata';
CREATE TABLE IF NOT EXISTS `idp_user_group_rel` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`user_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'idp user id',
`group_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'idp group id',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'idp user group relation audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'idp relation current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'idp relation last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'idp relation deleted at',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_iuig_del` (`user_id`, `group_id`, `deleted_at`),
KEY `idx_iuig_uid` (`user_id`),
KEY `idx_iuig_gid` (`group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'local IdP user group relation';
CREATE TABLE IF NOT EXISTS `tag_meta` (
`tag_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'tag id',
`tag_name` VARCHAR(128) NOT NULL COMMENT 'tag name',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
`tag_comment` VARCHAR(256) DEFAULT '' COMMENT 'tag comment',
`properties` MEDIUMTEXT DEFAULT NULL COMMENT 'tag properties',
`allowed_values` MEDIUMTEXT DEFAULT NULL COMMENT 'tag allowed values as a JSON string array, NULL allows any value, [] allows no value',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'tag audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'tag current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'tag last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'tag deleted at',
PRIMARY KEY (`tag_id`),
UNIQUE KEY `uk_mi_tn_del` (`metalake_id`, `tag_name`, `deleted_at`),
KEY `idx_tag_meta_live` (`metalake_id`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'tag metadata';
CREATE TABLE IF NOT EXISTS `tag_relation_meta` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`tag_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'tag id',
`metadata_object_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metadata object id',
`metadata_object_type` VARCHAR(64) NOT NULL COMMENT 'metadata object type',
`tag_value` VARCHAR(256) NOT NULL DEFAULT '' COMMENT 'tag assignment value, empty string means no value',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'tag relation audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'tag relation current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'tag relation last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'tag relation deleted at',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_ti_mi_mo_tv_del` (`tag_id`, `metadata_object_id`, `metadata_object_type`, `tag_value`, `deleted_at`),
KEY `idx_tid` (`tag_id`),
KEY `tag_relation_meta_idx_mid` (`metadata_object_id`),
KEY `idx_tid_value` (`tag_id`, `tag_value`),
KEY `idx_tag_relation_meta_live` (`metadata_object_id`, `metadata_object_type`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'tag metadata object relation';
CREATE TABLE IF NOT EXISTS `owner_meta` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
`owner_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'owner id',
`owner_type` VARCHAR(64) NOT NULL COMMENT 'owner type',
`metadata_object_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metadata object id',
`metadata_object_type` VARCHAR(64) NOT NULL COMMENT 'metadata object type',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'owner relation audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'owner relation current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'owner relation last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'owner relation deleted at',
`updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'updated at',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_ow_me_del` (`owner_id`, `metadata_object_id`, `metadata_object_type`, `deleted_at`),
KEY `idx_oid` (`owner_id`),
KEY `idx_meid` (`metadata_object_id`),
KEY `idx_owner_meta_del_upd_obj` (`deleted_at`, `updated_at`, `metadata_object_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'owner relation';
CREATE TABLE IF NOT EXISTS `model_meta` (
`model_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'model id',
`model_name` VARCHAR(128) NOT NULL COMMENT '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',
`model_comment` TEXT DEFAULT NULL COMMENT 'model comment',
`model_properties` MEDIUMTEXT DEFAULT NULL COMMENT 'model properties',
`model_latest_version` INT UNSIGNED DEFAULT 0 COMMENT 'model latest version',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'model current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'model last allocated version',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'model audit info',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'model deleted at',
PRIMARY KEY (`model_id`),
UNIQUE KEY `uk_sid_mn_del` (`schema_id`, `model_name`, `deleted_at`),
KEY `model_meta_idx_mid` (`metalake_id`),
KEY `model_meta_idx_cid` (`catalog_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'model metadata';
CREATE TABLE IF NOT EXISTS `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',
`model_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'model id',
`version` INT UNSIGNED NOT NULL COMMENT 'model version',
`model_version_comment` TEXT DEFAULT NULL COMMENT 'model version comment',
`model_version_properties` MEDIUMTEXT DEFAULT NULL COMMENT 'model version properties',
`model_version_uri_name` VARCHAR(256) NOT NULL COMMENT 'model version uri name',
`model_version_uri` TEXT NOT NULL COMMENT 'model storage uri',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'model version audit info',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'model version deleted at',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_mid_ver_uri_del` (`model_id`, `version`, `model_version_uri_name`, `deleted_at`),
KEY `model_version_info_idx_mid` (`metalake_id`),
KEY `model_version_info_idx_cid` (`catalog_id`),
KEY `model_version_info_idx_sid` (`schema_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'model version info';
CREATE TABLE IF NOT EXISTS `model_version_alias_rel` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`model_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'model id',
`model_version` INT UNSIGNED NOT NULL COMMENT 'model version',
`model_version_alias` VARCHAR(128) NOT NULL COMMENT 'model version alias',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'model version alias deleted at',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_mi_mva_del` (`model_id`, `model_version_alias`, `deleted_at`),
KEY `idx_mva` (`model_version_alias`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'model_version_alias_rel';
CREATE TABLE IF NOT EXISTS `policy_meta` (
`policy_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'policy id',
`policy_name` VARCHAR(128) NOT NULL COMMENT 'policy name',
`policy_type` VARCHAR(64) NOT NULL COMMENT 'policy type',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'policy audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'policy current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'policy last version',
`occ_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'policy optimistic concurrency version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'policy deleted at',
PRIMARY KEY (`policy_id`),
UNIQUE KEY `uk_mi_pn_del` (`metalake_id`, `policy_name`, `deleted_at`),
KEY `idx_policy_meta_live` (`metalake_id`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'policy metadata';
CREATE TABLE IF NOT EXISTS `policy_version_info` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
`policy_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'policy id',
`version` INT UNSIGNED NOT NULL COMMENT 'policy info version',
`policy_comment` TEXT DEFAULT NULL COMMENT 'policy info comment',
`enabled` TINYINT(1) DEFAULT 1 COMMENT 'whether the policy is enabled, 0 is disabled, 1 is enabled',
`content` MEDIUMTEXT DEFAULT NULL COMMENT 'policy content',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'policy deleted at',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_pod_ver_del` (`policy_id`, `version`, `deleted_at`),
KEY `policy_version_info_idx_mid` (`metalake_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'policy version info';
CREATE TABLE IF NOT EXISTS `policy_tag_relation_meta` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`policy_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'policy id',
`tag_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'tag id',
`selector` MEDIUMTEXT DEFAULT NULL COMMENT 'policy tag selector JSON, NULL matches tag presence',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'policy tag relation audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'policy tag relation current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'policy tag relation last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'policy tag relation deleted at',
PRIMARY KEY (`id`),
UNIQUE KEY `policy_tag_relation_meta_uk_pid_tid_del` (`policy_id`, `tag_id`, `deleted_at`),
KEY `policy_tag_relation_meta_idx_tag_id` (`tag_id`),
KEY `idx_policy_tag_relation_meta_live` (`tag_id`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'policy tag relation';
CREATE TABLE IF NOT EXISTS `policy_role_relation_meta` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`policy_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'policy id',
`role_name` VARCHAR(128) NOT NULL COMMENT 'role name referenced by the policy content',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'policy role relation current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'policy role relation last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'policy role relation deleted at',
PRIMARY KEY (`id`),
UNIQUE KEY `policy_role_relation_meta_uk_pid_rn_del` (`policy_id`, `role_name`, `deleted_at`),
KEY `policy_role_relation_meta_idx_role_name` (`role_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'policy role relation';
CREATE TABLE IF NOT EXISTS `statistic_meta` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`statistic_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'statistic id',
`statistic_name` VARCHAR(128) NOT NULL COMMENT 'statistic name',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
`statistic_value` MEDIUMTEXT NOT NULL COMMENT 'statistic value',
`metadata_object_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metadata object id',
`metadata_object_type` VARCHAR(64) NOT NULL COMMENT 'metadata object type',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'statistic audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'statistic current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'statistic last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'statistic deleted at',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_si_mi_mo_del` (`statistic_name`, `metadata_object_id`, `deleted_at`),
KEY `idx_stid` (`statistic_id`),
KEY `idx_moid` (`metadata_object_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'statistic metadata';
CREATE TABLE IF NOT EXISTS `job_template_meta` (
`job_template_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'job template id',
`job_template_name` VARCHAR(128) NOT NULL COMMENT 'job template name',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
`job_template_comment` TEXT DEFAULT NULL COMMENT 'job template comment',
`job_template_content` MEDIUMTEXT NOT NULL COMMENT 'job template content',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'job template audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'job template current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'job template last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'job template deleted at',
PRIMARY KEY (`job_template_id`),
UNIQUE KEY `uk_mid_jtn_del` (`metalake_id`, `job_template_name`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'job template metadata';
CREATE TABLE IF NOT EXISTS `job_run_meta` (
`job_run_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'job run id',
`job_template_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'job template id',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
`job_execution_id` varchar(256) NOT NULL COMMENT 'job execution id',
`job_run_status` varchar(64) NOT NULL COMMENT 'job run status',
`job_started_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'job started at',
`job_finished_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'job finished at',
`runtime_job_template` MEDIUMTEXT DEFAULT NULL COMMENT 'job run runtime job template',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'job run audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'job run current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'job run last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'job run deleted at',
PRIMARY KEY (`job_run_id`),
UNIQUE KEY `uk_mid_jei_del` (`metalake_id`, `job_execution_id`, `deleted_at`),
KEY `idx_job_template_id` (`job_template_id`),
KEY `idx_job_execution_id` (`job_execution_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'job run metadata';
CREATE TABLE IF NOT EXISTS `table_version_info` (
`table_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'table id',
`format` VARCHAR(64) COMMENT 'table format, such as Lance, Iceberg and so on, it will be null if it is not a lakehouse table',
`properties` MEDIUMTEXT DEFAULT NULL COMMENT 'table properties',
`partitioning` MEDIUMTEXT DEFAULT NULL COMMENT 'table partition info',
`distribution` MEDIUMTEXT DEFAULT NULL COMMENT 'table distribution info',
`sort_orders` MEDIUMTEXT DEFAULT NULL COMMENT 'table sort order info',
`indexes` MEDIUMTEXT DEFAULT NULL COMMENT 'table index info',
`comment` MEDIUMTEXT DEFAULT NULL COMMENT 'table comment',
`version` BIGINT(20) UNSIGNED NOT NULL COMMENT 'table current version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'table deletion timestamp, 0 means not deleted',
PRIMARY KEY (`table_id`, `version`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'table detail information including format, location, properties, partition, distribution, sort order, index and so on';
CREATE TABLE IF NOT EXISTS `function_meta` (
`function_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'function id',
`function_name` VARCHAR(128) NOT NULL COMMENT 'function 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',
`function_type` VARCHAR(64) NOT NULL COMMENT 'function type',
`deterministic` TINYINT(1) DEFAULT 1 COMMENT 'whether the function result is deterministic',
`function_current_version` INT UNSIGNED DEFAULT 1 COMMENT 'function current version',
`function_latest_version` INT UNSIGNED DEFAULT 1 COMMENT 'function latest version',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'function audit info',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'function deleted at',
PRIMARY KEY (`function_id`),
UNIQUE KEY `function_meta_uk_sid_fn_del` (`schema_id`, `function_name`, `deleted_at`),
KEY `function_meta_idx_mid` (`metalake_id`),
KEY `function_meta_idx_cid` (`catalog_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'function metadata';
CREATE TABLE IF NOT EXISTS `function_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',
`function_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'function id',
`version` INT UNSIGNED NOT NULL COMMENT 'function version',
`function_comment` TEXT DEFAULT NULL COMMENT 'function version comment',
`definitions` MEDIUMTEXT NOT NULL COMMENT 'function definitions details',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'function version audit info',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'function version deleted at',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_fid_ver_del` (`function_id`, `version`, `deleted_at`),
KEY `function_version_info_idx_mid` (`metalake_id`),
KEY `function_version_info_idx_cid` (`catalog_id`),
KEY `function_version_info_idx_sid` (`schema_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'function version info';
CREATE TABLE IF NOT EXISTS `view_meta` (
`view_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'view id',
`view_name` VARCHAR(128) NOT NULL COMMENT 'view 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 'view audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'view current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'view last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'view deleted at',
PRIMARY KEY (`view_id`, `deleted_at`),
UNIQUE KEY `uk_sid_vn_del` (`schema_id`, `view_name`, `deleted_at`),
KEY `idx_vemid` (`metalake_id`),
KEY `idx_vecid` (`catalog_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'view metadata';
CREATE TABLE IF NOT EXISTS `view_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',
`view_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'view id',
`version` INT UNSIGNED NOT NULL COMMENT 'view version',
`view_comment` TEXT DEFAULT NULL COMMENT 'view version comment',
`columns` MEDIUMTEXT NOT NULL COMMENT 'view columns snapshot (JSON)',
`properties` MEDIUMTEXT DEFAULT NULL COMMENT 'view properties (JSON)',
`default_catalog` VARCHAR(128) DEFAULT NULL COMMENT 'default catalog for view SQL resolution',
`default_schema` VARCHAR(128) DEFAULT NULL COMMENT 'default schema for view SQL resolution',
`representations` MEDIUMTEXT NOT NULL COMMENT 'view representations (JSON array)',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'view version audit info',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'view version deleted at',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_vid_ver_del` (`view_id`, `version`, `deleted_at`),
KEY `idx_vvmid` (`metalake_id`),
KEY `idx_vvcid` (`catalog_id`),
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',
`active_version` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'published revision, 0 if none',
`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',
`publication_status` VARCHAR(32) NOT NULL DEFAULT 'DRAFT' COMMENT 'publication status of the revision',
`published_by` VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'publishing principal, empty for a draft',
`published_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'publication time in epoch millis, 0 for a draft',
`semantic_model_comment` TEXT DEFAULT NULL COMMENT 'semantic model comment snapshot',
`datasets` MEDIUMTEXT NOT NULL COMMENT 'dataset definitions snapshot (JSON)',
`relationships` MEDIUMTEXT DEFAULT NULL COMMENT 'relationship definitions snapshot (JSON)',
`metrics` MEDIUMTEXT DEFAULT NULL COMMENT 'metric definitions snapshot (JSON)',
`ai_context` MEDIUMTEXT DEFAULT NULL COMMENT 'model AI context snapshot (JSON)',
`custom_extensions` MEDIUMTEXT DEFAULT NULL COMMENT 'model custom extensions 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';
CREATE TABLE IF NOT EXISTS `semantic_model_metric_meta` (
`metric_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'stable internal metric 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 'containing semantic model id',
`metric_name` MEDIUMTEXT NOT NULL COMMENT 'metric name',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'metric retired at',
PRIMARY KEY (`metric_id`),
KEY `idx_smmm_model_live` (`semantic_model_id`, `deleted_at`),
KEY `idx_smmm_mid` (`metalake_id`),
KEY `idx_smmm_cid` (`catalog_id`),
KEY `idx_smmm_sid` (`schema_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'semantic model metric identities';
-- This schema extends version 1.1.0 with partition statistics storage support
-- The partition_statistic_meta table stores partition-level statistics for tables
CREATE TABLE IF NOT EXISTS `partition_statistic_meta` (
`table_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'table id from table_meta',
`partition_name` VARCHAR(1024) NOT NULL COMMENT 'partition name',
`statistic_name` VARCHAR(128) NOT NULL COMMENT 'statistic name',
`statistic_value` MEDIUMTEXT NOT NULL COMMENT 'statistic value as JSON',
`audit_info` TEXT NOT NULL COMMENT 'audit information as JSON',
`created_at` BIGINT(20) UNSIGNED NOT NULL COMMENT 'creation timestamp in milliseconds',
`updated_at` BIGINT(20) UNSIGNED NOT NULL COMMENT 'last update timestamp in milliseconds',
PRIMARY KEY (`table_id`, `partition_name`(255), `statistic_name`),
KEY `idx_table_partition` (`table_id`, `partition_name`(255))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'partition statistics metadata';
-- Optimizer metrics schema
CREATE TABLE IF NOT EXISTS `table_metrics` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`table_identifier` VARCHAR(1024) NOT NULL COMMENT 'normalized table identifier',
`metric_name` VARCHAR(1024) NOT NULL COMMENT 'metric name',
`table_partition` VARCHAR(1024) DEFAULT NULL COMMENT 'normalized partition identifier',
`metric_ts` BIGINT(20) NOT NULL COMMENT 'metric timestamp in epoch seconds',
`metric_value` VARCHAR(1024) NOT NULL COMMENT 'metric value payload',
PRIMARY KEY (`id`),
KEY `idx_table_metrics_metric_ts` (`metric_ts`),
KEY `idx_table_metrics_composite` (`table_identifier`(255), `table_partition`(255), `metric_ts`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'optimizer table metrics';
CREATE TABLE IF NOT EXISTS `job_metrics` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`job_identifier` VARCHAR(1024) NOT NULL COMMENT 'normalized job identifier',
`metric_name` VARCHAR(1024) NOT NULL COMMENT 'metric name',
`metric_ts` BIGINT(20) NOT NULL COMMENT 'metric timestamp in epoch seconds',
`metric_value` VARCHAR(1024) NOT NULL COMMENT 'metric value payload',
PRIMARY KEY (`id`),
KEY `idx_job_metrics_metric_ts` (`metric_ts`),
KEY `idx_job_metrics_identifier_metric_ts` (`job_identifier`(255), `metric_ts`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'optimizer job metrics';
CREATE TABLE IF NOT EXISTS `entity_change_log` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`metalake_name` VARCHAR(128) NOT NULL COMMENT 'metalake name',
`entity_type` VARCHAR(32) NOT NULL COMMENT 'METALAKE | CATALOG | SCHEMA | TABLE | FILESET | TOPIC | MODEL | VIEW',
`entity_full_name` VARCHAR(512) NOT NULL COMMENT 'Encoded full name of the affected entity. For ALTER, stores the old name. For DROP, stores the entity name.',
`operate_type` TINYINT UNSIGNED NOT NULL COMMENT 'Operate type code: 1=ALTER, 2=DROP, 3=INSERT. Codes are stable and never re-used.',
`created_at` BIGINT NOT NULL COMMENT 'timestamp of the change in millis',
PRIMARY KEY (`id`),
KEY `idx_ecl_created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'Append-only log of entity structural changes for targeted metadataIdCache invalidation';
CREATE TABLE IF NOT EXISTS `iceberg_cleanup_job` (
`id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'globally unique cleanup job id',
`catalog_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'globally unique id of the owning catalog, stable across catalog rename',
`namespace` VARCHAR(512) NOT NULL COMMENT 'namespace of the table to be cleaned up',
`table_name` VARCHAR(256) NOT NULL COMMENT 'name of the table to be cleaned up',
`metadata_location` MEDIUMTEXT NOT NULL COMMENT 'location of the table metadata file to purge',
`file_io_impl` VARCHAR(256) NOT NULL COMMENT 'FileIO implementation class used to access the table files',
`file_io_props` MEDIUMTEXT NOT NULL COMMENT 'JSON-encoded FileIO properties',
`state` VARCHAR(16) NOT NULL COMMENT 'PENDING|RUNNING|SUCCEEDED|FAILED',
`attempts` INT(10) NOT NULL DEFAULT 0 COMMENT 'number of processing attempts made so far',
`last_error` VARCHAR(2048) NULL COMMENT 'truncated reason for the most recent failure, NULL until a job fails',
`heartbeat_at` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'last heartbeat from the worker, 0 when not running',
`created_by` VARCHAR(128) NOT NULL COMMENT 'principal that requested the drop (audit)',
`updated_at` BIGINT(20) NOT NULL COMMENT 'last state change, drives poll ordering and old finished-job cleanup',
PRIMARY KEY (`id`),
KEY `idx_state_updated` (`state`, `updated_at`),
KEY `idx_object` (`catalog_id`, `namespace`(255), `table_name`(128), `state`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'async Iceberg table cleanup jobs';
CREATE TABLE IF NOT EXISTS `scheduled_expand_tasks` (
`task_name` VARCHAR(100) NOT NULL COMMENT 'task name',
`task_instance` VARCHAR(100) NOT NULL COMMENT 'task instance',
`task_data` BLOB COMMENT 'serialized task data',
`execution_time` DATETIME(6) NOT NULL COMMENT 'next execution time',
`picked` BOOLEAN NOT NULL COMMENT 'whether the task is currently picked',
`picked_by` VARCHAR(50) COMMENT 'scheduler instance that picked the task',
`last_heartbeat` DATETIME(6) NULL COMMENT 'last heartbeat from the picker',
`version` BIGINT NOT NULL COMMENT 'optimistic lock version',
`consecutive_failures` INT COMMENT 'consecutive failure count',
`last_success` DATETIME(6) NULL COMMENT 'last successful execution time',
`last_failure` DATETIME(6) NULL COMMENT 'last failed execution time',
PRIMARY KEY (`task_name`, `task_instance`),
KEY `execution_time_idx` (`execution_time`),
KEY `last_heartbeat_idx` (`last_heartbeat`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'table maintenance expand schedule metadata';
CREATE TABLE IF NOT EXISTS `scheduled_cron_tasks` (
`task_name` VARCHAR(100) NOT NULL COMMENT 'task name',
`task_instance` VARCHAR(100) NOT NULL COMMENT 'task instance',
`task_data` BLOB COMMENT 'serialized task data',
`execution_time` DATETIME(6) NOT NULL COMMENT 'next execution time',
`picked` BOOLEAN NOT NULL COMMENT 'whether the task is currently picked',
`picked_by` VARCHAR(50) COMMENT 'scheduler instance that picked the task',
`last_heartbeat` DATETIME(6) NULL COMMENT 'last heartbeat from the picker',
`version` BIGINT NOT NULL COMMENT 'optimistic lock version',
`consecutive_failures` INT COMMENT 'consecutive failure count',
`last_success` DATETIME(6) NULL COMMENT 'last successful execution time',
`last_failure` DATETIME(6) NULL COMMENT 'last failed execution time',
PRIMARY KEY (`task_name`, `task_instance`),
KEY `execution_time_idx` (`execution_time`),
KEY `last_heartbeat_idx` (`last_heartbeat`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'table maintenance cron schedule metadata';
CREATE TABLE IF NOT EXISTS `scheduled_commit_tasks` (
`task_name` VARCHAR(100) NOT NULL COMMENT 'task name',
`task_instance` VARCHAR(100) NOT NULL COMMENT 'task instance',
`task_data` BLOB COMMENT 'serialized task data',
`execution_time` DATETIME(6) NOT NULL COMMENT 'next execution time',
`picked` BOOLEAN NOT NULL COMMENT 'whether the task is currently picked',
`picked_by` VARCHAR(50) COMMENT 'scheduler instance that picked the task',
`last_heartbeat` DATETIME(6) NULL COMMENT 'last heartbeat from the picker',
`version` BIGINT NOT NULL COMMENT 'optimistic lock version',
`consecutive_failures` INT COMMENT 'consecutive failure count',
`last_success` DATETIME(6) NULL COMMENT 'last successful execution time',
`last_failure` DATETIME(6) NULL COMMENT 'last failed execution time',
PRIMARY KEY (`task_name`, `task_instance`),
KEY `execution_time_idx` (`execution_time`),
KEY `last_heartbeat_idx` (`last_heartbeat`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'table maintenance commit schedule metadata';
CREATE TABLE IF NOT EXISTS `table_maintenance_action` (
`action_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'maintenance action id',
`job_id` BIGINT(20) UNSIGNED NULL COMMENT 'job run id, maps to job_run_meta.job_run_id',
`table_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'table id from table_meta',
`policy_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'policy id from policy_meta',
`before_metrics_id` BIGINT(20) UNSIGNED NULL COMMENT 'table_snapshot_metrics.metrics_id for S0 sample',
`after_metrics_id` BIGINT(20) UNSIGNED NULL COMMENT 'table_snapshot_metrics.metrics_id for S1 sample',
`created_at` BIGINT(20) UNSIGNED NOT NULL COMMENT 'creation timestamp in milliseconds',
`finished_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'finish millis, 0 = soft in-flight slot (one per table/policy)',
PRIMARY KEY (`action_id`),
KEY `idx_tma_job_id` (`job_id`),
-- Soft slot: finished_at=0 is exclusive per table/policy (one in-flight finish).
UNIQUE KEY `uk_tma_table_policy_finished` (`table_id`, `policy_id`, `finished_at`),
KEY `idx_tma_before_metrics` (`before_metrics_id`),
KEY `idx_tma_after_metrics` (`after_metrics_id`),
KEY `idx_tma_created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'table maintenance action metadata';
CREATE TABLE IF NOT EXISTS `table_snapshot_metrics` (
`metrics_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'metrics row id',
`table_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'table id from table_meta',
`policy_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'policy id from policy_meta',
`snapshot_id` BIGINT(20) NOT NULL COMMENT 'Iceberg snapshot id',
`metrics_value` MEDIUMTEXT NOT NULL COMMENT 'metrics value as JSON',
`created_at` BIGINT(20) UNSIGNED NOT NULL COMMENT 'creation timestamp in milliseconds',
PRIMARY KEY (`metrics_id`),
KEY `idx_tsm_tid_pid_sid` (`table_id`, `policy_id`, `snapshot_id`),
KEY `idx_tsm_created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'table snapshot metrics metadata';
CREATE TABLE IF NOT EXISTS `semantic_model_source_rel` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'containing metalake id',
`semantic_model_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'containing semantic model id',
`dataset_name` MEDIUMTEXT NOT NULL COMMENT 'exact dataset name in the associated revisions',
`source_type` VARCHAR(64) NOT NULL COMMENT 'TABLE or VIEW',
`source_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'resolved source object id',
`from_version` INT UNSIGNED NOT NULL COMMENT 'first revision containing this association',
`to_version` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'first revision without it, 0 if open',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'association retired at',
PRIMARY KEY (`id`),
KEY `idx_smsr_model` (`semantic_model_id`, `deleted_at`),
KEY `idx_smsr_source` (`metalake_id`, `source_type`, `source_id`, `deleted_at`),
KEY `idx_smsr_deleted_at` (`deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
COMMENT 'versioned semantic model dataset source associations';
CREATE TABLE IF NOT EXISTS `domain_meta` (
`domain_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'domain id',
`domain_name` VARCHAR(128) NOT NULL COMMENT 'domain name',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
`domain_comment` VARCHAR(256) DEFAULT '' COMMENT 'domain comment',
`domain_status` VARCHAR(16) NOT NULL DEFAULT 'DRAFT' COMMENT 'domain status, DRAFT or PUBLISHED',
`backing_tag_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'id of the backing tag, NULL if the domain has none',
`backing_tag_value` VARCHAR(256) DEFAULT NULL COMMENT 'value of the backing tag, NULL binds the tag without a value',
`properties` MEDIUMTEXT DEFAULT NULL COMMENT 'domain properties',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'domain audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'domain current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'domain last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'domain deleted at',
PRIMARY KEY (`domain_id`),
UNIQUE KEY `uk_mi_dn_del` (`metalake_id`, `domain_name`, `deleted_at`),
KEY `domain_meta_idx_backing_tag` (`metalake_id`, `backing_tag_id`, `backing_tag_value`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'domain metadata';
CREATE TABLE IF NOT EXISTS `domain_rel` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
`parent_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'parent domain id',
`child_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'sub-domain id',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'domain relation audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'domain relation current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'domain relation last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'domain relation deleted at',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_dr_ci_del` (`child_id`, `deleted_at`),
KEY `domain_rel_idx_parent` (`parent_id`, `deleted_at`),
KEY `domain_rel_idx_metalake` (`metalake_id`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'domain parent relation';
CREATE TABLE IF NOT EXISTS `iceberg_idempotency_meta` (
`idempotency_key` VARCHAR(36) NOT NULL COMMENT 'client-provided UUIDv7 idempotency key',
`http_method` VARCHAR(16) NOT NULL COMMENT 'HTTP method of the request',
`request_uri` MEDIUMTEXT NOT NULL COMMENT 'encoded request path and sorted query string',
`http_status` INT(10) UNSIGNED DEFAULT NULL COMMENT 'HTTP status of finalized response, NULL while reserved',
`response_summary` MEDIUMTEXT DEFAULT NULL COMMENT 'serialized response body (JSON) for replay',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'idempotency record audit info',
`created_at` BIGINT(20) UNSIGNED NOT NULL COMMENT 'record created at (unix epoch millis)',
`expires_at` BIGINT(20) UNSIGNED NOT NULL COMMENT 'record expires at (unix epoch millis)',
PRIMARY KEY (`idempotency_key`),
KEY `idx_iim_expires` (`expires_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'Iceberg REST idempotency records';
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';