Author: cws Date: Fri Jan 3 01:50:29 2014 New Revision: 1554993 URL: http://svn.apache.org/r1554993 Log: HIVE-5911: Recent change to schema upgrade scripts breaks file naming conventions (Sergey Shelukhin via cws)
Added: hive/trunk/metastore/scripts/upgrade/mysql/015-HIVE-5700.mysql.sql hive/trunk/metastore/scripts/upgrade/oracle/015-HIVE-5700.oracle.sql hive/trunk/metastore/scripts/upgrade/postgres/015-HIVE-5700.postgres.sql Modified: hive/trunk/metastore/scripts/upgrade/mysql/014-HIVE-3764.mysql.sql hive/trunk/metastore/scripts/upgrade/mysql/upgrade-0.12.0-to-0.13.0.mysql.sql hive/trunk/metastore/scripts/upgrade/oracle/upgrade-0.12.0-to-0.13.0.oracle.sql hive/trunk/metastore/scripts/upgrade/postgres/011-HIVE-3649.postgres.sql hive/trunk/metastore/scripts/upgrade/postgres/014-HIVE-3764.postgres.sql hive/trunk/metastore/scripts/upgrade/postgres/upgrade-0.12.0-to-0.13.0.postgres.sql Modified: hive/trunk/metastore/scripts/upgrade/mysql/014-HIVE-3764.mysql.sql URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/mysql/014-HIVE-3764.mysql.sql?rev=1554993&r1=1554992&r2=1554993&view=diff ============================================================================== --- hive/trunk/metastore/scripts/upgrade/mysql/014-HIVE-3764.mysql.sql (original) +++ hive/trunk/metastore/scripts/upgrade/mysql/014-HIVE-3764.mysql.sql Fri Jan 3 01:50:29 2014 @@ -1,3 +1,5 @@ +SELECT '< HIVE-3764 Support metastore version consistency check >' AS ' '; + -- Table structure for VERSION CREATE TABLE IF NOT EXISTS `VERSION` ( `VER_ID` BIGINT NOT NULL, Added: hive/trunk/metastore/scripts/upgrade/mysql/015-HIVE-5700.mysql.sql URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/mysql/015-HIVE-5700.mysql.sql?rev=1554993&view=auto ============================================================================== --- hive/trunk/metastore/scripts/upgrade/mysql/015-HIVE-5700.mysql.sql (added) +++ hive/trunk/metastore/scripts/upgrade/mysql/015-HIVE-5700.mysql.sql Fri Jan 3 01:50:29 2014 @@ -0,0 +1,11 @@ +SELECT '< HIVE-5700 enforce single date format for partition column storage >' AS ' '; + +-- Normalize the date partition column values as best we can. No schema changes. + + +UPDATE PARTITION_KEY_VALS + INNER JOIN PARTITIONS ON PARTITION_KEY_VALS.PART_ID = PARTITIONS.PART_ID + INNER JOIN PARTITION_KEYS ON PARTITION_KEYS.TBL_ID = PARTITIONS.TBL_ID + AND PARTITION_KEYS.INTEGER_IDX = PARTITION_KEY_VALS.INTEGER_IDX + AND PARTITION_KEYS.PKEY_TYPE = 'date' +SET PART_KEY_VAL = IFNULL(DATE_FORMAT(cast(PART_KEY_VAL as date),'%Y-%m-%d'), PART_KEY_VAL); Modified: hive/trunk/metastore/scripts/upgrade/mysql/upgrade-0.12.0-to-0.13.0.mysql.sql URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/mysql/upgrade-0.12.0-to-0.13.0.mysql.sql?rev=1554993&r1=1554992&r2=1554993&view=diff ============================================================================== --- hive/trunk/metastore/scripts/upgrade/mysql/upgrade-0.12.0-to-0.13.0.mysql.sql (original) +++ hive/trunk/metastore/scripts/upgrade/mysql/upgrade-0.12.0-to-0.13.0.mysql.sql Fri Jan 3 01:50:29 2014 @@ -1,11 +1,6 @@ SELECT 'Upgrading MetaStore schema from 0.12.0 to 0.13.0' AS ' '; -UPDATE PARTITION_KEY_VALS - INNER JOIN PARTITIONS ON PARTITION_KEY_VALS.PART_ID = PARTITIONS.PART_ID - INNER JOIN PARTITION_KEYS ON PARTITION_KEYS.TBL_ID = PARTITIONS.TBL_ID - AND PARTITION_KEYS.INTEGER_IDX = PARTITION_KEY_VALS.INTEGER_IDX - AND PARTITION_KEYS.PKEY_TYPE = 'date' -SET PART_KEY_VAL = IFNULL(DATE_FORMAT(cast(PART_KEY_VAL as date),'%Y-%m-%d'), PART_KEY_VAL); +SOURCE 015-HIVE-5700.mysql.sql; UPDATE VERSION SET SCHEMA_VERSION='0.13.0', VERSION_COMMENT='Hive release version 0.13.0' where VER_ID=1; SELECT 'Finished upgrading MetaStore schema from 0.12.0 to 0.13.0' AS ' '; Added: hive/trunk/metastore/scripts/upgrade/oracle/015-HIVE-5700.oracle.sql URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/oracle/015-HIVE-5700.oracle.sql?rev=1554993&view=auto ============================================================================== --- hive/trunk/metastore/scripts/upgrade/oracle/015-HIVE-5700.oracle.sql (added) +++ hive/trunk/metastore/scripts/upgrade/oracle/015-HIVE-5700.oracle.sql Fri Jan 3 01:50:29 2014 @@ -0,0 +1,26 @@ +-- Normalize the date partition column values as best we can. No schema changes. + +CREATE FUNCTION hive13_to_date(date_str IN VARCHAR2) +RETURN DATE +IS dt DATE; +BEGIN + dt := TO_DATE(date_str, 'YYYY-MM-DD'); + RETURN dt; +EXCEPTION + WHEN others THEN RETURN null; +END; +/ + +MERGE INTO PARTITION_KEY_VALS +USING ( + SELECT SRC.PART_ID as IPART_ID, SRC.INTEGER_IDX as IINTEGER_IDX, + NVL(TO_CHAR(hive13_to_date(PART_KEY_VAL),'YYYY-MM-DD'), PART_KEY_VAL) as NORM + FROM PARTITION_KEY_VALS SRC + INNER JOIN PARTITIONS ON SRC.PART_ID = PARTITIONS.PART_ID + INNER JOIN PARTITION_KEYS ON PARTITION_KEYS.TBL_ID = PARTITIONS.TBL_ID + AND PARTITION_KEYS.INTEGER_IDX = SRC.INTEGER_IDX AND PARTITION_KEYS.PKEY_TYPE = 'date' +) ON (IPART_ID = PARTITION_KEY_VALS.PART_ID AND IINTEGER_IDX = PARTITION_KEY_VALS.INTEGER_IDX) +WHEN MATCHED THEN UPDATE SET PART_KEY_VAL = NORM; + +DROP FUNCTION hive13_to_date; + Modified: hive/trunk/metastore/scripts/upgrade/oracle/upgrade-0.12.0-to-0.13.0.oracle.sql URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/oracle/upgrade-0.12.0-to-0.13.0.oracle.sql?rev=1554993&r1=1554992&r2=1554993&view=diff ============================================================================== --- hive/trunk/metastore/scripts/upgrade/oracle/upgrade-0.12.0-to-0.13.0.oracle.sql (original) +++ hive/trunk/metastore/scripts/upgrade/oracle/upgrade-0.12.0-to-0.13.0.oracle.sql Fri Jan 3 01:50:29 2014 @@ -1,28 +1,6 @@ SELECT 'Upgrading MetaStore schema from 0.12.0 to 0.13.0' AS Status from dual; -CREATE FUNCTION hive13_to_date(date_str IN VARCHAR2) -RETURN DATE -IS dt DATE; -BEGIN - dt := TO_DATE(date_str, 'YYYY-MM-DD'); - RETURN dt; -EXCEPTION - WHEN others THEN RETURN null; -END; -/ - -MERGE INTO PARTITION_KEY_VALS -USING ( - SELECT SRC.PART_ID as IPART_ID, SRC.INTEGER_IDX as IINTEGER_IDX, - NVL(TO_CHAR(hive13_to_date(PART_KEY_VAL),'YYYY-MM-DD'), PART_KEY_VAL) as NORM - FROM PARTITION_KEY_VALS SRC - INNER JOIN PARTITIONS ON SRC.PART_ID = PARTITIONS.PART_ID - INNER JOIN PARTITION_KEYS ON PARTITION_KEYS.TBL_ID = PARTITIONS.TBL_ID - AND PARTITION_KEYS.INTEGER_IDX = SRC.INTEGER_IDX AND PARTITION_KEYS.PKEY_TYPE = 'date' -) ON (IPART_ID = PARTITION_KEY_VALS.PART_ID AND IINTEGER_IDX = PARTITION_KEY_VALS.INTEGER_IDX) -WHEN MATCHED THEN UPDATE SET PART_KEY_VAL = NORM; - -DROP FUNCTION hive13_to_date; +@015-HIVE-5700.oracle.sql; UPDATE VERSION SET SCHEMA_VERSION='0.13.0', VERSION_COMMENT='Hive release version 0.13.0' where VER_ID=1; SELECT 'Finished upgrading MetaStore schema from 0.12.0 to 0.13.0' AS Status from dual; Modified: hive/trunk/metastore/scripts/upgrade/postgres/011-HIVE-3649.postgres.sql URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/postgres/011-HIVE-3649.postgres.sql?rev=1554993&r1=1554992&r2=1554993&view=diff ============================================================================== --- hive/trunk/metastore/scripts/upgrade/postgres/011-HIVE-3649.postgres.sql (original) +++ hive/trunk/metastore/scripts/upgrade/postgres/011-HIVE-3649.postgres.sql Fri Jan 3 01:50:29 2014 @@ -1,3 +1,5 @@ +SELECT '< HIVE-3649 Hive List Bucketing - enhance DDL to specify list bucketing table >'; + -- Add new not null column into SDS table in three steps -- Step 1: Add the column allowing null Modified: hive/trunk/metastore/scripts/upgrade/postgres/014-HIVE-3764.postgres.sql URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/postgres/014-HIVE-3764.postgres.sql?rev=1554993&r1=1554992&r2=1554993&view=diff ============================================================================== --- hive/trunk/metastore/scripts/upgrade/postgres/014-HIVE-3764.postgres.sql (original) +++ hive/trunk/metastore/scripts/upgrade/postgres/014-HIVE-3764.postgres.sql Fri Jan 3 01:50:29 2014 @@ -1,3 +1,5 @@ +SELECT '< HIVE-3764 Support metastore version consistency check >'; + -- -- Table structure for VERSION -- Added: hive/trunk/metastore/scripts/upgrade/postgres/015-HIVE-5700.postgres.sql URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/postgres/015-HIVE-5700.postgres.sql?rev=1554993&view=auto ============================================================================== --- hive/trunk/metastore/scripts/upgrade/postgres/015-HIVE-5700.postgres.sql (added) +++ hive/trunk/metastore/scripts/upgrade/postgres/015-HIVE-5700.postgres.sql Fri Jan 3 01:50:29 2014 @@ -0,0 +1,24 @@ +SELECT '< HIVE-5700 enforce single date format for partition column storage >'; + +-- Normalize the date partition column values as best we can. No schema changes. + +CREATE FUNCTION hive13_to_date(date_str text) RETURNS DATE AS $$ +DECLARE dt DATE; +BEGIN + dt := date_str::DATE; + RETURN dt; +EXCEPTION + WHEN others THEN RETURN null; +END; +$$ LANGUAGE plpgsql; + +UPDATE "PARTITION_KEY_VALS" +SET "PART_KEY_VAL" = COALESCE(TO_CHAR(hive13_to_date(src."PART_KEY_VAL"),'YYYY-MM-DD'), src."PART_KEY_VAL") +FROM "PARTITION_KEY_VALS" src + INNER JOIN "PARTITIONS" ON src."PART_ID" = "PARTITIONS"."PART_ID" + INNER JOIN "PARTITION_KEYS" ON "PARTITION_KEYS"."TBL_ID" = "PARTITIONS"."TBL_ID" + AND "PARTITION_KEYS"."INTEGER_IDX" = src."INTEGER_IDX" + AND "PARTITION_KEYS"."PKEY_TYPE" = 'date'; + +DROP FUNCTION hive13_to_date(date_str text); + Modified: hive/trunk/metastore/scripts/upgrade/postgres/upgrade-0.12.0-to-0.13.0.postgres.sql URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/postgres/upgrade-0.12.0-to-0.13.0.postgres.sql?rev=1554993&r1=1554992&r2=1554993&view=diff ============================================================================== --- hive/trunk/metastore/scripts/upgrade/postgres/upgrade-0.12.0-to-0.13.0.postgres.sql (original) +++ hive/trunk/metastore/scripts/upgrade/postgres/upgrade-0.12.0-to-0.13.0.postgres.sql Fri Jan 3 01:50:29 2014 @@ -1,24 +1,6 @@ SELECT 'Upgrading MetaStore schema from 0.12.0 to 0.13.0'; -CREATE FUNCTION hive13_to_date(date_str text) RETURNS DATE AS $$ -DECLARE dt DATE; -BEGIN - dt := date_str::DATE; - RETURN dt; -EXCEPTION - WHEN others THEN RETURN null; -END; -$$ LANGUAGE plpgsql; - -UPDATE "PARTITION_KEY_VALS" -SET "PART_KEY_VAL" = COALESCE(TO_CHAR(hive13_to_date(src."PART_KEY_VAL"),'YYYY-MM-DD'), src."PART_KEY_VAL") -FROM "PARTITION_KEY_VALS" src - INNER JOIN "PARTITIONS" ON src."PART_ID" = "PARTITIONS"."PART_ID" - INNER JOIN "PARTITION_KEYS" ON "PARTITION_KEYS"."TBL_ID" = "PARTITIONS"."TBL_ID" - AND "PARTITION_KEYS"."INTEGER_IDX" = src."INTEGER_IDX" - AND "PARTITION_KEYS"."PKEY_TYPE" = 'date'; - -DROP FUNCTION hive13_to_date(date_str text); +\i 015-HIVE-5700.postgres.sql; UPDATE "VERSION" SET "SCHEMA_VERSION"='0.13.0', "VERSION_COMMENT"='Hive release version 0.13.0' where "VER_ID"=1; SELECT 'Finished upgrading MetaStore schema from 0.12.0 to 0.13.0';