HIVE-13349: Metastore Changes : API calls for retrieving primary keys and foreign keys information - Adding metastore scripts (Hari Subramaniyan, reviewed by Ashutosh Chauhan)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/6c3d3b49 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/6c3d3b49 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/6c3d3b49 Branch: refs/heads/llap Commit: 6c3d3b495bafcf78445d785184b7da025e348c6b Parents: 55375ec Author: Hari Subramaniyan <harisan...@apache.org> Authored: Tue Apr 19 11:47:12 2016 -0700 Committer: Hari Subramaniyan <harisan...@apache.org> Committed: Tue Apr 19 11:47:12 2016 -0700 ---------------------------------------------------------------------- .../scripts/upgrade/derby/034-HIVE-13076.derby.sql | 3 +++ .../scripts/upgrade/mssql/019-HIVE-13076.mssql.sql | 15 +++++++++++++++ .../scripts/upgrade/mysql/034-HIVE-13076.mysql.sql | 17 +++++++++++++++++ .../upgrade/oracle/034-HIVE-13076.oracle.sql | 15 +++++++++++++++ .../upgrade/postgres/033-HIVE-13076.postgres.sql | 15 +++++++++++++++ 5 files changed, 65 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/6c3d3b49/metastore/scripts/upgrade/derby/034-HIVE-13076.derby.sql ---------------------------------------------------------------------- diff --git a/metastore/scripts/upgrade/derby/034-HIVE-13076.derby.sql b/metastore/scripts/upgrade/derby/034-HIVE-13076.derby.sql new file mode 100644 index 0000000..b062c56 --- /dev/null +++ b/metastore/scripts/upgrade/derby/034-HIVE-13076.derby.sql @@ -0,0 +1,3 @@ +CREATE TABLE "APP"."KEY_CONSTRAINTS" ("CHILD_CD_ID" BIGINT, "CHILD_TBL_ID" BIGINT, "PARENT_CD_ID" BIGINT NOT NULL, "PARENT_TBL_ID" BIGINT NOT NULL, "POSITION" BIGINT NOT NULL, "CONSTRAINT_NAME" VARCHAR(400) NOT NULL, "CONSTRAINT_TYPE" SMALLINT NOT NULL, "UPDATE_RULE" SMALLINT, "DELETE_RULE" SMALLINT, "ENABLE_VALIDATE_RELY" SMALLINT NOT NULL); +ALTER TABLE "APP"."KEY_CONSTRAINTS" ADD CONSTRAINT "CONSTRAINTS_PK" PRIMARY KEY ("CONSTRAINT_NAME", "POSITION"); +CREATE INDEX "APP"."CONSTRAINTS_PARENT_TBL_ID_INDEX" ON "APP"."KEY_CONSTRAINTS"("PARENT_TBL_ID"); http://git-wip-us.apache.org/repos/asf/hive/blob/6c3d3b49/metastore/scripts/upgrade/mssql/019-HIVE-13076.mssql.sql ---------------------------------------------------------------------- diff --git a/metastore/scripts/upgrade/mssql/019-HIVE-13076.mssql.sql b/metastore/scripts/upgrade/mssql/019-HIVE-13076.mssql.sql new file mode 100644 index 0000000..00ddb73 --- /dev/null +++ b/metastore/scripts/upgrade/mssql/019-HIVE-13076.mssql.sql @@ -0,0 +1,15 @@ +CREATE TABLE KEY_CONSTRAINTS +( + CHILD_CD_ID BIGINT, + CHILD_TBL_ID BIGINT, + PARENT_CD_ID BIGINT NOT NULL, + PARENT_TBL_ID BIGINT NOT NULL, + POSITION INT NOT NULL, + CONSTRAINT_NAME VARCHAR(400) NOT NULL, + CONSTRAINT_TYPE SMALLINT NOT NULL, + UPDATE_RULE SMALLINT, + DELETE_RULE SMALLINT, + ENABLE_VALIDATE_RELY SMALLINT NOT NULL +) ; +ALTER TABLE KEY_CONSTRAINTS ADD CONSTRAINT CONSTRAINTS_PK PRIMARY KEY (CONSTRAINT_NAME, POSITION); +CREATE INDEX CONSTRAINTS_PARENT_TBL_ID__INDEX ON KEY_CONSTRAINTS(PARENT_TBL_ID); http://git-wip-us.apache.org/repos/asf/hive/blob/6c3d3b49/metastore/scripts/upgrade/mysql/034-HIVE-13076.mysql.sql ---------------------------------------------------------------------- diff --git a/metastore/scripts/upgrade/mysql/034-HIVE-13076.mysql.sql b/metastore/scripts/upgrade/mysql/034-HIVE-13076.mysql.sql new file mode 100644 index 0000000..c9a5e1d --- /dev/null +++ b/metastore/scripts/upgrade/mysql/034-HIVE-13076.mysql.sql @@ -0,0 +1,17 @@ +CREATE TABLE IF NOT EXISTS `KEY_CONSTRAINTS` +( + `CHILD_CD_ID` BIGINT, + `CHILD_TBL_ID` BIGINT, + `PARENT_CD_ID` BIGINT NOT NULL, + `PARENT_TBL_ID` BIGINT NOT NULL, + `POSITION` BIGINT NOT NULL, + `CONSTRAINT_NAME` VARCHAR(400) NOT NULL, + `CONSTRAINT_TYPE` SMALLINT(6) NOT NULL, + `UPDATE_RULE` SMALLINT(6), + `DELETE_RULE` SMALLINT(6), + `ENABLE_VALIDATE_RELY` SMALLINT(6) NOT NULL, + PRIMARY KEY (`CONSTRAINT_NAME`, `POSITION`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +CREATE INDEX `CONSTRAINTS_PARENT_TABLE_ID_INDEX` ON KEY_CONSTRAINTS (`PARENT_TBL_ID`) USING BTREE; + + http://git-wip-us.apache.org/repos/asf/hive/blob/6c3d3b49/metastore/scripts/upgrade/oracle/034-HIVE-13076.oracle.sql ---------------------------------------------------------------------- diff --git a/metastore/scripts/upgrade/oracle/034-HIVE-13076.oracle.sql b/metastore/scripts/upgrade/oracle/034-HIVE-13076.oracle.sql new file mode 100644 index 0000000..baf855c --- /dev/null +++ b/metastore/scripts/upgrade/oracle/034-HIVE-13076.oracle.sql @@ -0,0 +1,15 @@ +CREATE TABLE IF NOT EXISTS KEY_CONSTRAINTS +( + CHILD_CD_ID NUMBER, + CHILD_TBL_ID NUMBER, + PARENT_CD_ID NUMBER NOT NULL, + PARENT_TBL_ID NUMBER NOT NULL, + POSITION NUMBER NOT NULL, + CONSTRAINT_NAME VARCHAR(400) NOT NULL, + CONSTRAINT_TYPE NUMBER NOT NULL, + UPDATE_RULE NUMBER, + DELETE_RULE NUMBER, + ENABLE_VALIDATE_RELY NUMBER NOT NULL +) ; +ALTER TABLE KEY_CONSTRAINTS ADD CONSTRAINT CONSTRAINTS_PK PRIMARY KEY (CONSTRAINT_NAME, POSITION); +CREATE INDEX CONSTRAINTS_PARENT_TBL_ID_INDEX ON KEY_CONSTRAINTS(PARENT_TBL_ID); http://git-wip-us.apache.org/repos/asf/hive/blob/6c3d3b49/metastore/scripts/upgrade/postgres/033-HIVE-13076.postgres.sql ---------------------------------------------------------------------- diff --git a/metastore/scripts/upgrade/postgres/033-HIVE-13076.postgres.sql b/metastore/scripts/upgrade/postgres/033-HIVE-13076.postgres.sql new file mode 100644 index 0000000..ec1fb48 --- /dev/null +++ b/metastore/scripts/upgrade/postgres/033-HIVE-13076.postgres.sql @@ -0,0 +1,15 @@ +CREATE TABLE IF NOT EXISTS "KEY_CONSTRAINTS" +( + "CHILD_CD_ID" BIGINT, + "CHILD_TBL_ID" BIGINT, + "PARENT_CD_ID" BIGINT NOT NULL, + "PARENT_TBL_ID" BIGINT NOT NULL, + "POSITION" BIGINT NOT NULL, + "CONSTRAINT_NAME" VARCHAR(400) NOT NULL, + "CONSTRAINT_TYPE" SMALLINT NOT NULL, + "UPDATE_RULE" SMALLINT, + "DELETE_RULE" SMALLINT, + "ENABLE_VALIDATE_RELY" SMALLINT NOT NULL, + PRIMARY KEY ("CONSTRAINT_NAME", "POSITION") +) ; +CREATE INDEX "CONSTRAINTS_PARENT_TBLID_INDEX" ON "KEY_CONSTRAINTS" USING BTREE ("PARENT_TBL_ID");