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

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

commit d781701d26859b78161514ac237119243f9bd1e3
Author: Stamatis Zampetakis <zabe...@gmail.com>
AuthorDate: Tue Feb 8 16:56:56 2022 +0100

    HIVE-26278: Add unit tests for Hive#getPartitionsByNames using batching 
(Stamatis Zampetakis, reviewed by Zoltan Haindrich, Krisztian Kasa, Ayush 
Saxena)
    
    Ensure that ValidWriteIdList is set when batching is involved in
    getPartitionByNames.
    
    Closes #3335
---
 ...TestHiveMetaStoreClientApiArgumentsChecker.java | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git 
a/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHiveMetaStoreClientApiArgumentsChecker.java
 
b/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHiveMetaStoreClientApiArgumentsChecker.java
index 6aefc44c563..175b47c47d8 100644
--- 
a/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHiveMetaStoreClientApiArgumentsChecker.java
+++ 
b/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHiveMetaStoreClientApiArgumentsChecker.java
@@ -38,10 +38,13 @@ import org.apache.hadoop.hive.ql.session.SessionState;
 import org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPEqualOrGreaterThan;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.thrift.TException;
+
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -80,6 +83,8 @@ public class TestHiveMetaStoreClientApiArgumentsChecker {
     hive.getConf().set(ValidTxnList.VALID_TXNS_KEY, "1:");
     hive.getConf().set(ValidWriteIdList.VALID_WRITEIDS_KEY, TABLE_NAME + 
":1:");
     hive.getConf().setVar(HiveConf.ConfVars.HIVE_TXN_MANAGER, 
"org.apache.hadoop.hive.ql.lockmgr.TestTxnManager");
+    // Pick a small number for the batch size to easily test code with 
multiple batches.
+    hive.getConf().setIntVar(HiveConf.ConfVars.METASTORE_BATCH_RETRIEVE_MAX, 
2);
     SessionState.start(hive.getConf());
     SessionState.get().initTxnMgr(hive.getConf());
     Context ctx = new Context(hive.getConf());
@@ -140,6 +145,26 @@ public class TestHiveMetaStoreClientApiArgumentsChecker {
     hive.getPartitionsByNames(t, new ArrayList<>(), true);
   }
 
+  @Test
+  public void testGetPartitionsByNamesWithSingleBatch() throws HiveException {
+    hive.getPartitionsByNames(t, Arrays.asList("Greece", "Italy"), true);
+  }
+
+  @Test
+  public void testGetPartitionsByNamesWithMultipleEqualSizeBatches()
+      throws HiveException {
+    List<String> names = Arrays.asList("Greece", "Italy", "France", "Spain");
+    hive.getPartitionsByNames(t, names, true);
+  }
+
+  @Test
+  public void testGetPartitionsByNamesWithMultipleUnequalSizeBatches()
+      throws HiveException {
+    List<String> names =
+        Arrays.asList("Greece", "Italy", "France", "Spain", "Hungary");
+    hive.getPartitionsByNames(t, names, true);
+  }
+
   @Test
   public void testGetPartitionsByExpr() throws HiveException, TException {
     List<Partition> partitions = new ArrayList<>();

Reply via email to