This is an automated email from the ASF dual-hosted git repository.

szita pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 7cf1777  HIVE-21812: Implement get partition related methods on 
temporary tables (Laszlo Pinter, reviewed by Marta Kuczora, Adam Szita)
7cf1777 is described below

commit 7cf1777ad64cb761fcadf3d566b4b72c29fdae12
Author: Laszlo Pinter <[email protected]>
AuthorDate: Fri Jun 14 11:24:21 2019 +0200

    HIVE-21812: Implement get partition related methods on temporary tables 
(Laszlo Pinter, reviewed by Marta Kuczora, Adam Szita)
---
 .../ql/metadata/SessionHiveMetaStoreClient.java    | 211 +++++++++++++++++----
 .../hive/metastore/client/MetaStoreClientTest.java |  11 +-
 .../hive/metastore/client/TestGetPartitions.java   | 112 ++++++-----
 3 files changed, 242 insertions(+), 92 deletions(-)

diff --git 
a/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java
 
b/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java
index 410868c..b71ef5a 100644
--- 
a/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java
+++ 
b/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java
@@ -20,14 +20,15 @@ package org.apache.hadoop.hive.ql.metadata;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
+import java.util.Map.Entry;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -74,6 +75,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_CATALOG_NAME;
+import static 
org.apache.hadoop.hive.metastore.Warehouse.getCatalogQualifiedTableName;
+import static org.apache.hadoop.hive.metastore.Warehouse.makePartName;
 
 /**
  * todo: This need review re: thread safety.  Various places (see callsers of
@@ -573,7 +576,14 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
     createTempTable(tbl);
   }
 
-  private org.apache.hadoop.hive.metastore.api.Table getTempTable(String 
dbName, String tableName) {
+  private org.apache.hadoop.hive.metastore.api.Table getTempTable(String 
dbName, String tableName)
+      throws MetaException {
+    if (dbName == null) {
+      throw new MetaException("Db name cannot be null");
+    }
+    if (tableName == null) {
+      throw new MetaException("Table name cannot be null");
+    }
     Map<String, Table> tables = getTempTablesForDatabase(dbName.toLowerCase(),
         tableName.toLowerCase());
     if (tables != null) {
@@ -914,30 +924,79 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
       pTree = t.getPartitionKeysSize() > 0 ? new PartitionTree(tTable) : null;
     }
     private void addPartition(Partition p) throws AlreadyExistsException, 
MetaException {
-      assertPartitioned();
       pTree.addPartition(p);
     }
 
     private Partition getPartition(String partName) throws MetaException {
-      assertPartitioned();
+      if (partName == null || partName.isEmpty()) {
+        throw new MetaException("Partition name cannot be null or empty");
+      }
       return pTree.getPartition(partName);
     }
 
+    private Partition getPartition(List<String> partVals) throws MetaException 
{
+      if (partVals == null) {
+        throw new MetaException("Partition values cannot be null");
+      }
+      return pTree.getPartition(partVals);
+    }
+
     private int addPartitions(List<Partition> partitions) throws 
AlreadyExistsException,
             MetaException {
-      assertPartitioned();
       return pTree.addPartitions(partitions);
     }
 
+    private List<Partition> getPartitionsByNames(List<String> partNames) 
throws MetaException {
+      if (partNames == null) {
+        throw new MetaException("Partition names cannot be null");
+      }
+      List<Partition> partitions = new ArrayList<>();
+      for (String partName : partNames) {
+        Partition partition = getPartition(partName);
+        if (partition != null) {
+          partitions.add(partition);
+        }
+      }
+      return partitions;
+    }
+
     private List<Partition> getPartitions(List<String> partialPartVals) throws 
MetaException {
-      assertPartitioned();
       return pTree.getPartitions(partialPartVals);
     }
 
-    private void assertPartitioned() throws MetaException {
-      if(tTable.getPartitionKeysSize() <= 0) {
-        throw new MetaException(Warehouse.getQualifiedName(tTable) + " is not 
partitioned");
+    private Partition getPartitionWithAuthInfo(List<String> partionVals, 
String userName, List<String> groupNames)
+        throws MetaException {
+      Partition partition = getPartition(partionVals);
+      if (partition == null) {
+        return null;
+      }
+      return checkPrivilegesForPartition(partition, userName, groupNames) ? 
partition : null;
+    }
+
+    private boolean checkPrivilegesForPartition(Partition partition, String 
userName, List<String> groupNames) {
+      if ((userName == null || userName.isEmpty()) && (groupNames == null || 
groupNames.isEmpty())) {
+        return true;
+      }
+      PrincipalPrivilegeSet privileges = partition.getPrivileges();
+      if (privileges == null) {
+        return false;
       }
+      if (privileges.isSetUserPrivileges()) {
+        if (!privileges.getUserPrivileges().containsKey(userName)) {
+          return false;
+        }
+      }
+      if (privileges.isSetGroupPrivileges()) {
+        if (groupNames == null) {
+          return false;
+        }
+        for (String group : groupNames) {
+          if (!privileges.getGroupPrivileges().containsKey(group)) {
+            return false;
+          }
+        }
+      }
+      return true;
     }
 
     /**
@@ -965,6 +1024,19 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
         return parts.get(partName);
       }
 
+      /**
+       * Get a partition matching the partition values.
+       *
+       * @param partVals partition values for this partition, must be in the 
same order as the
+       *                 partition keys of the table.
+       * @return the partition object, or if not found null.
+       * @throws MetaException
+       */
+      private Partition getPartition(List<String> partVals) throws 
MetaException {
+        String partName = makePartName(tTable.getPartitionKeys(), partVals);
+        return getPartition(partName);
+      }
+
       private int addPartitions(List<Partition> partitions)
               throws AlreadyExistsException, MetaException {
         int partitionsAdded = 0;
@@ -1011,7 +1083,7 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
       //(assume) not a temp table - Try underlying client
       return super.add_partition(partition);
     }
-    TempTable tt = getTempTable(table);
+    TempTable tt = getPartitionedTempTable(table);
     if(tt == null) {
       throw new IllegalStateException("TempTable not found for " +
           Warehouse.getQualifiedName(table));
@@ -1039,7 +1111,7 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
       // not a temp table - Try underlying client
       return super.add_partitions(partitions);
     }
-    TempTable tt = getTempTable(table);
+    TempTable tt = getPartitionedTempTable(table);
     if (tt == null) {
       throw new IllegalStateException("TempTable not found for" +
               table.getTableName());
@@ -1047,6 +1119,50 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
     return tt.addPartitions(deepCopyPartitions(partitions));
   }
 
+
+  @Override
+  public Partition getPartition(String catName, String dbName, String tblName, 
String name) throws TException {
+    org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, 
tblName);
+    if (table == null) {
+      return super.getPartition(catName, dbName, tblName, name);
+    }
+    assertPartitioned(table);
+    TempTable tt = getPartitionedTempTable(table);
+    if(tt == null) {
+      throw new IllegalStateException("TempTable not found for " +
+              getCatalogQualifiedTableName(table));
+    }
+    Partition partition = tt.getPartition(name);
+    if (partition == null) {
+      throw new NoSuchObjectException("Partition with name " + name + " for 
table " + tblName + " in database " +
+              dbName + " is not found.");
+    }
+
+    return deepCopy(partition);
+  }
+
+  @Override
+  public Partition getPartition(String catName, String dbName, String tblName,
+                                List<String> partVals) throws TException {
+    org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, 
tblName);
+    if (table == null) {
+      return super.getPartition(catName, dbName, tblName, partVals);
+    }
+    assertPartitioned(table);
+    TempTable tt = getPartitionedTempTable(table);
+    if(tt == null) {
+      throw new IllegalStateException("TempTable not found for " +
+              getCatalogQualifiedTableName(table));
+    }
+    Partition partition = tt.getPartition(partVals);
+    if (partition == null) {
+      throw new NoSuchObjectException("Partition with partition values " +
+              (partVals != null ? Arrays.toString(partVals.toArray()) : 
"null")+
+              " for table " + tblName + " in database " + dbName + " is not 
found.");
+    }
+    return deepCopy(partition);
+  }
+
   /**
    * @param partialPvals partition values, can be partial.  This really means 
that missing values
    *                    are represented by empty str.
@@ -1062,7 +1178,7 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
       return super.listPartitionsWithAuthInfo(dbName, tableName, partialPvals, 
maxParts, userName,
           groupNames);
     }
-    TempTable tt = getTempTable(table);
+    TempTable tt = getPartitionedTempTable(table);
     if(tt == null) {
       throw new IllegalStateException("TempTable not found for " +
           Warehouse.getQualifiedName(table));
@@ -1087,7 +1203,7 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
       //(assume) not a temp table - Try underlying client
       return super.listPartitionNames(dbName, tableName, maxParts);
     }
-    TempTable tt = getTempTable(table);
+    TempTable tt = getPartitionedTempTable(table);
     if(tt == null) {
       throw new IllegalStateException("TempTable not found for " +
           Warehouse.getQualifiedName(table));
@@ -1103,42 +1219,53 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
     return matchedParts;
   }
 
-  /**
-   * partNames are like "p=1/q=2" type strings.  The values (RHS of =) are 
escaped.
-   */
+
   @Override
-  public List<Partition> getPartitionsByNames(String db_name, String tblName,
-                                              List<String> partNames) throws 
TException {
-    return getPartitionsByNames(db_name, tblName, partNames, false);
+  public List<Partition> getPartitionsByNames(String catName, String dbName, 
String tblName,
+                                              List<String> partNames, boolean 
getColStats) throws TException {
+    org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, 
tblName);
+    if (table == null) {
+      //(assume) not a temp table - Try underlying client
+      return super.getPartitionsByNames(catName, dbName, tblName, partNames, 
getColStats);
+    }
+    assertPartitioned(table);
+    TempTable tt = getPartitionedTempTable(table);
+    if (tt == null) {
+      throw new IllegalStateException("TempTable not found for " +
+              getCatalogQualifiedTableName(table));
+    }
+    List<Partition> partitions = tt.getPartitionsByNames(partNames);
+
+    return deepCopyPartitions(partitions);
   }
 
-  /**
-   * partNames are like "p=1/q=2" type strings.  The values (RHS of =) are 
escaped.
-   */
   @Override
-  public List<Partition> getPartitionsByNames(String db_name, String tblName,
-                                              List<String> partNames, boolean 
getColStats)
-          throws TException {
-    org.apache.hadoop.hive.metastore.api.Table table = getTempTable(db_name, 
tblName);
+  public Partition getPartitionWithAuthInfo(String catName, String dbName, 
String tableName,
+                                            List<String> pvals, String 
userName,
+                                            List<String> groupNames) throws 
TException {
+    org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, 
tableName);
     if (table == null) {
-      //(assume) not a temp table - Try underlying client
-      return super.getPartitionsByNames(db_name, tblName, partNames, 
getColStats);
+      return super.getPartitionWithAuthInfo(catName, dbName, tableName, pvals, 
userName, groupNames);
     }
-    TempTable tt = getTempTable(table);
-    if(tt == null) {
-      throw new IllegalStateException("TempTable not found for " + tblName);
+    assertPartitioned(table);
+    TempTable tt = getPartitionedTempTable(table);
+    if (tt == null) {
+      throw new IllegalStateException("TempTable not found for " +
+              getCatalogQualifiedTableName(table));
     }
-    List<Partition> matchedParts = new ArrayList<>();
-    for(String partName : partNames) {
-      Partition p = tt.getPartition(partName);
-      if(p != null) {
-        matchedParts.add(deepCopy(p));
-      }
+
+    Partition partition = tt.getPartitionWithAuthInfo(pvals, userName, 
groupNames);
+    if (partition == null) {
+      throw new NoSuchObjectException("Partition with partition values " +
+              (pvals != null ? Arrays.toString(pvals.toArray()) : "null") +
+              " for table " + tableName + " in database " + dbName + "and for 
user " +
+              userName + " and group names " + (groupNames != null ? 
Arrays.toString(groupNames.toArray()) : "null") +
+              " is not found.");
     }
-    return matchedParts;
+    return deepCopy(partition);
   }
 
-  private static TempTable 
getTempTable(org.apache.hadoop.hive.metastore.api.Table t) {
+  private static TempTable 
getPartitionedTempTable(org.apache.hadoop.hive.metastore.api.Table t) {
     String qualifiedTableName = Warehouse.
         getQualifiedName(t.getDbName().toLowerCase(), 
t.getTableName().toLowerCase());
     SessionState ss = SessionState.get();
@@ -1175,4 +1302,10 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
       throw new IllegalStateException("TempTable for " + qualifiedTableName + 
" already exists");
     }
   }
+
+  private void assertPartitioned(org.apache.hadoop.hive.metastore.api.Table 
table) throws MetaException {
+    if(table.getPartitionKeysSize() <= 0) {
+      throw new MetaException(getCatalogQualifiedTableName(table) + " is not 
partitioned");
+    }
+  }
 }
diff --git 
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreClientTest.java
 
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreClientTest.java
index dc48fa8..afe60b5 100644
--- 
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreClientTest.java
+++ 
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreClientTest.java
@@ -22,7 +22,9 @@ import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
 import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.Rule;
 import org.junit.experimental.categories.Category;
+import org.junit.rules.TestRule;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.slf4j.Logger;
@@ -47,12 +49,15 @@ public abstract class MetaStoreClientTest {
   // Then we should remove our own copy
   private static Set<AbstractMetaStoreService> metaStoreServices = null;
 
+  @Rule
+  public TestRule ignoreRule;
+
   @Parameterized.Parameters(name = "{0}")
   public static List<Object[]> getMetaStoreToTest() throws Exception {
     List<Object[]> result = MetaStoreFactoryForTests.getMetaStores();
     metaStoreServices = result.stream()
-                            .map(test -> (AbstractMetaStoreService)test[1])
-                            .collect(Collectors.toSet());
+        .map(test -> (AbstractMetaStoreService)test[1])
+        .collect(Collectors.toSet());
     return result;
   }
 
@@ -68,7 +73,7 @@ public abstract class MetaStoreClientTest {
    * @param extraConf Specific other configuration values
    */
   public static void startMetaStores(Map<MetastoreConf.ConfVars, String> 
msConf,
-                              Map<String, String> extraConf) {
+      Map<String, String> extraConf) {
     for(AbstractMetaStoreService metaStoreService : metaStoreServices) {
       try {
         metaStoreService.start(msConf, extraConf);
diff --git 
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetPartitions.java
 
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetPartitions.java
index 4d7f7c1..5d5ff1c 100644
--- 
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetPartitions.java
+++ 
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetPartitions.java
@@ -51,11 +51,11 @@ import org.junit.experimental.categories.Category;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
-import static junit.framework.TestCase.assertNotNull;
-import static junit.framework.TestCase.assertNull;
-import static org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_DATABASE_NAME;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNull;
 
 /**
  * API tests for HMS client's getPartitions methods.
@@ -64,10 +64,11 @@ import static org.junit.Assert.fail;
 @Category(MetastoreCheckinTest.class)
 public class TestGetPartitions extends MetaStoreClientTest {
   private AbstractMetaStoreService metaStore;
+
   private IMetaStoreClient client;
 
-  private static final String DB_NAME = "testpartdb";
-  private static final String TABLE_NAME = "testparttable";
+  protected static final String DB_NAME = "testpartdb";
+  protected static final String TABLE_NAME = "testparttable";
 
   public TestGetPartitions(String name, AbstractMetaStoreService metaStore) {
     this.metaStore = metaStore;
@@ -98,21 +99,29 @@ public class TestGetPartitions extends MetaStoreClientTest {
     }
   }
 
+  public IMetaStoreClient getClient() {
+    return client;
+  }
+
+  public void setClient(IMetaStoreClient client) {
+    this.client = client;
+  }
+
   private void createDB(String dbName) throws TException {
     new DatabaseBuilder().
-            setName(dbName).
-            create(client, metaStore.getConf());
+        setName(dbName).
+        create(client, metaStore.getConf());
   }
 
 
-  private Table createTestTable(IMetaStoreClient client, String dbName, String 
tableName,
-                                       List<String> partCols, boolean 
setPartitionLevelPrivilages)
-          throws TException {
+  protected Table createTestTable(IMetaStoreClient client, String dbName, 
String tableName,
+      List<String> partCols, boolean setPartitionLevelPrivilages)
+      throws TException {
     TableBuilder builder = new TableBuilder()
-            .setDbName(dbName)
-            .setTableName(tableName)
-            .addCol("id", "int")
-            .addCol("name", "string");
+        .setDbName(dbName)
+        .setTableName(tableName)
+        .addCol("id", "int")
+        .addCol("name", "string");
 
     partCols.forEach(col -> builder.addPartCol(col, "string"));
     Table table = builder.build(metaStore.getConf());
@@ -125,37 +134,37 @@ public class TestGetPartitions extends 
MetaStoreClientTest {
     return table;
   }
 
-  private void addPartition(IMetaStoreClient client, Table table, List<String> 
values)
-          throws TException {
+  protected void addPartition(IMetaStoreClient client, Table table, 
List<String> values)
+      throws TException {
     PartitionBuilder partitionBuilder = new PartitionBuilder().inTable(table);
     values.forEach(val -> partitionBuilder.addValue(val));
     client.add_partition(partitionBuilder.build(metaStore.getConf()));
   }
 
   private void createTable3PartCols1PartGeneric(IMetaStoreClient client, 
boolean authOn)
-          throws TException {
+      throws TException {
     Table t = createTestTable(client, DB_NAME, TABLE_NAME, 
Lists.newArrayList("yyyy", "mm",
-            "dd"), authOn);
+        "dd"), authOn);
     addPartition(client, t, Lists.newArrayList("1997", "05", "16"));
   }
 
-  private void createTable3PartCols1Part(IMetaStoreClient client) throws 
TException {
+  protected void createTable3PartCols1Part(IMetaStoreClient client) throws 
TException {
     createTable3PartCols1PartGeneric(client, false);
   }
 
-  private void createTable3PartCols1PartAuthOn(IMetaStoreClient client) throws 
TException {
+  protected void createTable3PartCols1PartAuthOn(IMetaStoreClient client) 
throws TException {
     createTable3PartCols1PartGeneric(client, true);
   }
 
-  private List<List<String>> createTable4PartColsParts(IMetaStoreClient 
client) throws
-          Exception {
+  protected List<List<String>> createTable4PartColsParts(IMetaStoreClient 
client) throws
+      Exception {
     Table t = createTestTable(client, DB_NAME, TABLE_NAME, 
Lists.newArrayList("yyyy", "mm", "dd"),
-            false);
+        false);
     List<List<String>> testValues = Lists.newArrayList(
-            Lists.newArrayList("1999", "01", "02"),
-            Lists.newArrayList("2009", "02", "10"),
-            Lists.newArrayList("2017", "10", "26"),
-            Lists.newArrayList("2017", "11", "27"));
+        Lists.newArrayList("1999", "01", "02"),
+        Lists.newArrayList("2009", "02", "10"),
+        Lists.newArrayList("2017", "10", "26"),
+        Lists.newArrayList("2017", "11", "27"));
 
     for(List<String> vals : testValues){
       addPartition(client, t, vals);
@@ -167,11 +176,11 @@ public class TestGetPartitions extends 
MetaStoreClientTest {
   private static void assertAuthInfoReturned(String user, String group, 
Partition partition) {
     assertNotNull(partition.getPrivileges());
     assertEquals(Lists.newArrayList(),
-            partition.getPrivileges().getUserPrivileges().get(user));
+        partition.getPrivileges().getUserPrivileges().get(user));
     assertEquals(Lists.newArrayList(),
-            partition.getPrivileges().getGroupPrivileges().get(group));
+        partition.getPrivileges().getGroupPrivileges().get(group));
     assertEquals(Lists.newArrayList(),
-            partition.getPrivileges().getRolePrivileges().get("public"));
+        partition.getPrivileges().getRolePrivileges().get("public"));
   }
 
 
@@ -339,18 +348,16 @@ public class TestGetPartitions extends 
MetaStoreClientTest {
 
     //TODO: partition names in getPartitionsByNames are not case insensitive
     List<Partition> partitions = client.getPartitionsByNames(DB_NAME, 
TABLE_NAME,
-            Lists.newArrayList("yYYy=2017/MM=11/DD=27", 
"yYyY=1999/mM=01/dD=02"));
+        Lists.newArrayList("yYYy=2017/MM=11/DD=27", "yYyY=1999/mM=01/dD=02"));
     assertEquals(0, partitions.size());
 
     partitions = client.getPartitionsByNames(DB_NAME, TABLE_NAME,
-            Lists.newArrayList("yyyy=2017/mm=11/dd=27", 
"yyyy=1999/mm=01/dd=02"));
+        Lists.newArrayList("yyyy=2017/mm=11/dd=27", "yyyy=1999/mm=01/dd=02"));
     assertEquals(2, partitions.size());
-    assertEquals(testValues.get(0), partitions.get(0).getValues());
-    assertEquals(testValues.get(3), partitions.get(1).getValues());
-
+    partitions.forEach(p -> assertTrue(testValues.contains(p.getValues())));
 
     partitions = client.getPartitionsByNames(DB_NAME, TABLE_NAME,
-            Lists.newArrayList("yyyy=2017", "yyyy=1999/mm=01/dd=02"));
+        Lists.newArrayList("yyyy=2017", "yyyy=1999/mm=01/dd=02"));
     assertEquals(testValues.get(0), partitions.get(0).getValues());
   }
 
@@ -359,11 +366,11 @@ public class TestGetPartitions extends 
MetaStoreClientTest {
     List<List<String>> testValues = createTable4PartColsParts(client);
 
     List<Partition> partitions = client.getPartitionsByNames(DB_NAME, 
TABLE_NAME,
-            Lists.newArrayList("", ""));
+        Lists.newArrayList("", ""));
     assertEquals(0, partitions.size());
 
     partitions = client.getPartitionsByNames(DB_NAME, TABLE_NAME,
-            Lists.newArrayList());
+        Lists.newArrayList());
     assertEquals(0, partitions.size());
   }
 
@@ -428,7 +435,7 @@ public class TestGetPartitions extends MetaStoreClientTest {
   public void testGetPartitionWithAuthInfoNoPrivilagesSet() throws Exception {
     createTable3PartCols1Part(client);
     Partition partition = client.getPartitionWithAuthInfo(DB_NAME, TABLE_NAME, 
Lists.newArrayList(
-            "1997", "05", "16"), "", Lists.newArrayList());
+        "1997", "05", "16"), "", Lists.newArrayList());
     assertNotNull(partition);
     assertNull(partition.getPrivileges());
   }
@@ -437,7 +444,7 @@ public class TestGetPartitions extends MetaStoreClientTest {
   public void testGetPartitionWithAuthInfo() throws Exception {
     createTable3PartCols1PartAuthOn(client);
     Partition partition = client.getPartitionWithAuthInfo(DB_NAME, TABLE_NAME,
-            Lists.newArrayList("1997", "05", "16"), "user0", 
Lists.newArrayList("group0"));
+        Lists.newArrayList("1997", "05", "16"), "user0", 
Lists.newArrayList("group0"));
     assertNotNull(partition);
     assertAuthInfoReturned("user0", "group0", partition);
   }
@@ -446,7 +453,7 @@ public class TestGetPartitions extends MetaStoreClientTest {
   public void testGetPartitionWithAuthInfoEmptyUserGroup() throws Exception {
     createTable3PartCols1PartAuthOn(client);
     Partition partition = client.getPartitionWithAuthInfo(DB_NAME, TABLE_NAME,
-            Lists.newArrayList("1997", "05", "16"), "", 
Lists.newArrayList(""));
+        Lists.newArrayList("1997", "05", "16"), "", Lists.newArrayList(""));
     assertNotNull(partition);
     assertAuthInfoReturned("", "", partition);
   }
@@ -455,28 +462,28 @@ public class TestGetPartitions extends 
MetaStoreClientTest {
   public void testGetPartitionWithAuthInfoNoDbName() throws Exception {
     createTable3PartCols1PartAuthOn(client);
     client.getPartitionWithAuthInfo("", TABLE_NAME,
-            Lists.newArrayList("1997", "05", "16"), "user0", 
Lists.newArrayList("group0"));
+        Lists.newArrayList("1997", "05", "16"), "user0", 
Lists.newArrayList("group0"));
   }
 
   @Test(expected = NoSuchObjectException.class)
   public void testGetPartitionWithAuthInfoNoTblName() throws Exception {
     createTable3PartCols1PartAuthOn(client);
     client.getPartitionWithAuthInfo(DB_NAME, "",
-            Lists.newArrayList("1997", "05", "16"), "user0", 
Lists.newArrayList("group0"));
+        Lists.newArrayList("1997", "05", "16"), "user0", 
Lists.newArrayList("group0"));
   }
 
   @Test(expected = NoSuchObjectException.class)
   public void testGetPartitionWithAuthInfoNoSuchPart() throws Exception {
     createTable3PartCols1PartAuthOn(client);
     client.getPartitionWithAuthInfo(DB_NAME, TABLE_NAME,
-            Lists.newArrayList("1997", "05", "66"), "user0", 
Lists.newArrayList("group0"));
+        Lists.newArrayList("1997", "05", "66"), "user0", 
Lists.newArrayList("group0"));
   }
 
   @Test(expected = MetaException.class)
   public void testGetPartitionWithAuthInfoWrongNumOfPartVals() throws 
Exception {
     createTable3PartCols1PartAuthOn(client);
     client.getPartitionWithAuthInfo(DB_NAME, TABLE_NAME,
-            Lists.newArrayList("1997", "05"), "user0", 
Lists.newArrayList("group0"));
+        Lists.newArrayList("1997", "05"), "user0", 
Lists.newArrayList("group0"));
   }
 
   @Test
@@ -484,7 +491,7 @@ public class TestGetPartitions extends MetaStoreClientTest {
     try {
       createTable3PartCols1PartAuthOn(client);
       client.getPartitionWithAuthInfo(null, TABLE_NAME,
-              Lists.newArrayList("1997", "05", "16"), "user0", 
Lists.newArrayList("group0"));
+          Lists.newArrayList("1997", "05", "16"), "user0", 
Lists.newArrayList("group0"));
       fail("Should have thrown exception");
     } catch (NullPointerException | TTransportException e) {
       //TODO: should not throw different exceptions for different HMS 
deployment types
@@ -496,7 +503,7 @@ public class TestGetPartitions extends MetaStoreClientTest {
     try {
       createTable3PartCols1PartAuthOn(client);
       client.getPartitionWithAuthInfo(DB_NAME, null,
-              Lists.newArrayList("1997", "05", "16"), "user0", 
Lists.newArrayList("group0"));
+          Lists.newArrayList("1997", "05", "16"), "user0", 
Lists.newArrayList("group0"));
       fail("Should have thrown exception");
     } catch (NullPointerException | TTransportException e) {
       //TODO: should not throw different exceptions for different HMS 
deployment types
@@ -507,24 +514,25 @@ public class TestGetPartitions extends 
MetaStoreClientTest {
   public void testGetPartitionWithAuthInfoNullValues() throws Exception {
     createTable3PartCols1PartAuthOn(client);
     client.getPartitionWithAuthInfo(DB_NAME, TABLE_NAME,
-            null, "user0", Lists.newArrayList("group0"));
+        null, "user0", Lists.newArrayList("group0"));
   }
 
   @Test(expected = NoSuchObjectException.class)
   public void testGetPartitionWithAuthInfoNullUser() throws Exception {
     createTable3PartCols1PartAuthOn(client);
     client.getPartitionWithAuthInfo(DB_NAME, "",
-            Lists.newArrayList("1997", "05", "16"), null, 
Lists.newArrayList("group0"));
+        Lists.newArrayList("1997", "05", "16"), null, 
Lists.newArrayList("group0"));
   }
 
   @Test
   public void testGetPartitionWithAuthInfoNullGroups() throws Exception {
     createTable3PartCols1PartAuthOn(client);
     client.getPartitionWithAuthInfo(DB_NAME, TABLE_NAME,
-            Lists.newArrayList("1997", "05", "16"), "user0", null);
+        Lists.newArrayList("1997", "05", "16"), "user0", null);
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void otherCatalog() throws TException {
     String catName = "get_partition_catalog";
     Catalog cat = new CatalogBuilder()
@@ -578,18 +586,21 @@ public class TestGetPartitions extends 
MetaStoreClientTest {
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void getPartitionBogusCatalog() throws TException {
     createTable3PartCols1Part(client);
     client.getPartition("bogus", DB_NAME, TABLE_NAME, 
Lists.newArrayList("1997", "05", "16"));
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void getPartitionByNameBogusCatalog() throws TException {
     createTable3PartCols1Part(client);
     client.getPartition("bogus", DB_NAME, TABLE_NAME, "yyyy=1997/mm=05/dd=16");
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void getPartitionWithAuthBogusCatalog() throws TException {
     createTable3PartCols1PartAuthOn(client);
     client.getPartitionWithAuthInfo("bogus", DB_NAME, TABLE_NAME,
@@ -597,6 +608,7 @@ public class TestGetPartitions extends MetaStoreClientTest {
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void getPartitionsByNamesBogusCatalog() throws TException {
     createTable3PartCols1Part(client);
     client.getPartitionsByNames("bogus", DB_NAME, TABLE_NAME,

Reply via email to