rbalamohan commented on a change in pull request #2578:
URL: https://github.com/apache/hive/pull/2578#discussion_r690003539
##########
File path:
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
##########
@@ -5096,37 +5097,74 @@ public Partition alterPartition(String catName, String
dbname, String name, List
}
@Override
- public List<Partition> alterPartitions(String catName, String dbname, String
name,
+ public List<Partition> alterPartitions(String catName, String dbName, String
tblName,
List<List<String>> part_vals, List<Partition>
newParts,
long writeId, String queryWriteIdList)
throws InvalidObjectException, MetaException
{
boolean success = false;
Exception e = null;
List<Partition> results = new ArrayList<>(newParts.size());
+ if (newParts.isEmpty()) {
+ return results;
+ }
try {
openTransaction();
- Iterator<List<String>> part_val_itr = part_vals.iterator();
- Set<MColumnDescriptor> oldCds = new HashSet<>();
- Ref<MColumnDescriptor> oldCdRef = new Ref<>();
- MTable table = null;
- for (Partition tmpPart: newParts) {
- List<String> tmpPartVals = part_val_itr.next();
- if (writeId > 0) {
- tmpPart.setWriteId(writeId);
+
+ MTable table = this.getMTable(catName, dbName, tblName);
+ List<String> partNames = new ArrayList<>();
+ for (List<String> partVal : part_vals) {
+ partNames.add(
+
Warehouse.makePartName(convertToFieldSchemas(table.getPartitionKeys()), partVal)
+ );
+ }
+
+ catName = normalizeIdentifier(catName);
+ dbName = normalizeIdentifier(dbName);
+ tblName = normalizeIdentifier(tblName);
+ List<MPartition> mPartitionList;
+
+ try (Query query = pm.newQuery(MPartition.class,
+ "table.tableName == t1 && table.database.name == t2 &&
t3.contains(partitionName) " +
+ " && table.database.catalogName == t4")) {
+ query.declareParameters("java.lang.String t1, java.lang.String t2,
java.util.Collection t3, "
+ + "java.lang.String t4");
+ mPartitionList = (List<MPartition>) query.executeWithArray(tblName,
dbName, partNames, catName);
Review comment:
This should help a lot in reducing calls when large number of partitions
are present.
--
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]