hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1667338 [1/3] - in /hive/branches/hbase-metastore: itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/ metastore/src/gen/protobuf/gen-java/org/apache/hadoop/hive/metastore/hbase/ metastore/src/java/org/apache/hadoop/hive...
Date Tue, 17 Mar 2015 15:50:32 GMT
Author: gates
Date: Tue Mar 17 15:50:31 2015
New Revision: 1667338

URL: http://svn.apache.org/r1667338
Log:
HIVE-9942 Implement functions methods in HBaseStore (Alan Gates)

Modified:
    hive/branches/hbase-metastore/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseImport.java
    hive/branches/hbase-metastore/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseStoreIntegration.java
    hive/branches/hbase-metastore/metastore/src/gen/protobuf/gen-java/org/apache/hadoop/hive/metastore/hbase/HbaseMetastoreProto.java
    hive/branches/hbase-metastore/metastore/src/java/org/apache/hadoop/hive/metastore/hbase/HBaseImport.java
    hive/branches/hbase-metastore/metastore/src/java/org/apache/hadoop/hive/metastore/hbase/HBaseReadWrite.java
    hive/branches/hbase-metastore/metastore/src/java/org/apache/hadoop/hive/metastore/hbase/HBaseSchemaTool.java
    hive/branches/hbase-metastore/metastore/src/java/org/apache/hadoop/hive/metastore/hbase/HBaseStore.java
    hive/branches/hbase-metastore/metastore/src/java/org/apache/hadoop/hive/metastore/hbase/HBaseUtils.java
    hive/branches/hbase-metastore/metastore/src/protobuf/org/apache/hadoop/hive/metastore/hbase/hbase_metastore_proto.proto
    hive/branches/hbase-metastore/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseStore.java

Modified: hive/branches/hbase-metastore/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseImport.java
URL: http://svn.apache.org/viewvc/hive/branches/hbase-metastore/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseImport.java?rev=1667338&r1=1667337&r2=1667338&view=diff
==============================================================================
--- hive/branches/hbase-metastore/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseImport.java
(original)
+++ hive/branches/hbase-metastore/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseImport.java
Tue Mar 17 15:50:31 2015
@@ -28,7 +28,12 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.RawStore;
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.metastore.api.Function;
+import org.apache.hadoop.hive.metastore.api.FunctionType;
 import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.PrincipalType;
+import org.apache.hadoop.hive.metastore.api.ResourceType;
+import org.apache.hadoop.hive.metastore.api.ResourceUri;
 import org.apache.hadoop.hive.metastore.api.Role;
 import org.apache.hadoop.hive.metastore.api.SerDeInfo;
 import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
@@ -63,6 +68,7 @@ public class TestHBaseImport {
   private static HTableInterface sdTable;
   private static HTableInterface partTable;
   private static HTableInterface dbTable;
+  private static HTableInterface funcTable;
   private static HTableInterface roleTable;
   private static Map<String, String> emptyParameters = new HashMap<String, String>();
 
@@ -84,6 +90,8 @@ public class TestHBaseImport {
         families);
     dbTable = utility.createTable(HBaseReadWrite.DB_TABLE.getBytes(HBaseUtils.ENCODING),
         HBaseReadWrite.CATALOG_CF);
+    funcTable = utility.createTable(HBaseReadWrite.FUNC_TABLE.getBytes(HBaseUtils.ENCODING),
+                                  HBaseReadWrite.CATALOG_CF);
     roleTable = utility.createTable(HBaseReadWrite.ROLE_TABLE.getBytes(HBaseUtils.ENCODING),
         HBaseReadWrite.CATALOG_CF);
   }
@@ -100,6 +108,7 @@ public class TestHBaseImport {
     Mockito.when(hconn.getHBaseTable(HBaseReadWrite.TABLE_TABLE)).thenReturn(tblTable);
     Mockito.when(hconn.getHBaseTable(HBaseReadWrite.PART_TABLE)).thenReturn(partTable);
     Mockito.when(hconn.getHBaseTable(HBaseReadWrite.DB_TABLE)).thenReturn(dbTable);
+    Mockito.when(hconn.getHBaseTable(HBaseReadWrite.FUNC_TABLE)).thenReturn(funcTable);
     Mockito.when(hconn.getHBaseTable(HBaseReadWrite.ROLE_TABLE)).thenReturn(roleTable);
     conf = new HiveConf();
     // Turn off caching, as we want to test actual interaction with HBase
@@ -120,6 +129,7 @@ public class TestHBaseImport {
     String[] dbNames = new String[] {"importdb1", "importdb2"};
     String[] tableNames = new String[] {"nonparttable", "parttable"};
     String[] partVals = new String[] {"na", "emea", "latam", "apac"};
+    String[] funcNames = new String[] {"func1", "func2"};
     String[] roles = new String[] {"role1", "role2"};
     int now = (int)System.currentTimeMillis() / 1000;
 
@@ -150,6 +160,12 @@ public class TestHBaseImport {
             now, now, psd, emptyParameters);
         store.addPartition(part);
       }
+
+      for (String funcName : funcNames) {
+        store.createFunction(new Function(funcName, dbNames[i], "classname", "ownername",
+            PrincipalType.USER, (int)System.currentTimeMillis()/1000, FunctionType.JAVA,
+            Arrays.asList(new ResourceUri(ResourceType.JAR, "uri"))));
+      }
     }
 
     HBaseImport importer = new HBaseImport();
@@ -187,7 +203,10 @@ public class TestHBaseImport {
       Assert.assertEquals(4, store.getPartitions(dbNames[i], tableNames[1], -1).size());
       Assert.assertEquals(2, store.getAllTables(dbNames[i]).size());
 
-
+      Assert.assertEquals(2, store.getFunctions(dbNames[i], "*").size());
+      for (int j = 0; j < funcNames.length; j++) {
+        Assert.assertNotNull(store.getFunction(dbNames[i], funcNames[j]));
+      }
     }
 
     Assert.assertEquals(2, store.getAllDatabases().size());

Modified: hive/branches/hbase-metastore/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseStoreIntegration.java
URL: http://svn.apache.org/viewvc/hive/branches/hbase-metastore/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseStoreIntegration.java?rev=1667338&r1=1667337&r2=1667338&view=diff
==============================================================================
--- hive/branches/hbase-metastore/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseStoreIntegration.java
(original)
+++ hive/branches/hbase-metastore/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseStoreIntegration.java
Tue Mar 17 15:50:31 2015
@@ -36,6 +36,8 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.api.DecimalColumnStatsData;
 import org.apache.hadoop.hive.metastore.api.DoubleColumnStatsData;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.metastore.api.Function;
+import org.apache.hadoop.hive.metastore.api.FunctionType;
 import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege;
 import org.apache.hadoop.hive.metastore.api.HiveObjectRef;
 import org.apache.hadoop.hive.metastore.api.HiveObjectType;
@@ -48,6 +50,8 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.api.PrincipalType;
 import org.apache.hadoop.hive.metastore.api.PrivilegeBag;
 import org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo;
+import org.apache.hadoop.hive.metastore.api.ResourceType;
+import org.apache.hadoop.hive.metastore.api.ResourceUri;
 import org.apache.hadoop.hive.metastore.api.Role;
 import org.apache.hadoop.hive.metastore.api.RolePrincipalGrant;
 import org.apache.hadoop.hive.metastore.api.SerDeInfo;
@@ -86,6 +90,7 @@ public class TestHBaseStoreIntegration {
   private static HTableInterface sdTable;
   private static HTableInterface partTable;
   private static HTableInterface dbTable;
+  private static HTableInterface funcTable;
   private static HTableInterface roleTable;
   private static HTableInterface globalPrivsTable;
   private static HTableInterface principalRoleMapTable;
@@ -109,6 +114,8 @@ public class TestHBaseStoreIntegration {
         families);
     dbTable = utility.createTable(HBaseReadWrite.DB_TABLE.getBytes(HBaseUtils.ENCODING),
         HBaseReadWrite.CATALOG_CF);
+    funcTable = utility.createTable(HBaseReadWrite.FUNC_TABLE.getBytes(HBaseUtils.ENCODING),
+                                  HBaseReadWrite.CATALOG_CF);
     roleTable = utility.createTable(HBaseReadWrite.ROLE_TABLE.getBytes(HBaseUtils.ENCODING),
         HBaseReadWrite.CATALOG_CF);
     globalPrivsTable =
@@ -131,6 +138,7 @@ public class TestHBaseStoreIntegration {
     Mockito.when(hconn.getHBaseTable(HBaseReadWrite.TABLE_TABLE)).thenReturn(tblTable);
     Mockito.when(hconn.getHBaseTable(HBaseReadWrite.PART_TABLE)).thenReturn(partTable);
     Mockito.when(hconn.getHBaseTable(HBaseReadWrite.DB_TABLE)).thenReturn(dbTable);
+    Mockito.when(hconn.getHBaseTable(HBaseReadWrite.FUNC_TABLE)).thenReturn(funcTable);
     Mockito.when(hconn.getHBaseTable(HBaseReadWrite.ROLE_TABLE)).thenReturn(roleTable);
     Mockito.when(hconn.getHBaseTable(HBaseReadWrite.GLOBAL_PRIVS_TABLE)).thenReturn(globalPrivsTable);
     Mockito.when(hconn.getHBaseTable(HBaseReadWrite.USER_TO_ROLE_TABLE)).thenReturn(principalRoleMapTable);
@@ -209,6 +217,35 @@ public class TestHBaseStoreIntegration {
   }
 
   @Test
+  public void getFuncsRegex() throws Exception {
+    String dbname = "default";
+    int now = (int)(System.currentTimeMillis()/1000);
+    String[] funcNames = new String[3];
+    for (int i = 0; i < funcNames.length; i++) {
+      funcNames[i] = "func" + i;
+      store.createFunction(new Function(funcNames[i], dbname, "o.a.h.h.myfunc", "me",
+                                        PrincipalType.USER, now, FunctionType.JAVA,
+                                        Arrays.asList(new ResourceUri(ResourceType.JAR,
+                                        "file:/tmp/somewhere"))));
+    }
+
+    List<String> funcs = store.getFunctions(dbname, "func1|func2");
+    Assert.assertEquals(2, funcs.size());
+    String[] namesFromStore = funcs.toArray(new String[2]);
+    Arrays.sort(namesFromStore);
+    Assert.assertArrayEquals(Arrays.copyOfRange(funcNames, 1, 3), namesFromStore);
+
+    funcs = store.getFunctions(dbname, "func*");
+    Assert.assertEquals(3, funcs.size());
+    namesFromStore = funcs.toArray(new String[3]);
+    Arrays.sort(namesFromStore);
+    Assert.assertArrayEquals(funcNames, namesFromStore);
+
+    funcs = store.getFunctions("nosuchdb", "func*");
+    Assert.assertEquals(0, funcs.size());
+  }
+
+  @Test
   public void createTable() throws Exception {
     int startTime = (int)(System.currentTimeMillis() / 1000);
     List<FieldSchema> cols = new ArrayList<FieldSchema>();



Mime
View raw message