FAQ
Author: xuefu
Date: Fri Mar 20 18:10:01 2015
New Revision: 1668108

URL: http://svn.apache.org/r1668108
Log:
HIVE-7018: Table and Partition tables have column LINK_TARGET_ID in Mysql scripts but not others (Yongzhi via Xuefu)

Added:
     hive/trunk/metastore/scripts/upgrade/mysql/021-HIVE-7018.mysql.sql
Modified:
     hive/trunk/metastore/scripts/upgrade/mysql/hive-schema-1.2.0.mysql.sql
     hive/trunk/metastore/scripts/upgrade/mysql/upgrade-1.1.0-to-1.2.0.mysql.sql

Added: hive/trunk/metastore/scripts/upgrade/mysql/021-HIVE-7018.mysql.sql
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/mysql/021-HIVE-7018.mysql.sql?rev=1668108&view=auto
==============================================================================
--- hive/trunk/metastore/scripts/upgrade/mysql/021-HIVE-7018.mysql.sql (added)
+++ hive/trunk/metastore/scripts/upgrade/mysql/021-HIVE-7018.mysql.sql Fri Mar 20 18:10:01 2015
@@ -0,0 +1,53 @@
+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

Modified: hive/trunk/metastore/scripts/upgrade/mysql/hive-schema-1.2.0.mysql.sql
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/mysql/hive-schema-1.2.0.mysql.sql?rev=1668108&r1=1668107&r2=1668108&view=diff
==============================================================================
--- hive/trunk/metastore/scripts/upgrade/mysql/hive-schema-1.2.0.mysql.sql (original)
+++ hive/trunk/metastore/scripts/upgrade/mysql/hive-schema-1.2.0.mysql.sql Fri Mar 20 18:10:01 2015
@@ -211,15 +211,12 @@ 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_FK3` FOREIGN KEY (`LINK_TARGET_ID`) REFERENCES `PARTITIONS` (`PART_ID`)
+ CONSTRAINT `PARTITIONS_FK2` FOREIGN KEY (`SD_ID`) REFERENCES `SDS` (`SD_ID`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  /*!40101 SET character_set_client = @saved_cs_client */;

@@ -590,15 +587,12 @@ 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_FK3` FOREIGN KEY (`LINK_TARGET_ID`) REFERENCES `TBLS` (`TBL_ID`)
+ CONSTRAINT `TBLS_FK2` FOREIGN KEY (`DB_ID`) REFERENCES `DBS` (`DB_ID`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  /*!40101 SET character_set_client = @saved_cs_client */;


Modified: hive/trunk/metastore/scripts/upgrade/mysql/upgrade-1.1.0-to-1.2.0.mysql.sql
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/mysql/upgrade-1.1.0-to-1.2.0.mysql.sql?rev=1668108&r1=1668107&r2=1668108&view=diff
==============================================================================
--- hive/trunk/metastore/scripts/upgrade/mysql/upgrade-1.1.0-to-1.2.0.mysql.sql (original)
+++ hive/trunk/metastore/scripts/upgrade/mysql/upgrade-1.1.0-to-1.2.0.mysql.sql Fri Mar 20 18:10:01 2015
@@ -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 ' ';

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedMar 20, '15 at 6:10p
activeMar 20, '15 at 6:10p
posts1
users1
websitehive.apache.org

1 user in discussion

Xuefu: 1 post

People

Translate

site design / logo © 2021 Grokbase