ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject [1/2] git commit: AMBARI-6291. Hive Metastore scripts on Oracle for Ambari needs to be updated (aonishuk)
Date Thu, 26 Jun 2014 19:07:34 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.6.1 4bc10a43e -> 7f78cdf74
  refs/heads/trunk a66d9f252 -> c188b96b3


AMBARI-6291. Hive Metastore scripts on Oracle for Ambari needs to be updated (aonishuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c188b96b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c188b96b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c188b96b

Branch: refs/heads/trunk
Commit: c188b96b303cb96613139828fabdfb00a87acf77
Parents: a66d9f2
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Thu Jun 26 22:07:21 2014 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Thu Jun 26 22:07:21 2014 +0300

----------------------------------------------------------------------
 .../HIVE/etc/hive-schema-0.13.0.oracle.sql      |  30 ++--
 .../etc/upgrade-0.12.0-to-0.13.0.oracle.sql     | 165 +++++++++++++++++++
 .../services/HIVE/etc/upgrade-0.13.0.oracle.sql |  38 +++++
 .../HIVE/etc/hive-schema-0.13.0.oracle.sql      |  30 ++--
 .../etc/upgrade-0.12.0-to-0.13.0.oracle.sql     | 165 +++++++++++++++++++
 .../services/HIVE/etc/upgrade-0.13.0.oracle.sql |  38 +++++
 6 files changed, 436 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c188b96b/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/HIVE/etc/hive-schema-0.13.0.oracle.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/HIVE/etc/hive-schema-0.13.0.oracle.sql
b/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/HIVE/etc/hive-schema-0.13.0.oracle.sql
index f819187..6bd8df9 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/HIVE/etc/hive-schema-0.13.0.oracle.sql
+++ b/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/HIVE/etc/hive-schema-0.13.0.oracle.sql
@@ -760,44 +760,44 @@ CREATE INDEX FUNC_RU_N49 ON FUNC_RU (FUNC_ID);
 -- -----------------------------------------------------------------------------------------------------------------------------------------------
 
 CREATE TABLE TXNS (
-  TXN_ID NUMBER(10) PRIMARY KEY,
+  TXN_ID NUMBER(19) PRIMARY KEY,
   TXN_STATE char(1) NOT NULL,
-  TXN_STARTED NUMBER(10) NOT NULL,
-  TXN_LAST_HEARTBEAT NUMBER(10) NOT NULL,
+  TXN_STARTED NUMBER(19) NOT NULL,
+  TXN_LAST_HEARTBEAT NUMBER(19) NOT NULL,
   TXN_USER varchar(128) NOT NULL,
   TXN_HOST varchar(128) NOT NULL
 );
 
 CREATE TABLE TXN_COMPONENTS (
-  TC_TXNID NUMBER(10) REFERENCES TXNS (TXN_ID),
+  TC_TXNID NUMBER(19) REFERENCES TXNS (TXN_ID),
   TC_DATABASE VARCHAR2(128) NOT NULL,
   TC_TABLE VARCHAR2(128),
   TC_PARTITION VARCHAR2(767) NULL
 );
 
 CREATE TABLE COMPLETED_TXN_COMPONENTS (
-  CTC_TXNID NUMBER(10),
+  CTC_TXNID NUMBER(19),
   CTC_DATABASE varchar(128) NOT NULL,
   CTC_TABLE varchar(128),
   CTC_PARTITION varchar(767)
 );
 
 CREATE TABLE NEXT_TXN_ID (
-  NTXN_NEXT NUMBER(10) NOT NULL
+  NTXN_NEXT NUMBER(19) NOT NULL
 );
 INSERT INTO NEXT_TXN_ID VALUES(1);
 
 CREATE TABLE HIVE_LOCKS (
-  HL_LOCK_EXT_ID NUMBER(10) NOT NULL,
-  HL_LOCK_INT_ID NUMBER(10) NOT NULL,
-  HL_TXNID NUMBER(10),
+  HL_LOCK_EXT_ID NUMBER(19) NOT NULL,
+  HL_LOCK_INT_ID NUMBER(19) NOT NULL,
+  HL_TXNID NUMBER(19),
   HL_DB VARCHAR2(128) NOT NULL,
   HL_TABLE VARCHAR2(128),
   HL_PARTITION VARCHAR2(767),
   HL_LOCK_STATE CHAR(1) NOT NULL,
   HL_LOCK_TYPE CHAR(1) NOT NULL,
-  HL_LAST_HEARTBEAT NUMBER(10) NOT NULL,
-  HL_ACQUIRED_AT NUMBER(10),
+  HL_LAST_HEARTBEAT NUMBER(19) NOT NULL,
+  HL_ACQUIRED_AT NUMBER(19),
   HL_USER varchar(128) NOT NULL,
   HL_HOST varchar(128) NOT NULL,
   PRIMARY KEY(HL_LOCK_EXT_ID, HL_LOCK_INT_ID)
@@ -806,24 +806,24 @@ CREATE TABLE HIVE_LOCKS (
 CREATE INDEX HL_TXNID_INDEX ON HIVE_LOCKS (HL_TXNID);
 
 CREATE TABLE NEXT_LOCK_ID (
-  NL_NEXT NUMBER(10) NOT NULL
+  NL_NEXT NUMBER(19) NOT NULL
 );
 INSERT INTO NEXT_LOCK_ID VALUES(1);
 
 CREATE TABLE COMPACTION_QUEUE (
-  CQ_ID NUMBER(10) PRIMARY KEY,
+  CQ_ID NUMBER(19) PRIMARY KEY,
   CQ_DATABASE varchar(128) NOT NULL,
   CQ_TABLE varchar(128) NOT NULL,
   CQ_PARTITION varchar(767),
   CQ_STATE char(1) NOT NULL,
   CQ_TYPE char(1) NOT NULL,
   CQ_WORKER_ID varchar(128),
-  CQ_START NUMBER(10),
+  CQ_START NUMBER(19),
   CQ_RUN_AS varchar(128)
 );
 
 CREATE TABLE NEXT_COMPACTION_QUEUE_ID (
-  NCQ_NEXT NUMBER(10) NOT NULL
+  NCQ_NEXT NUMBER(19) NOT NULL
 );
 INSERT INTO NEXT_COMPACTION_QUEUE_ID VALUES(1);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c188b96b/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/HIVE/etc/upgrade-0.12.0-to-0.13.0.oracle.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/HIVE/etc/upgrade-0.12.0-to-0.13.0.oracle.sql
b/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/HIVE/etc/upgrade-0.12.0-to-0.13.0.oracle.sql
new file mode 100644
index 0000000..d08b985
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/HIVE/etc/upgrade-0.12.0-to-0.13.0.oracle.sql
@@ -0,0 +1,165 @@
+SELECT 'Upgrading MetaStore schema from 0.12.0 to 0.13.0' AS Status from dual;
+
+-- 15-HIVE-5700.oracle.sql
+-- 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;
+
+-- 16-HIVE-6386.oracle.sql
+ALTER TABLE DBS ADD OWNER_NAME VARCHAR2(128);
+ALTER TABLE DBS ADD OWNER_TYPE VARCHAR2(10);
+
+-- 17-HIVE-6458.oracle.sql
+CREATE TABLE FUNCS (
+  FUNC_ID NUMBER NOT NULL,
+  CLASS_NAME VARCHAR2(4000),
+  CREATE_TIME NUMBER(10) NOT NULL,
+  DB_ID NUMBER,
+  FUNC_NAME VARCHAR2(128),
+  FUNC_TYPE NUMBER(10) NOT NULL,
+  OWNER_NAME VARCHAR2(128),
+  OWNER_TYPE VARCHAR2(10)
+);
+
+ALTER TABLE FUNCS ADD CONSTRAINT FUNCS_PK PRIMARY KEY (FUNC_ID);
+ALTER TABLE FUNCS ADD CONSTRAINT FUNCS_FK1 FOREIGN KEY (DB_ID) REFERENCES DBS (DB_ID) INITIALLY
DEFERRED;
+CREATE UNIQUE INDEX UNIQUEFUNCTION ON FUNCS (FUNC_NAME, DB_ID);
+CREATE INDEX FUNCS_N49 ON FUNCS (DB_ID);
+
+CREATE TABLE FUNC_RU (
+  FUNC_ID NUMBER NOT NULL,
+  RESOURCE_TYPE NUMBER(10) NOT NULL,
+  RESOURCE_URI VARCHAR2(4000),
+  INTEGER_IDX NUMBER(10) NOT NULL
+);
+
+ALTER TABLE FUNC_RU ADD CONSTRAINT FUNC_RU_PK PRIMARY KEY (FUNC_ID, INTEGER_IDX);
+ALTER TABLE FUNC_RU ADD CONSTRAINT FUNC_RU_FK1 FOREIGN KEY (FUNC_ID) REFERENCES FUNCS (FUNC_ID)
INITIALLY DEFERRED;
+CREATE INDEX FUNC_RU_N49 ON FUNC_RU (FUNC_ID);
+
+-- 18-HIVE-6757.oracle.sql
+UPDATE SDS
+  SET INPUT_FORMAT = 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
+WHERE
+  INPUT_FORMAT= 'parquet.hive.DeprecatedParquetInputFormat' or
+  INPUT_FORMAT = 'parquet.hive.MapredParquetInputFormat'
+;
+
+UPDATE SDS
+  SET OUTPUT_FORMAT = 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
+WHERE
+  OUTPUT_FORMAT = 'parquet.hive.DeprecatedParquetOutputFormat'  or
+  OUTPUT_FORMAT = 'parquet.hive.MapredParquetOutputFormat'
+;
+
+UPDATE SERDES
+  SET SLIB='org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
+WHERE
+  SLIB = 'parquet.hive.serde.ParquetHiveSerDe'
+;
+
+-- hive-txn-schema-0.13.0.oracle.sql
+
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the License); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an AS IS BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+--
+-- Tables for transaction management
+-- 
+
+CREATE TABLE TXNS (
+  TXN_ID NUMBER(19) PRIMARY KEY,
+  TXN_STATE char(1) NOT NULL,
+  TXN_STARTED NUMBER(19) NOT NULL,
+  TXN_LAST_HEARTBEAT NUMBER(19) NOT NULL,
+  TXN_USER varchar(128) NOT NULL,
+  TXN_HOST varchar(128) NOT NULL
+);
+
+CREATE TABLE TXN_COMPONENTS (
+  TC_TXNID NUMBER(19) REFERENCES TXNS (TXN_ID),
+  TC_DATABASE VARCHAR2(128) NOT NULL,
+  TC_TABLE VARCHAR2(128),
+  TC_PARTITION VARCHAR2(767) NULL
+);
+
+CREATE TABLE COMPLETED_TXN_COMPONENTS (
+  CTC_TXNID NUMBER(19),
+  CTC_DATABASE varchar(128) NOT NULL,
+  CTC_TABLE varchar(128),
+  CTC_PARTITION varchar(767)
+);
+
+CREATE TABLE NEXT_TXN_ID (
+  NTXN_NEXT NUMBER(19) NOT NULL
+);
+INSERT INTO NEXT_TXN_ID VALUES(1);
+
+CREATE TABLE HIVE_LOCKS (
+  HL_LOCK_EXT_ID NUMBER(19) NOT NULL,
+  HL_LOCK_INT_ID NUMBER(19) NOT NULL,
+  HL_TXNID NUMBER(19),
+  HL_DB VARCHAR2(128) NOT NULL,
+  HL_TABLE VARCHAR2(128),
+  HL_PARTITION VARCHAR2(767),
+  HL_LOCK_STATE CHAR(1) NOT NULL,
+  HL_LOCK_TYPE CHAR(1) NOT NULL,
+  HL_LAST_HEARTBEAT NUMBER(19) NOT NULL,
+  HL_ACQUIRED_AT NUMBER(19),
+  HL_USER varchar(128) NOT NULL,
+  HL_HOST varchar(128) NOT NULL,
+  PRIMARY KEY(HL_LOCK_EXT_ID, HL_LOCK_INT_ID)
+); 
+
+CREATE INDEX HL_TXNID_INDEX ON HIVE_LOCKS (HL_TXNID);
+
+CREATE TABLE NEXT_LOCK_ID (
+  NL_NEXT NUMBER(19) NOT NULL
+);
+INSERT INTO NEXT_LOCK_ID VALUES(1);
+
+CREATE TABLE COMPACTION_QUEUE (
+  CQ_ID NUMBER(19) PRIMARY KEY,
+  CQ_DATABASE varchar(128) NOT NULL,
+  CQ_TABLE varchar(128) NOT NULL,
+  CQ_PARTITION varchar(767),
+  CQ_STATE char(1) NOT NULL,
+  CQ_TYPE char(1) NOT NULL,
+  CQ_WORKER_ID varchar(128),
+  CQ_START NUMBER(19),
+  CQ_RUN_AS varchar(128)
+);
+
+CREATE TABLE NEXT_COMPACTION_QUEUE_ID (
+  NCQ_NEXT NUMBER(19) NOT NULL
+);
+INSERT INTO NEXT_COMPACTION_QUEUE_ID VALUES(1);
+
+
+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;

http://git-wip-us.apache.org/repos/asf/ambari/blob/c188b96b/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/HIVE/etc/upgrade-0.13.0.oracle.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/HIVE/etc/upgrade-0.13.0.oracle.sql
b/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/HIVE/etc/upgrade-0.13.0.oracle.sql
new file mode 100644
index 0000000..b34f406
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/HIVE/etc/upgrade-0.13.0.oracle.sql
@@ -0,0 +1,38 @@
+ALTER TABLE TXNS MODIFY (
+  TXN_ID NUMBER(19),
+  TXN_STARTED NUMBER(19),
+  TXN_LAST_HEARTBEAT NUMBER(19)
+);
+
+ALTER TABLE TXN_COMPONENTS MODIFY (
+  TC_TXNID NUMBER(19)
+);
+
+ALTER TABLE COMPLETED_TXN_COMPONENTS MODIFY (
+  CTC_TXNID NUMBER(19)
+);
+
+ALTER TABLE NEXT_TXN_ID MODIFY (
+  NTXN_NEXT NUMBER(19)
+);
+
+ALTER TABLE HIVE_LOCKS MODIFY (
+  HL_LOCK_EXT_ID NUMBER(19),
+  HL_LOCK_INT_ID NUMBER(19),
+  HL_TXNID NUMBER(19),
+  HL_LAST_HEARTBEAT NUMBER(19),
+  HL_ACQUIRED_AT NUMBER(19)
+);
+
+ALTER TABLE NEXT_LOCK_ID MODIFY (
+  NL_NEXT NUMBER(19)
+);
+
+ALTER TABLE COMPACTION_QUEUE MODIFY (
+  CQ_ID NUMBER(19),
+  CQ_START NUMBER(19)
+);
+
+ALTER TABLE NEXT_COMPACTION_QUEUE_ID MODIFY (
+  NCQ_NEXT NUMBER(19)
+);

http://git-wip-us.apache.org/repos/asf/ambari/blob/c188b96b/ambari-server/src/main/resources/stacks/HDP/2.1/services/HIVE/etc/hive-schema-0.13.0.oracle.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.1/services/HIVE/etc/hive-schema-0.13.0.oracle.sql
b/ambari-server/src/main/resources/stacks/HDP/2.1/services/HIVE/etc/hive-schema-0.13.0.oracle.sql
index f819187..6bd8df9 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.1/services/HIVE/etc/hive-schema-0.13.0.oracle.sql
+++ b/ambari-server/src/main/resources/stacks/HDP/2.1/services/HIVE/etc/hive-schema-0.13.0.oracle.sql
@@ -760,44 +760,44 @@ CREATE INDEX FUNC_RU_N49 ON FUNC_RU (FUNC_ID);
 -- -----------------------------------------------------------------------------------------------------------------------------------------------
 
 CREATE TABLE TXNS (
-  TXN_ID NUMBER(10) PRIMARY KEY,
+  TXN_ID NUMBER(19) PRIMARY KEY,
   TXN_STATE char(1) NOT NULL,
-  TXN_STARTED NUMBER(10) NOT NULL,
-  TXN_LAST_HEARTBEAT NUMBER(10) NOT NULL,
+  TXN_STARTED NUMBER(19) NOT NULL,
+  TXN_LAST_HEARTBEAT NUMBER(19) NOT NULL,
   TXN_USER varchar(128) NOT NULL,
   TXN_HOST varchar(128) NOT NULL
 );
 
 CREATE TABLE TXN_COMPONENTS (
-  TC_TXNID NUMBER(10) REFERENCES TXNS (TXN_ID),
+  TC_TXNID NUMBER(19) REFERENCES TXNS (TXN_ID),
   TC_DATABASE VARCHAR2(128) NOT NULL,
   TC_TABLE VARCHAR2(128),
   TC_PARTITION VARCHAR2(767) NULL
 );
 
 CREATE TABLE COMPLETED_TXN_COMPONENTS (
-  CTC_TXNID NUMBER(10),
+  CTC_TXNID NUMBER(19),
   CTC_DATABASE varchar(128) NOT NULL,
   CTC_TABLE varchar(128),
   CTC_PARTITION varchar(767)
 );
 
 CREATE TABLE NEXT_TXN_ID (
-  NTXN_NEXT NUMBER(10) NOT NULL
+  NTXN_NEXT NUMBER(19) NOT NULL
 );
 INSERT INTO NEXT_TXN_ID VALUES(1);
 
 CREATE TABLE HIVE_LOCKS (
-  HL_LOCK_EXT_ID NUMBER(10) NOT NULL,
-  HL_LOCK_INT_ID NUMBER(10) NOT NULL,
-  HL_TXNID NUMBER(10),
+  HL_LOCK_EXT_ID NUMBER(19) NOT NULL,
+  HL_LOCK_INT_ID NUMBER(19) NOT NULL,
+  HL_TXNID NUMBER(19),
   HL_DB VARCHAR2(128) NOT NULL,
   HL_TABLE VARCHAR2(128),
   HL_PARTITION VARCHAR2(767),
   HL_LOCK_STATE CHAR(1) NOT NULL,
   HL_LOCK_TYPE CHAR(1) NOT NULL,
-  HL_LAST_HEARTBEAT NUMBER(10) NOT NULL,
-  HL_ACQUIRED_AT NUMBER(10),
+  HL_LAST_HEARTBEAT NUMBER(19) NOT NULL,
+  HL_ACQUIRED_AT NUMBER(19),
   HL_USER varchar(128) NOT NULL,
   HL_HOST varchar(128) NOT NULL,
   PRIMARY KEY(HL_LOCK_EXT_ID, HL_LOCK_INT_ID)
@@ -806,24 +806,24 @@ CREATE TABLE HIVE_LOCKS (
 CREATE INDEX HL_TXNID_INDEX ON HIVE_LOCKS (HL_TXNID);
 
 CREATE TABLE NEXT_LOCK_ID (
-  NL_NEXT NUMBER(10) NOT NULL
+  NL_NEXT NUMBER(19) NOT NULL
 );
 INSERT INTO NEXT_LOCK_ID VALUES(1);
 
 CREATE TABLE COMPACTION_QUEUE (
-  CQ_ID NUMBER(10) PRIMARY KEY,
+  CQ_ID NUMBER(19) PRIMARY KEY,
   CQ_DATABASE varchar(128) NOT NULL,
   CQ_TABLE varchar(128) NOT NULL,
   CQ_PARTITION varchar(767),
   CQ_STATE char(1) NOT NULL,
   CQ_TYPE char(1) NOT NULL,
   CQ_WORKER_ID varchar(128),
-  CQ_START NUMBER(10),
+  CQ_START NUMBER(19),
   CQ_RUN_AS varchar(128)
 );
 
 CREATE TABLE NEXT_COMPACTION_QUEUE_ID (
-  NCQ_NEXT NUMBER(10) NOT NULL
+  NCQ_NEXT NUMBER(19) NOT NULL
 );
 INSERT INTO NEXT_COMPACTION_QUEUE_ID VALUES(1);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c188b96b/ambari-server/src/main/resources/stacks/HDP/2.1/services/HIVE/etc/upgrade-0.12.0-to-0.13.0.oracle.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.1/services/HIVE/etc/upgrade-0.12.0-to-0.13.0.oracle.sql
b/ambari-server/src/main/resources/stacks/HDP/2.1/services/HIVE/etc/upgrade-0.12.0-to-0.13.0.oracle.sql
new file mode 100644
index 0000000..d08b985
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.1/services/HIVE/etc/upgrade-0.12.0-to-0.13.0.oracle.sql
@@ -0,0 +1,165 @@
+SELECT 'Upgrading MetaStore schema from 0.12.0 to 0.13.0' AS Status from dual;
+
+-- 15-HIVE-5700.oracle.sql
+-- 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;
+
+-- 16-HIVE-6386.oracle.sql
+ALTER TABLE DBS ADD OWNER_NAME VARCHAR2(128);
+ALTER TABLE DBS ADD OWNER_TYPE VARCHAR2(10);
+
+-- 17-HIVE-6458.oracle.sql
+CREATE TABLE FUNCS (
+  FUNC_ID NUMBER NOT NULL,
+  CLASS_NAME VARCHAR2(4000),
+  CREATE_TIME NUMBER(10) NOT NULL,
+  DB_ID NUMBER,
+  FUNC_NAME VARCHAR2(128),
+  FUNC_TYPE NUMBER(10) NOT NULL,
+  OWNER_NAME VARCHAR2(128),
+  OWNER_TYPE VARCHAR2(10)
+);
+
+ALTER TABLE FUNCS ADD CONSTRAINT FUNCS_PK PRIMARY KEY (FUNC_ID);
+ALTER TABLE FUNCS ADD CONSTRAINT FUNCS_FK1 FOREIGN KEY (DB_ID) REFERENCES DBS (DB_ID) INITIALLY
DEFERRED;
+CREATE UNIQUE INDEX UNIQUEFUNCTION ON FUNCS (FUNC_NAME, DB_ID);
+CREATE INDEX FUNCS_N49 ON FUNCS (DB_ID);
+
+CREATE TABLE FUNC_RU (
+  FUNC_ID NUMBER NOT NULL,
+  RESOURCE_TYPE NUMBER(10) NOT NULL,
+  RESOURCE_URI VARCHAR2(4000),
+  INTEGER_IDX NUMBER(10) NOT NULL
+);
+
+ALTER TABLE FUNC_RU ADD CONSTRAINT FUNC_RU_PK PRIMARY KEY (FUNC_ID, INTEGER_IDX);
+ALTER TABLE FUNC_RU ADD CONSTRAINT FUNC_RU_FK1 FOREIGN KEY (FUNC_ID) REFERENCES FUNCS (FUNC_ID)
INITIALLY DEFERRED;
+CREATE INDEX FUNC_RU_N49 ON FUNC_RU (FUNC_ID);
+
+-- 18-HIVE-6757.oracle.sql
+UPDATE SDS
+  SET INPUT_FORMAT = 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
+WHERE
+  INPUT_FORMAT= 'parquet.hive.DeprecatedParquetInputFormat' or
+  INPUT_FORMAT = 'parquet.hive.MapredParquetInputFormat'
+;
+
+UPDATE SDS
+  SET OUTPUT_FORMAT = 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
+WHERE
+  OUTPUT_FORMAT = 'parquet.hive.DeprecatedParquetOutputFormat'  or
+  OUTPUT_FORMAT = 'parquet.hive.MapredParquetOutputFormat'
+;
+
+UPDATE SERDES
+  SET SLIB='org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
+WHERE
+  SLIB = 'parquet.hive.serde.ParquetHiveSerDe'
+;
+
+-- hive-txn-schema-0.13.0.oracle.sql
+
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the License); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an AS IS BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+--
+-- Tables for transaction management
+-- 
+
+CREATE TABLE TXNS (
+  TXN_ID NUMBER(19) PRIMARY KEY,
+  TXN_STATE char(1) NOT NULL,
+  TXN_STARTED NUMBER(19) NOT NULL,
+  TXN_LAST_HEARTBEAT NUMBER(19) NOT NULL,
+  TXN_USER varchar(128) NOT NULL,
+  TXN_HOST varchar(128) NOT NULL
+);
+
+CREATE TABLE TXN_COMPONENTS (
+  TC_TXNID NUMBER(19) REFERENCES TXNS (TXN_ID),
+  TC_DATABASE VARCHAR2(128) NOT NULL,
+  TC_TABLE VARCHAR2(128),
+  TC_PARTITION VARCHAR2(767) NULL
+);
+
+CREATE TABLE COMPLETED_TXN_COMPONENTS (
+  CTC_TXNID NUMBER(19),
+  CTC_DATABASE varchar(128) NOT NULL,
+  CTC_TABLE varchar(128),
+  CTC_PARTITION varchar(767)
+);
+
+CREATE TABLE NEXT_TXN_ID (
+  NTXN_NEXT NUMBER(19) NOT NULL
+);
+INSERT INTO NEXT_TXN_ID VALUES(1);
+
+CREATE TABLE HIVE_LOCKS (
+  HL_LOCK_EXT_ID NUMBER(19) NOT NULL,
+  HL_LOCK_INT_ID NUMBER(19) NOT NULL,
+  HL_TXNID NUMBER(19),
+  HL_DB VARCHAR2(128) NOT NULL,
+  HL_TABLE VARCHAR2(128),
+  HL_PARTITION VARCHAR2(767),
+  HL_LOCK_STATE CHAR(1) NOT NULL,
+  HL_LOCK_TYPE CHAR(1) NOT NULL,
+  HL_LAST_HEARTBEAT NUMBER(19) NOT NULL,
+  HL_ACQUIRED_AT NUMBER(19),
+  HL_USER varchar(128) NOT NULL,
+  HL_HOST varchar(128) NOT NULL,
+  PRIMARY KEY(HL_LOCK_EXT_ID, HL_LOCK_INT_ID)
+); 
+
+CREATE INDEX HL_TXNID_INDEX ON HIVE_LOCKS (HL_TXNID);
+
+CREATE TABLE NEXT_LOCK_ID (
+  NL_NEXT NUMBER(19) NOT NULL
+);
+INSERT INTO NEXT_LOCK_ID VALUES(1);
+
+CREATE TABLE COMPACTION_QUEUE (
+  CQ_ID NUMBER(19) PRIMARY KEY,
+  CQ_DATABASE varchar(128) NOT NULL,
+  CQ_TABLE varchar(128) NOT NULL,
+  CQ_PARTITION varchar(767),
+  CQ_STATE char(1) NOT NULL,
+  CQ_TYPE char(1) NOT NULL,
+  CQ_WORKER_ID varchar(128),
+  CQ_START NUMBER(19),
+  CQ_RUN_AS varchar(128)
+);
+
+CREATE TABLE NEXT_COMPACTION_QUEUE_ID (
+  NCQ_NEXT NUMBER(19) NOT NULL
+);
+INSERT INTO NEXT_COMPACTION_QUEUE_ID VALUES(1);
+
+
+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;

http://git-wip-us.apache.org/repos/asf/ambari/blob/c188b96b/ambari-server/src/main/resources/stacks/HDP/2.1/services/HIVE/etc/upgrade-0.13.0.oracle.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.1/services/HIVE/etc/upgrade-0.13.0.oracle.sql
b/ambari-server/src/main/resources/stacks/HDP/2.1/services/HIVE/etc/upgrade-0.13.0.oracle.sql
new file mode 100644
index 0000000..b34f406
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.1/services/HIVE/etc/upgrade-0.13.0.oracle.sql
@@ -0,0 +1,38 @@
+ALTER TABLE TXNS MODIFY (
+  TXN_ID NUMBER(19),
+  TXN_STARTED NUMBER(19),
+  TXN_LAST_HEARTBEAT NUMBER(19)
+);
+
+ALTER TABLE TXN_COMPONENTS MODIFY (
+  TC_TXNID NUMBER(19)
+);
+
+ALTER TABLE COMPLETED_TXN_COMPONENTS MODIFY (
+  CTC_TXNID NUMBER(19)
+);
+
+ALTER TABLE NEXT_TXN_ID MODIFY (
+  NTXN_NEXT NUMBER(19)
+);
+
+ALTER TABLE HIVE_LOCKS MODIFY (
+  HL_LOCK_EXT_ID NUMBER(19),
+  HL_LOCK_INT_ID NUMBER(19),
+  HL_TXNID NUMBER(19),
+  HL_LAST_HEARTBEAT NUMBER(19),
+  HL_ACQUIRED_AT NUMBER(19)
+);
+
+ALTER TABLE NEXT_LOCK_ID MODIFY (
+  NL_NEXT NUMBER(19)
+);
+
+ALTER TABLE COMPACTION_QUEUE MODIFY (
+  CQ_ID NUMBER(19),
+  CQ_START NUMBER(19)
+);
+
+ALTER TABLE NEXT_COMPACTION_QUEUE_ID MODIFY (
+  NCQ_NEXT NUMBER(19)
+);


Mime
View raw message