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

kuczoram 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 67c5dd3  HIVE-21814: Implement list partitions related methods on 
temporary tables (Laszlo Pinter via Marta Kuczora)
67c5dd3 is described below

commit 67c5dd338a957b841944f4679029335496208ae5
Author: Laszlo Pinter <[email protected]>
AuthorDate: Fri Jun 21 09:49:38 2019 +0200

    HIVE-21814: Implement list partitions related methods on temporary tables 
(Laszlo Pinter via Marta Kuczora)
---
 .../ql/metadata/SessionHiveMetaStoreClient.java    | 240 +++++++++++++++------
 ...HiveMetastoreClientListPartitionsTempTable.java | 236 ++++++++++++++++++++
 ...ditionalIgnoreOnSessionHiveMetastoreClient.java |   2 +-
 .../hive/metastore/client/TestListPartitions.java  | 155 ++++++++++---
 4 files changed, 539 insertions(+), 94 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 b71ef5a..957ebb1 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
@@ -25,6 +25,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -50,19 +51,22 @@ import 
org.apache.hadoop.hive.metastore.api.ColumnStatisticsDesc;
 import org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj;
 import org.apache.hadoop.hive.metastore.api.EnvironmentContext;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
-import org.apache.hadoop.hive.metastore.api.HiveObjectRef;
-import org.apache.hadoop.hive.metastore.api.HiveObjectType;
 import org.apache.hadoop.hive.metastore.api.InvalidInputException;
 import org.apache.hadoop.hive.metastore.api.InvalidObjectException;
 import org.apache.hadoop.hive.metastore.api.InvalidOperationException;
+import org.apache.hadoop.hive.metastore.api.HiveObjectRef;
+import org.apache.hadoop.hive.metastore.api.HiveObjectType;
 import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
 import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.PartitionListComposingSpec;
+import org.apache.hadoop.hive.metastore.api.PartitionSpec;
 import org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet;
 import org.apache.hadoop.hive.metastore.api.SetPartitionsStatsRequest;
 import org.apache.hadoop.hive.metastore.api.TableMeta;
 import org.apache.hadoop.hive.metastore.api.UnknownDBException;
 import org.apache.hadoop.hive.metastore.api.UnknownTableException;
+import org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy;
 import org.apache.hadoop.hive.ql.parse.SemanticAnalyzer;
 import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
 import org.apache.hadoop.hive.metastore.utils.SecurityUtils;
@@ -960,8 +964,8 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
       return partitions;
     }
 
-    private List<Partition> getPartitions(List<String> partialPartVals) throws 
MetaException {
-      return pTree.getPartitions(partialPartVals);
+    private List<Partition> getPartitionsByPartitionVals(List<String> 
partialPartVals) throws MetaException {
+      return pTree.getPartitionsByPartitionVals(partialPartVals);
     }
 
     private Partition getPartitionWithAuthInfo(List<String> partionVals, 
String userName, List<String> groupNames)
@@ -973,13 +977,40 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
       return checkPrivilegesForPartition(partition, userName, groupNames) ? 
partition : null;
     }
 
+    private List<Partition> listPartitions() throws MetaException {
+      return pTree.listPartitions();
+    }
+
+    private List<Partition> listPartitionsWithAuthInfo(String userName, 
List<String> groupNames) throws MetaException {
+      List<Partition> partitions = listPartitions();
+      List<Partition> result = new ArrayList<>();
+      partitions.forEach(p -> {
+        if (checkPrivilegesForPartition(p, userName, groupNames)) {
+          result.add(p);
+        }
+      });
+      return result;
+    }
+
+    private List<Partition> 
listPartitionsByPartitionValsWithAuthInfo(List<String> partialVals, String 
userName,
+        List<String> groupNames) throws MetaException {
+      List<Partition> partitions = 
pTree.getPartitionsByPartitionVals(partialVals);
+      List<Partition> result = new ArrayList<>();
+      partitions.forEach(p -> {
+        if (checkPrivilegesForPartition(p, userName, groupNames)) {
+          result.add(p);
+        }
+      });
+      return result;
+    }
+
     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;
+        return true;
       }
       if (privileges.isSetUserPrivileges()) {
         if (!privileges.getUserPrivileges().containsKey(userName)) {
@@ -1004,7 +1035,7 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
      * via references.
      */
     private static final class PartitionTree {
-      private final Map<String, Partition> parts = new HashMap<>();
+      private final Map<String, Partition> parts = new LinkedHashMap<>();
       private final org.apache.hadoop.hive.metastore.api.Table tTable;
 
       private PartitionTree(org.apache.hadoop.hive.metastore.api.Table t) {
@@ -1053,18 +1084,29 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
        * Missing values should be represented as "" (empty strings).  May 
provide fewer values.
        * So if part cols are a,b,c, {"",2} is a valid list
        * {@link MetaStoreUtils#getPvals(List, Map)}
-       *
        */
-      private List<Partition> getPartitions(List<String> partialPartVals) 
throws MetaException {
+      private List<Partition> getPartitionsByPartitionVals(List<String> 
partialPartVals) throws MetaException {
+        if (partialPartVals == null || partialPartVals.isEmpty()) {
+          throw new MetaException("Partition partial vals cannot be null or 
empty");
+        }
         String partNameMatcher = MetaStoreUtils.makePartNameMatcher(tTable, 
partialPartVals, ".*");
         List<Partition> matchedPartitions = new ArrayList<>();
-        for(String key : parts.keySet()) {
-          if(key.matches(partNameMatcher)) {
+        for (String key : parts.keySet()) {
+          if (key.matches(partNameMatcher)) {
             matchedPartitions.add(parts.get(key));
           }
         }
         return matchedPartitions;
       }
+
+      /**
+       * Get all the partitions.
+       *
+       * @return partitions list
+       */
+      private List<Partition> listPartitions() {
+        return new ArrayList<>(parts.values());
+      }
     }
   }
   /**
@@ -1084,10 +1126,6 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
       return super.add_partition(partition);
     }
     TempTable tt = getPartitionedTempTable(table);
-    if(tt == null) {
-      throw new IllegalStateException("TempTable not found for " +
-          Warehouse.getQualifiedName(table));
-    }
     tt.addPartition(deepCopy(partition));
     return partition;
   }
@@ -1112,10 +1150,6 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
       return super.add_partitions(partitions);
     }
     TempTable tt = getPartitionedTempTable(table);
-    if (tt == null) {
-      throw new IllegalStateException("TempTable not found for" +
-              table.getTableName());
-    }
     return tt.addPartitions(deepCopyPartitions(partitions));
   }
 
@@ -1126,12 +1160,7 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
     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 " +
@@ -1148,12 +1177,7 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
     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 " +
@@ -1179,46 +1203,134 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
           groupNames);
     }
     TempTable tt = getPartitionedTempTable(table);
-    if(tt == null) {
-      throw new IllegalStateException("TempTable not found for " +
-          Warehouse.getQualifiedName(table));
+    List<Partition> parts = 
tt.listPartitionsByPartitionValsWithAuthInfo(partialPvals, userName, 
groupNames);
+    if (parts.isEmpty()) {
+      throw new NoSuchObjectException("Partition with partition values " +
+          (partialPvals != null ? Arrays.toString(partialPvals.toArray()) : 
"null") +
+          " for table " + tableName + " in database " + dbName + " is not 
found");
     }
-    List<Partition> parts = tt.getPartitions(partialPvals);
     List<Partition> matchedParts = new ArrayList<>();
-    for(int i = 0; i < (maxParts <= 0 ? parts.size() : maxParts); i++) {
+    for(int i = 0; i < ((maxParts < 0 || maxParts > parts.size()) ? 
parts.size() : maxParts); i++) {
       matchedParts.add(deepCopy(parts.get(i)));
     }
     return matchedParts;
   }
 
-  /**
-   * Returns a list of partition names, i.e. "p=1/q=2" type strings.  The 
values (RHS of =) are
-   * escaped.
-   */
   @Override
-  public List<String> listPartitionNames(String dbName, String tableName,
-      short maxParts) throws TException {
+  public List<Partition> listPartitionsWithAuthInfo(String catName, String 
dbName, String tableName,
+      int maxParts, 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.listPartitionNames(dbName, tableName, maxParts);
+      return super.listPartitionsWithAuthInfo(catName, dbName, tableName, 
maxParts, userName, groupNames);
     }
     TempTable tt = getPartitionedTempTable(table);
-    if(tt == null) {
-      throw new IllegalStateException("TempTable not found for " +
-          Warehouse.getQualifiedName(table));
+    List<Partition> partitions = tt.listPartitionsWithAuthInfo(userName, 
groupNames);
+    if (partitions.isEmpty()) {
+      throw new NoSuchObjectException(
+          "Partition for table " + tableName + " in database " + dbName + "and 
for user " +
+              userName + " and group names " + (groupNames != null ? 
Arrays.toString(groupNames.toArray()) : "null") +
+              " is not found.");
+    }
+    List<Partition> matchedParts = new ArrayList<>();
+    for(int i = 0; i < ((maxParts < 0 || maxParts > partitions.size()) ? 
partitions.size() : maxParts); i++) {
+      matchedParts.add(deepCopy(partitions.get(i)));
+    }
+    return matchedParts;
+  }
+
+  @Override
+  public List<String> listPartitionNames(String catName, String dbName, String 
tblName,
+      int maxParts) throws TException {
+    org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, 
tblName);
+    if (table == null) {
+      return super.listPartitionNames(catName, dbName, tblName, maxParts);
     }
-    List<String> partVals = new ArrayList<>();
-    partVals.add(""); //to get all partitions
-    List<Partition> parts = tt.getPartitions(partVals);
-    List<String> matchedParts = new ArrayList<>();
-    for(int i = 0; i < (maxParts <= 0 ? parts.size() : maxParts); i++) {
-      matchedParts.add(
-          Warehouse.makePartName(tt.tTable.getPartitionKeys(), 
parts.get(i).getValues()));
+    TempTable tt = getPartitionedTempTable(table);
+    List<Partition> partitions = tt.listPartitions();
+    List<String> result = new ArrayList<>();
+    for (int i = 0; i < ((maxParts < 0 || maxParts > partitions.size()) ? 
partitions.size() : maxParts); i++) {
+      result.add(makePartName(tt.tTable.getPartitionKeys(), 
partitions.get(i).getValues()));
+    }
+    return result;
+  }
+
+  @Override
+  public List<String> listPartitionNames(String catName, String dbName, String 
tblName,
+      List<String> partVals, int maxParts) throws TException {
+    org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, 
tblName);
+    if (table == null) {
+      return super.listPartitionNames(catName, dbName, tblName, partVals, 
maxParts);
+    }
+    TempTable tt = getPartitionedTempTable(table);
+    List<Partition> partitions = tt.getPartitionsByPartitionVals(partVals);
+    List<String> result = new ArrayList<>();
+    for (int i = 0; i < ((maxParts < 0 || maxParts > partitions.size()) ? 
partitions.size() : maxParts); i++) {
+      result.add(makePartName(tt.tTable.getPartitionKeys(), 
partitions.get(i).getValues()));
+    }
+    return result;
+  }
+
+  @Override
+  public List<Partition> listPartitions(String catName, String dbName, String 
tblName, int maxParts)
+      throws TException {
+    org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, 
tblName);
+    if (table == null) {
+      return super.listPartitions(catName, dbName, tblName, maxParts);
+    }
+    TempTable tt = getPartitionedTempTable(table);
+    List<Partition> partitions = tt.listPartitions();
+    List<Partition> matchedParts = new ArrayList<>();
+    for(int i = 0; i < ((maxParts < 0 || maxParts > partitions.size()) ? 
partitions.size() : maxParts); i++) {
+      matchedParts.add(deepCopy(partitions.get(i)));
     }
     return matchedParts;
   }
 
+  @Override
+  public List<Partition> listPartitions(String catName, String dbName, String 
tblName,
+      List<String> partVals, int maxParts) throws TException {
+    org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, 
tblName);
+    if (table == null) {
+      return super.listPartitions(catName, dbName, tblName, partVals, 
maxParts);
+    }
+    TempTable tt = getPartitionedTempTable(table);
+    List<Partition> partitions = tt.getPartitionsByPartitionVals(partVals);
+    List<Partition> matchedParts = new ArrayList<>();
+    for(int i = 0; i < ((maxParts < 0 || maxParts > partitions.size()) ? 
partitions.size() : maxParts); i++) {
+      matchedParts.add(deepCopy(partitions.get(i)));
+    }
+    return matchedParts;
+  }
+
+  @Override
+  public PartitionSpecProxy listPartitionSpecs(String catName, String dbName, 
String tableName,
+      int maxParts) throws TException {
+    org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, 
tableName);
+    if (table == null) {
+      return super.listPartitionSpecs(catName, dbName, tableName, maxParts);
+    }
+    TempTable tt = getPartitionedTempTable(table);
+    List<Partition> partitions = tt.listPartitions();
+    if (partitions.isEmpty()) {
+      throw new NoSuchObjectException("Partition for table " + tableName + " 
in database " +
+          dbName + " is not found.");
+    }
+    List<PartitionSpec> partitionSpecs;
+    PartitionSpec partitionSpec = new PartitionSpec();
+    PartitionListComposingSpec partitionListComposingSpec = new 
PartitionListComposingSpec(new ArrayList<>());
+    for (int i = 0; i < ((maxParts < 0 || maxParts > partitions.size()) ? 
partitions.size() : maxParts); i++) {
+      partitionListComposingSpec.addToPartitions(deepCopy(partitions.get(i)));
+    }
+    partitionSpec.setCatName(catName);
+    partitionSpec.setDbName(dbName);
+    partitionSpec.setTableName(tableName);
+    partitionSpec.setRootPath(table.getSd().getLocation());
+    partitionSpec.setPartitionList(partitionListComposingSpec);
+    partitionSpecs = Arrays.asList(partitionSpec);
+
+    return PartitionSpecProxy.Factory.get(partitionSpecs);
+  }
 
   @Override
   public List<Partition> getPartitionsByNames(String catName, String dbName, 
String tblName,
@@ -1228,12 +1340,8 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
       //(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);
@@ -1247,13 +1355,7 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
     if (table == null) {
       return super.getPartitionWithAuthInfo(catName, dbName, tableName, pvals, 
userName, groupNames);
     }
-    assertPartitioned(table);
     TempTable tt = getPartitionedTempTable(table);
-    if (tt == null) {
-      throw new IllegalStateException("TempTable not found for " +
-              getCatalogQualifiedTableName(table));
-    }
-
     Partition partition = tt.getPartitionWithAuthInfo(pvals, userName, 
groupNames);
     if (partition == null) {
       throw new NoSuchObjectException("Partition with partition values " +
@@ -1265,7 +1367,7 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
     return deepCopy(partition);
   }
 
-  private static TempTable 
getPartitionedTempTable(org.apache.hadoop.hive.metastore.api.Table t) {
+  private  TempTable 
getPartitionedTempTable(org.apache.hadoop.hive.metastore.api.Table t) throws 
MetaException {
     String qualifiedTableName = Warehouse.
         getQualifiedName(t.getDbName().toLowerCase(), 
t.getTableName().toLowerCase());
     SessionState ss = SessionState.get();
@@ -1273,9 +1375,15 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
       LOG.warn("No current SessionState, skipping temp partitions for " + 
qualifiedTableName);
       return null;
     }
-    return ss.getTempPartitions().get(qualifiedTableName);
+    assertPartitioned(t);
+    TempTable tt = ss.getTempPartitions().get(qualifiedTableName);
+    if (tt == null) {
+      throw new IllegalStateException("TempTable not found for " +
+          getCatalogQualifiedTableName(t));
+    }
+    return tt;
   }
-  private static void 
removeTempTable(org.apache.hadoop.hive.metastore.api.Table t) {
+  private void removeTempTable(org.apache.hadoop.hive.metastore.api.Table t) {
     String qualifiedTableName = Warehouse.
         getQualifiedName(t.getDbName().toLowerCase(), 
t.getTableName().toLowerCase());
     SessionState ss = SessionState.get();
@@ -1285,7 +1393,7 @@ public class SessionHiveMetaStoreClient extends 
HiveMetaStoreClient implements I
     }
     ss.getTempPartitions().remove(Warehouse.getQualifiedName(t));
   }
-  private static void 
createTempTable(org.apache.hadoop.hive.metastore.api.Table t) {
+  private void createTempTable(org.apache.hadoop.hive.metastore.api.Table t) {
     if(t.getPartitionKeysSize() <= 0) {
       //do nothing as it's not a partitioned table
       return;
diff --git 
a/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestSessionHiveMetastoreClientListPartitionsTempTable.java
 
b/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestSessionHiveMetastoreClientListPartitionsTempTable.java
new file mode 100644
index 0000000..a74b543
--- /dev/null
+++ 
b/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestSessionHiveMetastoreClientListPartitionsTempTable.java
@@ -0,0 +1,236 @@
+/*
+ * 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.
+ */
+
+package org.apache.hadoop.hive.ql.metadata;
+
+import com.google.common.collect.Lists;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.IMetaStoreClient;
+import org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
+import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet;
+import org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.client.CustomIgnoreRule;
+import org.apache.hadoop.hive.metastore.client.TestListPartitions;
+import org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder;
+import org.apache.hadoop.hive.metastore.client.builder.TableBuilder;
+import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService;
+import org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.thrift.TException;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static junit.framework.TestCase.assertFalse;
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Test class for list partitions related methods on temporary tables.
+ */
+@RunWith(Parameterized.class)
+@Category(MetastoreCheckinTest.class)
+public class TestSessionHiveMetastoreClientListPartitionsTempTable
+    extends TestListPartitions {
+
+  private HiveConf conf;
+
+  private static final String PART_PRIV = "PARTITION_LEVEL_PRIVILEGE";
+
+  public TestSessionHiveMetastoreClientListPartitionsTempTable(String name, 
AbstractMetaStoreService metaStore) {
+    super(name, metaStore);
+    ignoreRule = new CustomIgnoreRule();
+  }
+
+  @Before
+  public void setUp() throws Exception {
+    initHiveConf();
+    SessionState.start(conf);
+    setClient(Hive.get(conf).getMSC());
+    getClient().dropDatabase(DB_NAME, true, true, true);
+    getMetaStore().cleanWarehouseDirs();
+  }
+
+  private void initHiveConf() throws HiveException {
+    conf = Hive.get().getConf();
+    conf.setBoolVar(HiveConf.ConfVars.METASTORE_FASTPATH, true);
+  }
+
+  @Override
+  protected Table createTestTable(IMetaStoreClient client, String dbName, 
String tableName,
+      List<String> partCols, boolean setPartitionLevelPrivileges) throws 
TException {
+    TableBuilder builder =
+        new 
TableBuilder().setDbName(dbName).setTableName(tableName).addCol("id", "int")
+            .addCol("name", "string").setTemporary(true);
+
+    partCols.forEach(col -> builder.addPartCol(col, "string"));
+    Table table = builder.build(conf);
+
+    if (setPartitionLevelPrivileges) {
+      table.putToParameters(PART_PRIV, "true");
+    }
+
+    client.createTable(table);
+    return table;
+  }
+
+  @Override
+  protected void addPartition(IMetaStoreClient client, Table table, 
List<String> values) throws TException {
+    PartitionBuilder builder = new PartitionBuilder().inTable(table);
+    values.forEach(builder::addValue);
+    Partition partition = builder.build(conf);
+    if (table.getParameters().containsKey(PART_PRIV) && 
table.getParameters().get(PART_PRIV).equals("true")) {
+      PrincipalPrivilegeSet privileges = new PrincipalPrivilegeSet();
+      Map<String, List<PrivilegeGrantInfo>> userPrivileges = new HashMap<>();
+      userPrivileges.put(USER_NAME, new ArrayList<>());
+      privileges.setUserPrivileges(userPrivileges);
+
+      Map<String, List<PrivilegeGrantInfo>> groupPrivileges = new HashMap<>();
+      groupPrivileges.put(GROUP, new ArrayList<>());
+      privileges.setGroupPrivileges(groupPrivileges);
+      partition.setPrivileges(privileges);
+    }
+    client.add_partition(partition);
+  }
+
+  @Override
+  protected void assertAuthInfoReturned(String userName, String group, 
Partition partition) {
+    PrincipalPrivilegeSet privileges = partition.getPrivileges();
+    assertNotNull(privileges);
+    assertTrue(privileges.getUserPrivileges().containsKey(userName));
+    assertTrue(privileges.getGroupPrivileges().containsKey(group));
+  }
+
+  @Test
+  @Override
+  public void testListPartitionsAllHighMaxParts() throws Exception {
+    List<List<String>> testData = createTable4PartColsParts(getClient());
+    List<Partition> partitions = getClient().listPartitions(DB_NAME, 
TABLE_NAME, (short) 101);
+    assertFalse(partitions.isEmpty());
+    assertEquals(testData.size(), partitions.size());
+  }
+
+  @Test(expected = MetaException.class)
+  @Override
+  public void testListPartitionsAllNullTblName() throws Exception {
+    super.testListPartitionsAllNullTblName();
+  }
+
+  @Test(expected = MetaException.class)
+  @Override
+  public void testListPartitionsAllNullDbName() throws Exception {
+    super.testListPartitionsAllNullDbName();
+  }
+
+  @Test
+  @Override
+  public void testListPartitionSpecsHighMaxParts() throws Exception {
+    List<List<String>> testValues = createTable4PartColsParts(getClient());
+    PartitionSpecProxy partitionSpecs = 
getClient().listPartitionSpecs(DB_NAME, TABLE_NAME, 101);
+    assertNotNull(partitionSpecs);
+    assertPartitionsSpecProxy(partitionSpecs, testValues);
+  }
+
+  @Test(expected = MetaException.class)
+  @Override
+  public void testListPartitionSpecsNullTblName() throws Exception {
+    super.testListPartitionSpecsNullTblName();
+  }
+
+  @Test
+  @Override
+  public void testListPartitionsWithAuthHighMaxParts() throws Exception {
+    createTable4PartColsPartsAuthOn(getClient());
+    List<Partition> partitions =
+        getClient().listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, (short) 
101, USER_NAME, Lists.newArrayList(GROUP));
+    partitions.forEach(p -> assertAuthInfoReturned(USER_NAME, GROUP, p));
+  }
+
+  @Test(expected = NoSuchObjectException.class)
+  @Override
+  public void testListPartitionsWithAuthNullGroup()
+      throws Exception {
+    super.testListPartitionsWithAuthNullGroup();
+  }
+
+  @Test(expected = NoSuchObjectException.class)
+  @Override
+  public void testListPartitionsWithAuthByValues()
+      throws Exception {
+    super.testListPartitionsWithAuthByValues();
+  }
+
+  @Test(expected = MetaException.class)
+  @Override
+  public void testListPartitionsWithAuthByValuesNullDbName()
+      throws Exception {
+    super.testListPartitionsWithAuthByValuesNullDbName();
+  }
+
+  @Test(expected = MetaException.class)
+  @Override
+  public void testListPartitionsWithAuthByValuesNullTblName()
+      throws Exception {
+    super.testListPartitionsWithAuthByValuesNullTblName();
+  }
+
+  @Test(expected = MetaException.class)
+  @Override
+  public void testListPartitionNamesNullDbName() throws Exception {
+    super.testListPartitionNamesNullDbName();
+  }
+
+  @Test(expected = MetaException.class)
+  @Override
+  public void testListPartitionNamesNullTblName() throws Exception {
+    super.testListPartitionNamesNullTblName();
+  }
+
+  @Test(expected = MetaException.class)
+  @Override
+  public void testListPartitionNamesByValuesNullDbName()
+      throws Exception {
+    super.testListPartitionNamesByValuesNullDbName();
+  }
+
+  @Test(expected = MetaException.class)
+  @Override
+  public void testListPartitionNamesByValuesNullTblName()
+      throws Exception {
+    super.testListPartitionNamesByValuesNullTblName();
+  }
+
+  @Test
+  @Override
+  public void testListPartitionsWithAuthNoTable() throws Exception {
+    getClient().listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, (short)-1, "", 
Lists.newArrayList());
+  }
+
+}
diff --git 
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/ConditionalIgnoreOnSessionHiveMetastoreClient.java
 
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/ConditionalIgnoreOnSessionHiveMetastoreClient.java
index 99039b0..baa1a6f 100644
--- 
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/ConditionalIgnoreOnSessionHiveMetastoreClient.java
+++ 
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/ConditionalIgnoreOnSessionHiveMetastoreClient.java
@@ -25,7 +25,7 @@ import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
 /**
- * This annotation provides a way to skip the execution of seome tests,
+ * This annotation provides a way to skip the execution of some tests,
  * when a certain runtime criteria is met. It should be used together with 
{@link CustomIgnoreRule}.
  */
 @Retention(RetentionPolicy.RUNTIME)
diff --git 
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java
 
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java
index 34ceb34..94d37c2 100644
--- 
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java
+++ 
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java
@@ -74,8 +74,10 @@ public class TestListPartitions 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";
+  protected static final String USER_NAME = "user0";
+  protected static final String GROUP = "group0";
 
   public TestListPartitions(String name, AbstractMetaStoreService metaStore) {
     this.metaStore = metaStore;
@@ -89,6 +91,7 @@ public class TestListPartitions extends MetaStoreClientTest {
     // Clean up the database
     client.dropDatabase(DB_NAME, true, true, true);
     createDB(DB_NAME);
+
   }
 
   @After
@@ -106,6 +109,22 @@ public class TestListPartitions extends 
MetaStoreClientTest {
     }
   }
 
+  protected AbstractMetaStoreService getMetaStore() {
+    return metaStore;
+  }
+
+  protected void setMetaStore(AbstractMetaStoreService metaStore) {
+    this.metaStore = metaStore;
+  }
+
+  protected IMetaStoreClient getClient() {
+    return client;
+  }
+
+  protected void setClient(IMetaStoreClient client) {
+    this.client = client;
+  }
+
   private void createDB(String dbName) throws TException {
     new DatabaseBuilder().
             setName(dbName).
@@ -119,7 +138,7 @@ public class TestListPartitions extends MetaStoreClientTest 
{
   }
 
 
-  private Table createTestTable(IMetaStoreClient client, String dbName, String 
tableName,
+  protected Table createTestTable(IMetaStoreClient client, String dbName, 
String tableName,
                                        List<String> partCols, boolean 
setPartitionLevelPrivilages)
           throws TException {
     TableBuilder builder = new TableBuilder()
@@ -139,7 +158,7 @@ public class TestListPartitions extends MetaStoreClientTest 
{
     return table;
   }
 
-  private void addPartition(IMetaStoreClient client, Table table, List<String> 
values)
+  protected void addPartition(IMetaStoreClient client, Table table, 
List<String> values)
           throws TException {
     PartitionBuilder partitionBuilder = new PartitionBuilder().inTable(table);
     values.forEach(val -> partitionBuilder.addValue(val));
@@ -153,7 +172,7 @@ public class TestListPartitions extends MetaStoreClientTest 
{
     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);
   }
 
@@ -175,17 +194,17 @@ public class TestListPartitions extends 
MetaStoreClientTest {
     return testValues;
   }
 
-  private List<List<String>> createTable4PartColsParts(IMetaStoreClient 
client) throws
+  protected List<List<String>> createTable4PartColsParts(IMetaStoreClient 
client) throws
           Exception {
     return createTable4PartColsPartsGeneric(client, false);
   }
 
-  private List<List<String>> createTable4PartColsPartsAuthOn(IMetaStoreClient 
client) throws
+  protected List<List<String>> 
createTable4PartColsPartsAuthOn(IMetaStoreClient client) throws
           Exception {
     return createTable4PartColsPartsGeneric(client, true);
   }
 
-  private static void assertAuthInfoReturned(String user, String group, 
Partition partition) {
+  protected void assertAuthInfoReturned(String user, String group, Partition 
partition) {
     assertNotNull(partition.getPrivileges());
     assertEquals(Lists.newArrayList(),
             partition.getPrivileges().getUserPrivileges().get(user));
@@ -195,15 +214,17 @@ public class TestListPartitions extends 
MetaStoreClientTest {
             partition.getPrivileges().getRolePrivileges().get("public"));
   }
 
-  private static void assertPartitionsHaveCorrectValues(List<Partition> 
partitions,
+  private void assertPartitionsHaveCorrectValues(List<Partition> partitions,
                                                List<List<String>> testValues) 
throws Exception {
     assertEquals(testValues.size(), partitions.size());
+    partitions.forEach(p -> {});
+
     for (int i = 0; i < partitions.size(); ++i) {
       assertEquals(testValues.get(i), partitions.get(i).getValues());
     }
   }
 
-  private static void assertCorrectPartitionNames(List<String> names,
+  private void assertCorrectPartitionNames(List<String> names,
                                                   List<List<String>> 
testValues,
                                                   List<String>partCols) throws 
Exception {
     assertEquals(testValues.size(), names.size());
@@ -216,7 +237,7 @@ public class TestListPartitions extends MetaStoreClientTest 
{
     }
   }
 
-  private static void assertPartitionsSpecProxy(PartitionSpecProxy 
partSpecProxy,
+  protected void assertPartitionsSpecProxy(PartitionSpecProxy partSpecProxy,
                                                 List<List<String>> testValues) 
throws Exception {
     assertEquals(testValues.size(), partSpecProxy.size());
     List<PartitionSpec> partitionSpecs = partSpecProxy.toPartitionSpec();
@@ -228,7 +249,7 @@ public class TestListPartitions extends MetaStoreClientTest 
{
     }
   }
 
-  private static void assertCorrectPartitionValuesResponse(List<List<String>> 
testValues,
+  private void assertCorrectPartitionValuesResponse(List<List<String>> 
testValues,
                                          PartitionValuesResponse resp) throws 
Exception {
     assertEquals(testValues.size(), resp.getPartitionValuesSize());
     List<PartitionValuesRow> rowList = resp.getPartitionValues();
@@ -478,19 +499,18 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   @Test
   public void testListPartitionsWithAuth() throws Exception {
     List<List<String>> partValues = createTable4PartColsPartsAuthOn(client);
-    String user = "user0";
-    List<String> groups = Lists.newArrayList("group0");
+    List<String> groups = Lists.newArrayList(GROUP);
     List<Partition> partitions = client.listPartitionsWithAuthInfo(DB_NAME, 
TABLE_NAME, (short)-1,
-            user, groups);
+            USER_NAME, groups);
 
     assertEquals(4, partitions.size());
     assertPartitionsHaveCorrectValues(partitions, partValues);
-    partitions.forEach(partition -> assertAuthInfoReturned(user, 
groups.get(0), partition));
+    partitions.forEach(partition -> assertAuthInfoReturned(USER_NAME, 
groups.get(0), partition));
 
-    partitions = client.listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, 
(short)2, user, groups);
+    partitions = client.listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, 
(short)2, USER_NAME, groups);
     assertEquals(2, partitions.size());
     assertPartitionsHaveCorrectValues(partitions, partValues.subList(0, 2));
-    partitions.forEach(partition -> assertAuthInfoReturned(user, 
groups.get(0), partition));
+    partitions.forEach(partition -> assertAuthInfoReturned(USER_NAME, 
groups.get(0), partition));
   }
 
   @Test(expected = MetaException.class)
@@ -500,6 +520,19 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test
+  public void testListPartitionsWithAuthLowMaxParts() throws Exception {
+    createTable4PartColsPartsAuthOn(getClient());
+    List<Partition> partitions =
+        getClient().listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, (short) 2, 
USER_NAME, Lists.newArrayList(GROUP));
+    assertTrue(partitions.size() == 2);
+    partitions.forEach(p -> assertAuthInfoReturned(USER_NAME, GROUP, p));
+    partitions = getClient().listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, 
(short) -1, USER_NAME,
+        Lists.newArrayList(GROUP));
+    assertTrue(partitions.size() == 4);
+    partitions.forEach(p -> assertAuthInfoReturned(USER_NAME, GROUP, p));
+  }
+
+  @Test
   public void testListPartitionsWithAuthNoPrivilegesSet() throws Exception {
     List<List<String>> partValues = createTable4PartColsParts(client);
     List<Partition> partitions = client.listPartitionsWithAuthInfo(DB_NAME, 
TABLE_NAME, (short)-1,
@@ -573,29 +606,28 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   @Test
   public void testListPartitionsWithAuthByValues() throws Exception {
     List<List<String>> partValues = createTable4PartColsPartsAuthOn(client);
-    String user = "user0";
-    List<String> groups = Lists.newArrayList("group0");
+    List<String> groups = Lists.newArrayList(GROUP);
 
     List<Partition> partitions = client.listPartitionsWithAuthInfo(DB_NAME, 
TABLE_NAME, Lists
-            .newArrayList("2017", "11", "27"), (short)-1, user, groups);
+            .newArrayList("2017", "11", "27"), (short)-1, USER_NAME, groups);
     assertEquals(1, partitions.size());
     assertPartitionsHaveCorrectValues(partitions, partValues.subList(3, 4));
-    partitions.forEach(partition -> assertAuthInfoReturned(user, 
groups.get(0), partition));
+    partitions.forEach(partition -> assertAuthInfoReturned(USER_NAME, 
groups.get(0), partition));
 
     partitions = client.listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, Lists
-            .newArrayList("2017"), (short)-1, user, groups);
+            .newArrayList("2017"), (short)-1, USER_NAME, groups);
     assertEquals(2, partitions.size());
     assertPartitionsHaveCorrectValues(partitions, partValues.subList(2, 4));
-    partitions.forEach(partition -> assertAuthInfoReturned(user, 
groups.get(0), partition));
+    partitions.forEach(partition -> assertAuthInfoReturned(USER_NAME, 
groups.get(0), partition));
 
     partitions = client.listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, Lists
-            .newArrayList("2017"), (short)1, user, groups);
+            .newArrayList("2017"), (short)1, USER_NAME, groups);
     assertEquals(1, partitions.size());
     assertPartitionsHaveCorrectValues(partitions, partValues.subList(2, 3));
-    partitions.forEach(partition -> assertAuthInfoReturned(user, 
groups.get(0), partition));
+    partitions.forEach(partition -> assertAuthInfoReturned(USER_NAME, 
groups.get(0), partition));
 
     partitions = client.listPartitionsWithAuthInfo(DB_NAME, TABLE_NAME, Lists
-            .newArrayList("2013"), (short)-1, user, groups);
+            .newArrayList("2013"), (short)-1, USER_NAME, groups);
     assertTrue(partitions.isEmpty());
   }
 
@@ -723,7 +755,9 @@ public class TestListPartitions extends MetaStoreClientTest 
{
    * Testing listPartitionsByFilter(String,String,String,short) ->
    *         get_partitions_by_filter(String,String,String,short).
    */
+
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionsByFilter() throws Exception {
     List<List<String>> partValues = createTable4PartColsParts(client);
     List<Partition> partitions = client.listPartitionsByFilter(DB_NAME, 
TABLE_NAME,
@@ -746,6 +780,7 @@ public class TestListPartitions extends MetaStoreClientTest 
{
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionsByFilterCaseInsensitive() throws Exception {
     String tableName = TABLE_NAME + "_caseinsensitive";
     Table t = createTestTable(client, DB_NAME, tableName,
@@ -788,6 +823,7 @@ public class TestListPartitions extends MetaStoreClientTest 
{
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionsByFilterCaseSensitive() throws Exception {
     String tableName = TABLE_NAME + "_casesensitive";
     Table t = createTestTable(client, DB_NAME, tableName,
@@ -823,41 +859,48 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test(expected = MetaException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionsByFilterInvalidFilter() throws Exception {
     createTable4PartColsParts(client);
     client.listPartitionsByFilter(DB_NAME, TABLE_NAME, "yyy=\"2017\"", 
(short)101);
   }
 
   @Test(expected = MetaException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionsByFilterHighMaxParts() throws Exception {
     createTable4PartColsParts(client);
     client.listPartitionsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\"", 
(short)101);
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionsByFilterNoTblName() throws Exception {
     createTable4PartColsParts(client);
     client.listPartitionsByFilter(DB_NAME, "", "yyyy=\"2017\"", (short)-1);
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionsByFilterNoDbName() throws Exception {
     createTable4PartColsParts(client);
     client.listPartitionsByFilter("", TABLE_NAME, "yyyy=\"2017\"", (short)-1);
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionsByFilterNoTable() throws Exception {
     client.listPartitionsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\"", 
(short)-1);
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionsByFilterNoDb() throws Exception {
     client.dropDatabase(DB_NAME);
     client.listPartitionsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\"", 
(short)-1);
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionsByFilterNullTblName() throws Exception {
     try {
       createTable4PartColsParts(client);
@@ -869,6 +912,7 @@ public class TestListPartitions extends MetaStoreClientTest 
{
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionsByFilterNullDbName() throws Exception {
     try {
       createTable4PartColsParts(client);
@@ -880,6 +924,7 @@ public class TestListPartitions extends MetaStoreClientTest 
{
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionsByFilterNullFilter() throws Exception {
     createTable4PartColsParts(client);
     List<Partition> partitions = client.listPartitionsByFilter(DB_NAME, 
TABLE_NAME, null,
@@ -888,6 +933,7 @@ public class TestListPartitions extends MetaStoreClientTest 
{
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionsByFilterEmptyFilter() throws Exception {
     createTable4PartColsParts(client);
     List<Partition> partitions = client.listPartitionsByFilter(DB_NAME, 
TABLE_NAME, "", (short)-1);
@@ -901,6 +947,7 @@ public class TestListPartitions extends MetaStoreClientTest 
{
    *         get_part_specs_by_filter(String,String,String,int).
    */
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionsSpecsByFilter() throws Exception {
     List<List<String>> testValues = createTable4PartColsParts(client);
     PartitionSpecProxy partSpecProxy = 
client.listPartitionSpecsByFilter(DB_NAME, TABLE_NAME,
@@ -933,53 +980,62 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test(expected = MetaException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionSpecsByFilterInvalidFilter() throws Exception {
     createTable4PartColsParts(client);
     client.listPartitionSpecsByFilter(DB_NAME, TABLE_NAME, "yyy=\"2017\"", 
101);
   }
 
   @Test(expected = MetaException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionSpecsByFilterHighMaxParts() throws Exception {
     createTable4PartColsParts(client);
     client.listPartitionSpecsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\"", 
101);
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionSpecsByFilterNoTblName() throws Exception {
     createTable4PartColsParts(client);
     client.listPartitionSpecsByFilter(DB_NAME, "", "yyyy=\"2017\"", -1);
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionSpecsByFilterNoDbName() throws Exception {
     createTable4PartColsParts(client);
     client.listPartitionSpecsByFilter("", TABLE_NAME, "yyyy=\"2017\"", -1);
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionSpecsByFilterNoTable() throws Exception {
     client.listPartitionSpecsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\"", 
-1);
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionSpecsByFilterNoDb() throws Exception {
     client.dropDatabase(DB_NAME);
     client.listPartitionSpecsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\"", 
-1);
   }
 
   @Test(expected = MetaException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionSpecsByFilterNullTblName() throws Exception {
     createTable4PartColsParts(client);
     client.listPartitionSpecsByFilter(DB_NAME, null, "yyyy=\"2017\"", -1);
   }
 
   @Test(expected = MetaException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionSpecsByFilterNullDbName() throws Exception {
     createTable4PartColsParts(client);
     client.listPartitionSpecsByFilter(null, TABLE_NAME, "yyyy=\"2017\"", -1);
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionSpecsByFilterNullFilter() throws Exception {
     List<List<String>> values = createTable4PartColsParts(client);
     PartitionSpecProxy pproxy = client.listPartitionSpecsByFilter(DB_NAME, 
TABLE_NAME, null, -1);
@@ -987,6 +1043,7 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionSpecsByFilterEmptyFilter() throws Exception {
     List<List<String>> values = createTable4PartColsParts(client);
     PartitionSpecProxy pproxy = client.listPartitionSpecsByFilter(DB_NAME, 
TABLE_NAME, "", -1);
@@ -1000,6 +1057,7 @@ public class TestListPartitions extends 
MetaStoreClientTest {
    *         get_num_partitions_by_filter(String,String,String).
    */
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testGetNumPartitionsByFilter() throws Exception {
     createTable4PartColsParts(client);
     int n = client.getNumPartitionsByFilter(DB_NAME, TABLE_NAME, 
"yyyy=\"2017\" OR " +
@@ -1024,47 +1082,55 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test(expected = MetaException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testGetNumPartitionsByFilterInvalidFilter() throws Exception {
     createTable4PartColsParts(client);
     client.getNumPartitionsByFilter(DB_NAME, TABLE_NAME, "yyy=\"2017\"");
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testGetNumPartitionsByFilterNoTblName() throws Exception {
     createTable4PartColsParts(client);
     client.getNumPartitionsByFilter(DB_NAME, "", "yyyy=\"2017\"");
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testGetNumPartitionsByFilterNoDbName() throws Exception {
     createTable4PartColsParts(client);
     client.getNumPartitionsByFilter("", TABLE_NAME, "yyyy=\"2017\"");
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testGetNumPartitionsByFilterNoTable() throws Exception {
     client.getNumPartitionsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\"");
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testGetNumPartitionsByFilterNoDb() throws Exception {
     client.dropDatabase(DB_NAME);
     client.getNumPartitionsByFilter(DB_NAME, TABLE_NAME, "yyyy=\"2017\"");
   }
 
   @Test(expected = MetaException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testGetNumPartitionsByFilterNullTblName() throws Exception {
     createTable4PartColsParts(client);
     client.getNumPartitionsByFilter(DB_NAME, null, "yyyy=\"2017\"");
   }
 
   @Test(expected = MetaException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testGetNumPartitionsByFilterNullDbName() throws Exception {
     createTable4PartColsParts(client);
     client.getNumPartitionsByFilter(null, TABLE_NAME, "yyyy=\"2017\"");
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testGetNumPartitionsByFilterNullFilter() throws Exception {
     createTable4PartColsParts(client);
     int n = client.getNumPartitionsByFilter(DB_NAME, TABLE_NAME, null);
@@ -1188,6 +1254,21 @@ public class TestListPartitions extends 
MetaStoreClientTest {
             Lists.newArrayList("yyyy", "mm", "dd"));
   }
 
+  @Test
+  public void testListPartitionNamesByValuesLowPartCount() throws Exception {
+    List<List<String>> testValues = createTable4PartColsParts(client);
+    List<String> partitionNames = client.listPartitionNames(DB_NAME, 
TABLE_NAME,
+        Lists.newArrayList("2017"), (short) 1);
+    assertTrue(partitionNames.size() == 1);
+    assertCorrectPartitionNames(partitionNames, testValues.subList(2, 3),
+        Lists.newArrayList("yyyy", "mm", "dd"));
+    partitionNames = client.listPartitionNames(DB_NAME, TABLE_NAME,
+        Lists.newArrayList("2017"), (short) -1);
+    assertTrue(partitionNames.size() == 2);
+    assertCorrectPartitionNames(partitionNames, testValues.subList(2, 4),
+        Lists.newArrayList("yyyy", "mm", "dd"));
+  }
+
   @Test(expected = MetaException.class)
   public void testListPartitionNamesByValuesNoPartVals() throws Exception {
     createTable4PartColsParts(client);
@@ -1259,6 +1340,7 @@ public class TestListPartitions extends 
MetaStoreClientTest {
    *         get_partition_values(PartitionValuesRequest).
    */
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionValues() throws Exception {
     List<List<String>> testValues = createTable4PartColsParts(client);
     List<FieldSchema> partitionSchema = Lists.newArrayList(
@@ -1273,6 +1355,7 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionValuesEmptySchema() throws Exception {
     try {
       List<List<String>> testValues = createTable4PartColsParts(client);
@@ -1288,6 +1371,7 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionValuesNoDbName() throws Exception {
     createTable4PartColsParts(client);
     List<FieldSchema> partitionSchema = Lists.newArrayList(
@@ -1300,6 +1384,7 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionValuesNoTblName() throws Exception {
     createTable4PartColsParts(client);
     List<FieldSchema> partitionSchema = Lists.newArrayList(
@@ -1312,6 +1397,7 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test(expected = MetaException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionValuesNoTable() throws Exception {
     List<FieldSchema> partitionSchema = Lists.newArrayList(
             new FieldSchema("yyyy", "string", ""),
@@ -1323,6 +1409,7 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test(expected = MetaException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionValuesNoDb() throws Exception {
     client.dropDatabase(DB_NAME);
     List<FieldSchema> partitionSchema = Lists.newArrayList(
@@ -1335,6 +1422,7 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionValuesNullDbName() throws Exception {
     try {
       createTable4PartColsParts(client);
@@ -1352,6 +1440,7 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionValuesNullTblName() throws Exception {
     try {
       createTable4PartColsParts(client);
@@ -1369,6 +1458,7 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionValuesNullSchema() throws Exception {
     try {
       createTable4PartColsParts(client);
@@ -1382,6 +1472,7 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void testListPartitionValuesNullRequest() throws Exception {
     try {
       createTable4PartColsParts(client);
@@ -1393,6 +1484,7 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void otherCatalog() throws TException {
     String catName = "list_partition_catalog";
     Catalog cat = new CatalogBuilder()
@@ -1464,54 +1556,63 @@ public class TestListPartitions extends 
MetaStoreClientTest {
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void listPartitionsBogusCatalog() throws TException {
     createTable3PartCols1Part(client);
     client.listPartitions("bogus", DB_NAME, TABLE_NAME, -1);
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void listPartitionsWithPartialValuesBogusCatalog() throws TException {
     createTable3PartCols1Part(client);
     client.listPartitions("bogus", DB_NAME, TABLE_NAME, 
Collections.singletonList("a0"), -1);
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void listPartitionsSpecsBogusCatalog() throws TException {
     createTable3PartCols1Part(client);
     client.listPartitionSpecs("bogus", DB_NAME, TABLE_NAME, -1);
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void listPartitionsByFilterBogusCatalog() throws TException {
     createTable3PartCols1Part(client);
     client.listPartitionsByFilter("bogus", DB_NAME, TABLE_NAME, 
"partcol=\"a0\"", -1);
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void listPartitionSpecsByFilterBogusCatalog() throws TException {
     createTable3PartCols1Part(client);
     client.listPartitionSpecsByFilter("bogus", DB_NAME, TABLE_NAME, 
"partcol=\"a0\"", -1);
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void getNumPartitionsByFilterBogusCatalog() throws TException {
     createTable3PartCols1Part(client);
     client.getNumPartitionsByFilter("bogus", DB_NAME, TABLE_NAME, 
"partcol=\"a0\"");
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void listPartitionNamesBogusCatalog() throws TException {
     createTable3PartCols1Part(client);
     client.listPartitionNames("bogus", DB_NAME, TABLE_NAME, -1);
   }
 
   @Test(expected = NoSuchObjectException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void listPartitionNamesPartialValsBogusCatalog() throws TException {
     createTable3PartCols1Part(client);
     client.listPartitionNames("bogus", DB_NAME, TABLE_NAME, 
Collections.singletonList("a0"), -1);
   }
 
   @Test(expected = MetaException.class)
+  @ConditionalIgnoreOnSessionHiveMetastoreClient
   public void listPartitionValuesBogusCatalog() throws TException {
     createTable3PartCols1Part(client);
     PartitionValuesRequest rqst = new PartitionValuesRequest(DB_NAME,

Reply via email to