diff --git standalone-metastore/metastore-common/src/main/sql/derby/hive-schema-3.1.0.derby.sql standalone-metastore/metastore-common/src/main/sql/derby/hive-schema-3.1.0.derby.sql index 5e8693e128..e47938e76a 100644 --- standalone-metastore/metastore-common/src/main/sql/derby/hive-schema-3.1.0.derby.sql +++ standalone-metastore/metastore-common/src/main/sql/derby/hive-schema-3.1.0.derby.sql @@ -47,7 +47,7 @@ CREATE TABLE "APP"."IDXS" ("INDEX_ID" BIGINT NOT NULL, "CREATE_TIME" INTEGER NOT CREATE TABLE "APP"."INDEX_PARAMS" ("INDEX_ID" BIGINT NOT NULL, "PARAM_KEY" VARCHAR(256) NOT NULL, "PARAM_VALUE" VARCHAR(4000)); -CREATE TABLE "APP"."PARTITIONS" ("PART_ID" BIGINT NOT NULL, "CREATE_TIME" INTEGER NOT NULL, "LAST_ACCESS_TIME" INTEGER NOT NULL, "PART_NAME" VARCHAR(767), "SD_ID" BIGINT, "TBL_ID" BIGINT); +CREATE TABLE "APP"."PARTITIONS" ("PART_ID" BIGINT NOT NULL, "CREATE_TIME" INTEGER NOT NULL, "LAST_ACCESS_TIME" INTEGER NOT NULL, "PART_NAME" VARCHAR(767), "SD_ID" BIGINT, "TBL_ID" BIGINT, "WRITE_ID" BIGINT DEFAULT 0); CREATE TABLE "APP"."SERDES" ("SERDE_ID" BIGINT NOT NULL, "NAME" VARCHAR(128), "SLIB" VARCHAR(4000), "DESCRIPTION" VARCHAR(4000), "SERIALIZER_CLASS" VARCHAR(4000), "DESERIALIZER_CLASS" VARCHAR(4000), SERDE_TYPE INTEGER); @@ -75,7 +75,7 @@ CREATE TABLE "APP"."COLUMNS" ("SD_ID" BIGINT NOT NULL, "COMMENT" VARCHAR(256), " CREATE TABLE "APP"."ROLES" ("ROLE_ID" BIGINT NOT NULL, "CREATE_TIME" INTEGER NOT NULL, "OWNER_NAME" VARCHAR(128), "ROLE_NAME" VARCHAR(128)); -CREATE TABLE "APP"."TBLS" ("TBL_ID" BIGINT NOT NULL, "CREATE_TIME" INTEGER NOT NULL, "DB_ID" BIGINT, "LAST_ACCESS_TIME" INTEGER NOT NULL, "OWNER" VARCHAR(767), "OWNER_TYPE" VARCHAR(10), "RETENTION" INTEGER NOT NULL, "SD_ID" BIGINT, "TBL_NAME" VARCHAR(256), "TBL_TYPE" VARCHAR(128), "VIEW_EXPANDED_TEXT" LONG VARCHAR, "VIEW_ORIGINAL_TEXT" LONG VARCHAR, "IS_REWRITE_ENABLED" CHAR(1) NOT NULL DEFAULT 'N'); +CREATE TABLE "APP"."TBLS" ("TBL_ID" BIGINT NOT NULL, "CREATE_TIME" INTEGER NOT NULL, "DB_ID" BIGINT, "LAST_ACCESS_TIME" INTEGER NOT NULL, "OWNER" VARCHAR(767), "OWNER_TYPE" VARCHAR(10), "RETENTION" INTEGER NOT NULL, "SD_ID" BIGINT, "TBL_NAME" VARCHAR(256), "TBL_TYPE" VARCHAR(128), "VIEW_EXPANDED_TEXT" LONG VARCHAR, "VIEW_ORIGINAL_TEXT" LONG VARCHAR, "IS_REWRITE_ENABLED" CHAR(1) NOT NULL DEFAULT 'N', "WRITE_ID" BIGINT DEFAULT 0); CREATE TABLE "APP"."PARTITION_KEYS" ("TBL_ID" BIGINT NOT NULL, "PKEY_COMMENT" VARCHAR(4000), "PKEY_NAME" VARCHAR(128) NOT NULL, "PKEY_TYPE" VARCHAR(767) NOT NULL, "INTEGER_IDX" INTEGER NOT NULL); diff --git standalone-metastore/metastore-common/src/main/sql/derby/upgrade-3.0.0-to-3.1.0.derby.sql standalone-metastore/metastore-common/src/main/sql/derby/upgrade-3.0.0-to-3.1.0.derby.sql index 2b200f2184..1f7fc5feb4 100644 --- standalone-metastore/metastore-common/src/main/sql/derby/upgrade-3.0.0-to-3.1.0.derby.sql +++ standalone-metastore/metastore-common/src/main/sql/derby/upgrade-3.0.0-to-3.1.0.derby.sql @@ -64,5 +64,9 @@ CREATE TABLE MATERIALIZATION_REBUILD_LOCKS ( PRIMARY KEY(MRL_TXN_ID) ); +-- HIVE-19416 +ALTER TABLE "APP"."TBLS" ADD COLUMN "WRITE_ID" BIGINT DEFAULT 0; +ALTER TABLE "APP"."PARTITIONS" ADD COLUMN "WRITE_ID" BIGINT DEFAULT 0; + -- This needs to be the last thing done. Insert any changes above this line. UPDATE "APP".VERSION SET SCHEMA_VERSION='3.1.0', VERSION_COMMENT='Hive release version 3.1.0' where VER_ID=1; diff --git standalone-metastore/metastore-common/src/main/sql/mssql/hive-schema-3.1.0.mssql.sql standalone-metastore/metastore-common/src/main/sql/mssql/hive-schema-3.1.0.mssql.sql index 446ee6e819..9378ab6422 100644 --- standalone-metastore/metastore-common/src/main/sql/mssql/hive-schema-3.1.0.mssql.sql +++ standalone-metastore/metastore-common/src/main/sql/mssql/hive-schema-3.1.0.mssql.sql @@ -145,8 +145,8 @@ CREATE TABLE PARTITIONS LAST_ACCESS_TIME int NOT NULL, PART_NAME nvarchar(767) NULL, SD_ID bigint NULL, - TBL_ID bigint NULL -); + TBL_ID bigint NULL, + WRITE_ID bigint NOT NULL DEFAULT 0); ALTER TABLE PARTITIONS ADD CONSTRAINT PARTITIONS_PK PRIMARY KEY (PART_ID); @@ -376,8 +376,8 @@ CREATE TABLE TBLS TBL_TYPE nvarchar(128) NULL, VIEW_EXPANDED_TEXT text NULL, VIEW_ORIGINAL_TEXT text NULL, - IS_REWRITE_ENABLED bit NOT NULL DEFAULT 0 -); + IS_REWRITE_ENABLED bit NOT NULL DEFAULT 0, + WRITE_ID bigint NOT NULL DEFAULT 0); ALTER TABLE TBLS ADD CONSTRAINT TBLS_PK PRIMARY KEY (TBL_ID); diff --git standalone-metastore/metastore-common/src/main/sql/mssql/upgrade-3.0.0-to-3.1.0.mssql.sql standalone-metastore/metastore-common/src/main/sql/mssql/upgrade-3.0.0-to-3.1.0.mssql.sql index d44cfdb179..dc79e46304 100644 --- standalone-metastore/metastore-common/src/main/sql/mssql/upgrade-3.0.0-to-3.1.0.mssql.sql +++ standalone-metastore/metastore-common/src/main/sql/mssql/upgrade-3.0.0-to-3.1.0.mssql.sql @@ -64,6 +64,10 @@ PRIMARY KEY CLUSTERED ) ); +-- HIVE-19416 +ALTER TABLE TBLS ADD WRITE_ID bigint NOT NULL DEFAULT(0); +ALTER TABLE PARTITIONS ADD WRITE_ID bigint NOT NULL DEFAULT(0); + -- These lines need to be last. Insert any changes above. UPDATE VERSION SET SCHEMA_VERSION='3.1.0', VERSION_COMMENT='Hive release version 3.1.0' where VER_ID=1; diff --git standalone-metastore/metastore-common/src/main/sql/mysql/hive-schema-3.1.0.mysql.sql standalone-metastore/metastore-common/src/main/sql/mysql/hive-schema-3.1.0.mysql.sql index 75612a7143..59d459f707 100644 --- standalone-metastore/metastore-common/src/main/sql/mysql/hive-schema-3.1.0.mysql.sql +++ standalone-metastore/metastore-common/src/main/sql/mysql/hive-schema-3.1.0.mysql.sql @@ -224,6 +224,7 @@ CREATE TABLE IF NOT EXISTS `PARTITIONS` ( `PART_NAME` varchar(767) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL, `SD_ID` bigint(20) DEFAULT NULL, `TBL_ID` bigint(20) DEFAULT NULL, + `WRITE_ID` bigint(20) DEFAULT 0, PRIMARY KEY (`PART_ID`), UNIQUE KEY `UNIQUEPARTITION` (`PART_NAME`,`TBL_ID`), KEY `PARTITIONS_N49` (`TBL_ID`), @@ -630,6 +631,7 @@ CREATE TABLE IF NOT EXISTS `TBLS` ( `VIEW_EXPANDED_TEXT` mediumtext, `VIEW_ORIGINAL_TEXT` mediumtext, `IS_REWRITE_ENABLED` bit(1) NOT NULL DEFAULT 0, + `WRITE_ID` bigint(20) DEFAULT 0, PRIMARY KEY (`TBL_ID`), UNIQUE KEY `UNIQUETABLE` (`TBL_NAME`,`DB_ID`), KEY `TBLS_N50` (`SD_ID`), diff --git standalone-metastore/metastore-common/src/main/sql/mysql/upgrade-3.0.0-to-3.1.0.mysql.sql standalone-metastore/metastore-common/src/main/sql/mysql/upgrade-3.0.0-to-3.1.0.mysql.sql index 7752e891a8..8fc83abc56 100644 --- standalone-metastore/metastore-common/src/main/sql/mysql/upgrade-3.0.0-to-3.1.0.mysql.sql +++ standalone-metastore/metastore-common/src/main/sql/mysql/upgrade-3.0.0-to-3.1.0.mysql.sql @@ -65,6 +65,9 @@ CREATE TABLE MATERIALIZATION_REBUILD_LOCKS ( PRIMARY KEY(MRL_TXN_ID) ); +ALTER TABLE TBLS ADD WRITE_ID bigint DEFAULT 0; +ALTER TABLE PARTITIONS ADD WRITE_ID bigint DEFAULT 0; + -- These lines need to be last. Insert any changes above. UPDATE VERSION SET SCHEMA_VERSION='3.1.0', VERSION_COMMENT='Hive release version 3.1.0' where VER_ID=1; diff --git standalone-metastore/metastore-common/src/main/sql/oracle/hive-schema-3.1.0.oracle.sql standalone-metastore/metastore-common/src/main/sql/oracle/hive-schema-3.1.0.oracle.sql index a4720c865e..5fa88a674a 100644 --- standalone-metastore/metastore-common/src/main/sql/oracle/hive-schema-3.1.0.oracle.sql +++ standalone-metastore/metastore-common/src/main/sql/oracle/hive-schema-3.1.0.oracle.sql @@ -163,7 +163,8 @@ CREATE TABLE PARTITIONS LAST_ACCESS_TIME NUMBER (10) NOT NULL, PART_NAME VARCHAR2(767) NULL, SD_ID NUMBER NULL, - TBL_ID NUMBER NULL + TBL_ID NUMBER NULL, + WRITE_ID NUMBER DEFAULT 0 NOT NULL ); ALTER TABLE PARTITIONS ADD CONSTRAINT PARTITIONS_PK PRIMARY KEY (PART_ID); @@ -398,7 +399,8 @@ CREATE TABLE TBLS TBL_TYPE VARCHAR2(128) NULL, VIEW_EXPANDED_TEXT CLOB NULL, VIEW_ORIGINAL_TEXT CLOB NULL, - IS_REWRITE_ENABLED NUMBER(1) DEFAULT 0 NOT NULL CHECK (IS_REWRITE_ENABLED IN (1,0)) + IS_REWRITE_ENABLED NUMBER(1) DEFAULT 0 NOT NULL CHECK (IS_REWRITE_ENABLED IN (1,0)), + WRITE_ID NUMBER DEFAULT 0 NOT NULL ); ALTER TABLE TBLS ADD CONSTRAINT TBLS_PK PRIMARY KEY (TBL_ID); diff --git standalone-metastore/metastore-common/src/main/sql/oracle/upgrade-3.0.0-to-3.1.0.oracle.sql standalone-metastore/metastore-common/src/main/sql/oracle/upgrade-3.0.0-to-3.1.0.oracle.sql index e4efe4d12d..ac077e5599 100644 --- standalone-metastore/metastore-common/src/main/sql/oracle/upgrade-3.0.0-to-3.1.0.oracle.sql +++ standalone-metastore/metastore-common/src/main/sql/oracle/upgrade-3.0.0-to-3.1.0.oracle.sql @@ -65,6 +65,11 @@ CREATE TABLE MATERIALIZATION_REBUILD_LOCKS ( PRIMARY KEY(MRL_TXN_ID) ); + +alter table TBLS add WRITE_ID number DEFAULT 0 NOT NULL; +alter table PARTITIONS add WRITE_ID number DEFAULT 0 NOT NULL; + + -- These lines need to be last. Insert any changes above. UPDATE VERSION SET SCHEMA_VERSION='3.1.0', VERSION_COMMENT='Hive release version 3.1.0' where VER_ID=1; SELECT 'Finished upgrading MetaStore schema from 3.0.0 to 3.1.0' AS Status from dual; diff --git standalone-metastore/metastore-common/src/main/sql/postgres/hive-schema-3.1.0.postgres.sql standalone-metastore/metastore-common/src/main/sql/postgres/hive-schema-3.1.0.postgres.sql index a74c388d12..654ae416d6 100644 --- standalone-metastore/metastore-common/src/main/sql/postgres/hive-schema-3.1.0.postgres.sql +++ standalone-metastore/metastore-common/src/main/sql/postgres/hive-schema-3.1.0.postgres.sql @@ -168,7 +168,8 @@ CREATE TABLE "PARTITIONS" ( "LAST_ACCESS_TIME" bigint NOT NULL, "PART_NAME" character varying(767) DEFAULT NULL::character varying, "SD_ID" bigint, - "TBL_ID" bigint + "TBL_ID" bigint, + "WRITE_ID" bigint DEFAULT 0 ); @@ -392,7 +393,8 @@ CREATE TABLE "TBLS" ( "TBL_TYPE" character varying(128) DEFAULT NULL::character varying, "VIEW_EXPANDED_TEXT" text, "VIEW_ORIGINAL_TEXT" text, - "IS_REWRITE_ENABLED" boolean NOT NULL DEFAULT false + "IS_REWRITE_ENABLED" boolean NOT NULL DEFAULT false, + "WRITE_ID" bigint DEFAULT 0 ); -- diff --git standalone-metastore/metastore-common/src/main/sql/postgres/upgrade-3.0.0-to-3.1.0.postgres.sql standalone-metastore/metastore-common/src/main/sql/postgres/upgrade-3.0.0-to-3.1.0.postgres.sql index dadf065819..4a4edbc011 100644 --- standalone-metastore/metastore-common/src/main/sql/postgres/upgrade-3.0.0-to-3.1.0.postgres.sql +++ standalone-metastore/metastore-common/src/main/sql/postgres/upgrade-3.0.0-to-3.1.0.postgres.sql @@ -67,6 +67,10 @@ CREATE TABLE MATERIALIZATION_REBUILD_LOCKS ( PRIMARY KEY(MRL_TXN_ID) ); +-- HIVE-19416 +ALTER TABLE "TBLS" ADD COLUMN "WRITE_ID" bigint DEFAULT 0; +ALTER TABLE "PARTITIONS" ADD COLUMN "WRITE_ID" bigint DEFAULT 0; + -- These lines need to be last. Insert any changes above. UPDATE "VERSION" SET "SCHEMA_VERSION"='3.1.0', "VERSION_COMMENT"='Hive release version 3.1.0' where "VER_ID"=1; SELECT 'Finished upgrading MetaStore schema from 3.0.0 to 3.1.0';