HIVE-10614 : schemaTool upgrade from 0.14.0 to 1.3.0 causes failure (Hari Subramaniyan via Sushanth Sowmyan, Thejas Nair)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/dc72c873 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/dc72c873 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/dc72c873 Branch: refs/heads/beeline-cli Commit: dc72c873690e0b0f4a9be992172d6959d8ddddfe Parents: 3997202 Author: Sushanth Sowmyan <khorg...@gmail.com> Authored: Wed May 6 13:46:54 2015 -0700 Committer: Sushanth Sowmyan <khorg...@gmail.com> Committed: Wed May 6 13:47:54 2015 -0700 ---------------------------------------------------------------------- .../upgrade/mysql/021-HIVE-7018.mysql.sql | 53 -------------------- .../upgrade/mysql/hive-schema-1.2.0.mysql.sql | 10 +++- .../upgrade/mysql/hive-schema-1.3.0.mysql.sql | 10 +++- .../mysql/upgrade-1.1.0-to-1.2.0.mysql.sql | 2 +- 4 files changed, 17 insertions(+), 58 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/dc72c873/metastore/scripts/upgrade/mysql/021-HIVE-7018.mysql.sql ---------------------------------------------------------------------- diff --git a/metastore/scripts/upgrade/mysql/021-HIVE-7018.mysql.sql b/metastore/scripts/upgrade/mysql/021-HIVE-7018.mysql.sql deleted file mode 100644 index 08208f9..0000000 --- a/metastore/scripts/upgrade/mysql/021-HIVE-7018.mysql.sql +++ /dev/null @@ -1,53 +0,0 @@ -SELECT '< HIVE-7018 Remove Table and Partition tables column LINK_TARGET_ID from Mysql for other DBs do not have it >' AS ' '; - -DELIMITER $$ -DROP PROCEDURE IF EXISTS RM_TLBS_LINKID $$ -DROP PROCEDURE IF EXISTS RM_PARTITIONS_LINKID $$ -DROP PROCEDURE IF EXISTS RM_LINKID $$ - -/* Call this procedure to drop column LINK_TARGET_ID for TBLS */ -CREATE PROCEDURE RM_TLBS_LINKID() - BEGIN - IF EXISTS (SELECT * FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_NAME` = 'TBLS' AND `COLUMN_NAME` = 'LINK_TARGET_ID') THEN - ALTER TABLE `TBLS` - DROP FOREIGN KEY `TBLS_FK3` - ; - ALTER TABLE `TBLS` - DROP KEY `TBLS_N51` - ; - ALTER TABLE `TBLS` - DROP COLUMN `LINK_TARGET_ID` - ; - END IF; - END $$ - -/* Call this procedure to drop column LINK_TARGET_ID for PARTITIONS */ -CREATE PROCEDURE RM_PARTITIONS_LINKID() - BEGIN - IF EXISTS (SELECT * FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_NAME` = 'PARTITIONS' AND `COLUMN_NAME` = 'LINK_TARGET_ID') THEN - ALTER TABLE `PARTITIONS` - DROP FOREIGN KEY `PARTITIONS_FK3` - ; - ALTER TABLE `PARTITIONS` - DROP KEY `PARTITIONS_N51` - ; - ALTER TABLE `PARTITIONS` - DROP COLUMN `LINK_TARGET_ID` - ; - END IF; - END $$ - -/* - * Check and drop column LINK_TARGET_ID - */ -CREATE PROCEDURE RM_LINKID() - BEGIN - call RM_PARTITIONS_LINKID(); - call RM_TLBS_LINKID(); - SELECT 'Completed remove LINK_TARGET_ID'; - END $$ - - -DELIMITER ; - -CALL RM_LINKID(); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hive/blob/dc72c873/metastore/scripts/upgrade/mysql/hive-schema-1.2.0.mysql.sql ---------------------------------------------------------------------- diff --git a/metastore/scripts/upgrade/mysql/hive-schema-1.2.0.mysql.sql b/metastore/scripts/upgrade/mysql/hive-schema-1.2.0.mysql.sql index cdda8db..07dce8f 100644 --- a/metastore/scripts/upgrade/mysql/hive-schema-1.2.0.mysql.sql +++ b/metastore/scripts/upgrade/mysql/hive-schema-1.2.0.mysql.sql @@ -211,12 +211,15 @@ 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, + `LINK_TARGET_ID` bigint(20) DEFAULT NULL, PRIMARY KEY (`PART_ID`), UNIQUE KEY `UNIQUEPARTITION` (`PART_NAME`,`TBL_ID`), KEY `PARTITIONS_N49` (`TBL_ID`), KEY `PARTITIONS_N50` (`SD_ID`), + KEY `PARTITIONS_N51` (`LINK_TARGET_ID`) CONSTRAINT `PARTITIONS_FK1` FOREIGN KEY (`TBL_ID`) REFERENCES `TBLS` (`TBL_ID`), - CONSTRAINT `PARTITIONS_FK2` FOREIGN KEY (`SD_ID`) REFERENCES `SDS` (`SD_ID`) + CONSTRAINT `PARTITIONS_FK2` FOREIGN KEY (`SD_ID`) REFERENCES `SDS` (`SD_ID`), + CONSTRAINT `PARTITIONS_FK3` FOREIGN KEY (`LINK_TARGET_ID`) REFERENCES `PARTITIONS` (`PART_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -587,12 +590,15 @@ CREATE TABLE IF NOT EXISTS `TBLS` ( `TBL_TYPE` varchar(128) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL, `VIEW_EXPANDED_TEXT` mediumtext, `VIEW_ORIGINAL_TEXT` mediumtext, + `LINK_TARGET_ID` bigint(20) DEFAULT NULL, PRIMARY KEY (`TBL_ID`), UNIQUE KEY `UNIQUETABLE` (`TBL_NAME`,`DB_ID`), KEY `TBLS_N50` (`SD_ID`), KEY `TBLS_N49` (`DB_ID`), + KEY `TBLS_N51` (`LINK_TARGET_ID`), CONSTRAINT `TBLS_FK1` FOREIGN KEY (`SD_ID`) REFERENCES `SDS` (`SD_ID`), - CONSTRAINT `TBLS_FK2` FOREIGN KEY (`DB_ID`) REFERENCES `DBS` (`DB_ID`) + CONSTRAINT `TBLS_FK2` FOREIGN KEY (`DB_ID`) REFERENCES `DBS` (`DB_ID`), + CONSTRAINT `TBLS_FK3` FOREIGN KEY (`LINK_TARGET_ID`) REFERENCES `TBLS` (`TBL_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; http://git-wip-us.apache.org/repos/asf/hive/blob/dc72c873/metastore/scripts/upgrade/mysql/hive-schema-1.3.0.mysql.sql ---------------------------------------------------------------------- diff --git a/metastore/scripts/upgrade/mysql/hive-schema-1.3.0.mysql.sql b/metastore/scripts/upgrade/mysql/hive-schema-1.3.0.mysql.sql index 71de138..19ae264 100644 --- a/metastore/scripts/upgrade/mysql/hive-schema-1.3.0.mysql.sql +++ b/metastore/scripts/upgrade/mysql/hive-schema-1.3.0.mysql.sql @@ -211,12 +211,15 @@ 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, + `LINK_TARGET_ID` bigint(20) DEFAULT NULL, PRIMARY KEY (`PART_ID`), UNIQUE KEY `UNIQUEPARTITION` (`PART_NAME`,`TBL_ID`), KEY `PARTITIONS_N49` (`TBL_ID`), KEY `PARTITIONS_N50` (`SD_ID`), + KEY `PARTITIONS_N51` (`LINK_TARGET_ID`) CONSTRAINT `PARTITIONS_FK1` FOREIGN KEY (`TBL_ID`) REFERENCES `TBLS` (`TBL_ID`), - CONSTRAINT `PARTITIONS_FK2` FOREIGN KEY (`SD_ID`) REFERENCES `SDS` (`SD_ID`) + CONSTRAINT `PARTITIONS_FK2` FOREIGN KEY (`SD_ID`) REFERENCES `SDS` (`SD_ID`), + CONSTRAINT `PARTITIONS_FK3` FOREIGN KEY (`LINK_TARGET_ID`) REFERENCES `PARTITIONS` (`PART_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -587,12 +590,15 @@ CREATE TABLE IF NOT EXISTS `TBLS` ( `TBL_TYPE` varchar(128) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL, `VIEW_EXPANDED_TEXT` mediumtext, `VIEW_ORIGINAL_TEXT` mediumtext, + `LINK_TARGET_ID` bigint(20) DEFAULT NULL, PRIMARY KEY (`TBL_ID`), UNIQUE KEY `UNIQUETABLE` (`TBL_NAME`,`DB_ID`), KEY `TBLS_N50` (`SD_ID`), KEY `TBLS_N49` (`DB_ID`), + KEY `TBLS_N51` (`LINK_TARGET_ID`), CONSTRAINT `TBLS_FK1` FOREIGN KEY (`SD_ID`) REFERENCES `SDS` (`SD_ID`), - CONSTRAINT `TBLS_FK2` FOREIGN KEY (`DB_ID`) REFERENCES `DBS` (`DB_ID`) + CONSTRAINT `TBLS_FK2` FOREIGN KEY (`DB_ID`) REFERENCES `DBS` (`DB_ID`), + CONSTRAINT `TBLS_FK3` FOREIGN KEY (`LINK_TARGET_ID`) REFERENCES `TBLS` (`TBL_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; http://git-wip-us.apache.org/repos/asf/hive/blob/dc72c873/metastore/scripts/upgrade/mysql/upgrade-1.1.0-to-1.2.0.mysql.sql ---------------------------------------------------------------------- diff --git a/metastore/scripts/upgrade/mysql/upgrade-1.1.0-to-1.2.0.mysql.sql b/metastore/scripts/upgrade/mysql/upgrade-1.1.0-to-1.2.0.mysql.sql index e15c758..406504b 100644 --- a/metastore/scripts/upgrade/mysql/upgrade-1.1.0-to-1.2.0.mysql.sql +++ b/metastore/scripts/upgrade/mysql/upgrade-1.1.0-to-1.2.0.mysql.sql @@ -1,5 +1,5 @@ SELECT 'Upgrading MetaStore schema from 1.1.0 to 1.2.0' AS ' '; -SOURCE 021-HIVE-7018.mysql.sql; + UPDATE VERSION SET SCHEMA_VERSION='1.2.0', VERSION_COMMENT='Hive release version 1.2.0' where VER_ID=1; SELECT 'Finished upgrading MetaStore schema from 1.1.0 to 1.2.0' AS ' ';