You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by th...@apache.org on 2014/02/17 06:31:05 UTC

svn commit: r1568880 [1/4] - in /hive/trunk: itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/ metastore/if/ metastore/scripts/upgrade/derby/ metastore/scripts/upgrade/mysql/ metastore/scripts/upgrade/oracle/ metastore/scripts/upgrade/po...

Author: thejas
Date: Mon Feb 17 05:31:04 2014
New Revision: 1568880

URL: http://svn.apache.org/r1568880
Log:
HIVE-6386 : sql std auth - database should have an owner (Ashutosh Chauhan via Thejas Nair)

Added:
    hive/trunk/metastore/scripts/upgrade/derby/016-HIVE-6386.derby.sql
    hive/trunk/metastore/scripts/upgrade/mysql/016-HIVE-6386.mysql.sql
    hive/trunk/metastore/scripts/upgrade/oracle/016-HIVE-6386.oracle.sql
    hive/trunk/metastore/scripts/upgrade/postgres/016-HIVE-6386.postgres.sql
Modified:
    hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
    hive/trunk/metastore/if/hive_metastore.thrift
    hive/trunk/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp
    hive/trunk/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.cpp
    hive/trunk/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.h
    hive/trunk/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/Database.java
    hive/trunk/metastore/src/gen/thrift/gen-php/metastore/Types.php
    hive/trunk/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py
    hive/trunk/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb
    hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
    hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
    hive/trunk/metastore/src/model/org/apache/hadoop/hive/metastore/model/MDatabase.java
    hive/trunk/metastore/src/model/package.jdo
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataFormatter.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java
    hive/trunk/serde/src/gen/thrift/gen-cpp/serde_constants.cpp
    hive/trunk/serde/src/gen/thrift/gen-cpp/serde_constants.h
    hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde/test/ThriftTestObj.java
    hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/Complex.java
    hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java
    hive/trunk/serde/src/gen/thrift/gen-php/org/apache/hadoop/hive/serde/Types.php
    hive/trunk/serde/src/gen/thrift/gen-py/org_apache_hadoop_hive_serde/constants.py
    hive/trunk/serde/src/gen/thrift/gen-rb/serde_constants.rb

Modified: hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
URL: http://svn.apache.org/viewvc/hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java?rev=1568880&r1=1568879&r2=1568880&view=diff
==============================================================================
--- hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java (original)
+++ hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java Mon Feb 17 05:31:04 2014
@@ -54,6 +54,7 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
 import org.apache.hadoop.hive.metastore.api.Order;
 import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.PrincipalType;
 import org.apache.hadoop.hive.metastore.api.SerDeInfo;
 import org.apache.hadoop.hive.metastore.api.SkewedInfo;
 import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
@@ -62,9 +63,11 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.api.Type;
 import org.apache.hadoop.hive.metastore.api.UnknownDBException;
 import org.apache.hadoop.hive.ql.exec.Utilities;
+import org.apache.hadoop.hive.ql.session.SessionState;
 import org.apache.hadoop.hive.serde.serdeConstants;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.thrift.TException;
+import org.junit.Test;
 
 import com.google.common.collect.Lists;
 
@@ -923,6 +926,8 @@ public abstract class TestHiveMetaStore 
 
       Database db = new Database();
       db.setName(TEST_DB1_NAME);
+      db.setOwnerName(SessionState.getUserFromAuthenticator());
+      db.setOwnerType(PrincipalType.USER);
       client.createDatabase(db);
 
       db = client.getDatabase(TEST_DB1_NAME);
@@ -931,7 +936,8 @@ public abstract class TestHiveMetaStore 
           TEST_DB1_NAME, db.getName());
       assertEquals("location of the returned db is different from that of inserted db",
           warehouse.getDatabasePath(db).toString(), db.getLocationUri());
-
+      assertEquals(db.getOwnerName(), SessionState.getUserFromAuthenticator());
+      assertEquals(db.getOwnerType(), PrincipalType.USER);
       Database db2 = new Database();
       db2.setName(TEST_DB2_NAME);
       client.createDatabase(db2);
@@ -2659,4 +2665,11 @@ public abstract class TestHiveMetaStore 
 
     createPartitions(dbName, tbl, values);
   }
+
+    @Test
+    public void testDBOwner() throws NoSuchObjectException, MetaException, TException {
+      Database db = client.getDatabase(MetaStoreUtils.DEFAULT_DATABASE_NAME);
+      assertEquals(db.getOwnerName(), HiveMetaStore.PUBLIC);
+      assertEquals(db.getOwnerType(), PrincipalType.ROLE);
+    }
 }

Modified: hive/trunk/metastore/if/hive_metastore.thrift
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/if/hive_metastore.thrift?rev=1568880&r1=1568879&r2=1568880&view=diff
==============================================================================
--- hive/trunk/metastore/if/hive_metastore.thrift (original)
+++ hive/trunk/metastore/if/hive_metastore.thrift Mon Feb 17 05:31:04 2014
@@ -120,7 +120,9 @@ struct Database {
   2: string description,
   3: string locationUri,
   4: map<string, string> parameters, // properties associated with the database
-  5: optional PrincipalPrivilegeSet privileges
+  5: optional PrincipalPrivilegeSet privileges,
+  6: optional string ownerName,
+  7: optional PrincipalType ownerType
 }
 
 // This object holds the information needed by SerDes

Added: hive/trunk/metastore/scripts/upgrade/derby/016-HIVE-6386.derby.sql
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/derby/016-HIVE-6386.derby.sql?rev=1568880&view=auto
==============================================================================
--- hive/trunk/metastore/scripts/upgrade/derby/016-HIVE-6386.derby.sql (added)
+++ hive/trunk/metastore/scripts/upgrade/derby/016-HIVE-6386.derby.sql Mon Feb 17 05:31:04 2014
@@ -0,0 +1,2 @@
+ALTER TABLE "DBS" ADD "OWNER_NAME" CHAR(128);
+ALTER TABLE "DBS" ADD "OWNER_TYPE" CHAR(10);

Added: hive/trunk/metastore/scripts/upgrade/mysql/016-HIVE-6386.mysql.sql
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/mysql/016-HIVE-6386.mysql.sql?rev=1568880&view=auto
==============================================================================
--- hive/trunk/metastore/scripts/upgrade/mysql/016-HIVE-6386.mysql.sql (added)
+++ hive/trunk/metastore/scripts/upgrade/mysql/016-HIVE-6386.mysql.sql Mon Feb 17 05:31:04 2014
@@ -0,0 +1,5 @@
+SELECT '< HIVE-6386: Add owner filed to database >' AS ' ';
+
+ALTER TABLE `DBS` ADD `OWNER_NAME` varchar(128);
+ALTER TABLE `DBS` ADD `OWNER_TYPE` varchar(10);
+

Added: hive/trunk/metastore/scripts/upgrade/oracle/016-HIVE-6386.oracle.sql
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/oracle/016-HIVE-6386.oracle.sql?rev=1568880&view=auto
==============================================================================
--- hive/trunk/metastore/scripts/upgrade/oracle/016-HIVE-6386.oracle.sql (added)
+++ hive/trunk/metastore/scripts/upgrade/oracle/016-HIVE-6386.oracle.sql Mon Feb 17 05:31:04 2014
@@ -0,0 +1,2 @@
+ALTER TABLE DBS ADD OWNER_NAME VARCHAR2(128);
+ALTER TABLE DBS ADD OWNER_TYPE VARCHAR2(10);

Added: hive/trunk/metastore/scripts/upgrade/postgres/016-HIVE-6386.postgres.sql
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/postgres/016-HIVE-6386.postgres.sql?rev=1568880&view=auto
==============================================================================
--- hive/trunk/metastore/scripts/upgrade/postgres/016-HIVE-6386.postgres.sql (added)
+++ hive/trunk/metastore/scripts/upgrade/postgres/016-HIVE-6386.postgres.sql Mon Feb 17 05:31:04 2014
@@ -0,0 +1,4 @@
+SELECT '< HIVE-6386 Database should have an owner >';
+
+ALTER TABLE "DBS" ADD COLUMN "OWNER_NAME" character varying(128);
+ALTER TABLE "DBS" ADD COLUMN "OWNER_TYPE" character varying(10);