vikramahuja1001 commented on code in PR #4501:
URL: https://github.com/apache/hive/pull/4501#discussion_r1273047882


##########
ql/src/test/org/apache/hadoop/hive/ql/exec/TestGetPartitionInBatches.java:
##########
@@ -0,0 +1,245 @@
+/*
+ * 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.exec;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
+import org.apache.hadoop.hive.metastore.api.*;
+import org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder;
+import org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat;
+import org.apache.hadoop.hive.ql.metadata.Hive;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.hadoop.hive.ql.stats.StatsUtils;
+import org.apache.hadoop.mapred.TextInputFormat;
+import org.apache.hadoop.util.StringUtils;
+import org.junit.*;
+import org.mockito.ArgumentCaptor;
+
+import java.util.*;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.times;
+
+public class TestGetPartitionInBatches {
+
+    private final String catName = "hive";
+    private final String dbName = "default";
+    private final String tableName = "test_partition_batch";
+    private static HiveConf hiveConf;
+    private static HiveMetaStoreClient db;
+    private static Hive hive;
+    private Table table;
+
+    @BeforeClass
+    public static void setupClass() throws HiveException {
+        hiveConf = new HiveConf(TestMsckCreatePartitionsInBatches.class);
+        hive = Hive.get();
+        SessionState.start(hiveConf);
+        try {
+            db = new HiveMetaStoreClient(hiveConf);
+        } catch (MetaException e) {
+            throw new HiveException(e);
+        }
+    }
+
+    @Before
+    public void before() throws Exception {
+        createPartitionedTable(catName, dbName, tableName);
+        table = db.getTable(catName, dbName, tableName);
+        addPartitions(dbName, tableName);
+    }
+
+    @After
+    public void after() throws Exception {
+        cleanUpTableQuietly(catName, dbName, tableName);
+    }
+
+    private Table createPartitionedTable(String catName, String dbName, String 
tableName) throws Exception {
+        try {
+            db.dropTable(catName, dbName, tableName);
+            Table table = new Table();
+            table.setCatName(catName);
+            table.setDbName(dbName);
+            table.setTableName(tableName);
+            FieldSchema col1 = new FieldSchema("key", "string", "");
+            FieldSchema col2 = new FieldSchema("value", "int", "");
+            FieldSchema col3 = new FieldSchema("city", "string", "");
+            StorageDescriptor sd = new StorageDescriptor();
+            sd.setSerdeInfo(new SerDeInfo());
+            sd.setInputFormat(TextInputFormat.class.getCanonicalName());
+            
sd.setOutputFormat(HiveIgnoreKeyTextOutputFormat.class.getCanonicalName());
+            sd.setCols(Arrays.asList(col1, col2));
+            table.setPartitionKeys(Arrays.asList(col3));
+            table.setSd(sd);
+            db.createTable(table);
+            return db.getTable(catName, dbName, tableName);
+        } catch (Exception exception) {
+            fail("Unable to drop and create table " + 
StatsUtils.getFullyQualifiedTableName(dbName, tableName) + " because "
+                    + StringUtils.stringifyException(exception));
+            throw exception;
+        }
+    }
+
+    private void addPartitions(String dbName, String tableName) throws 
Exception {
+        List<Partition> partitions = new ArrayList<>();
+        for (int i = 0; i < 30; i++) {
+            partitions.add(buildPartition(dbName, tableName, 
String.valueOf(i), table.getSd().getLocation() + "/city=" + String.valueOf(i)));

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to