dengzhhu653 commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1582003556


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java:
##########
@@ -1270,6 +1291,31 @@ public int 
getNumPartitionsViaSqlFilter(SqlFilterForPushdown filter) throws Meta
       params[i + 3] = filter.params.get(i);
     }
 
+    return getNumPartitionsViaSql(queryText, params);
+  }
+
+  public int getNumPartitionsViaSqlPs(Table table, List<String> partVals) 
throws MetaException {
+    String partialName = MetaStoreUtils.makePartNameMatcher(table, partVals, 
"_%");
+
+    // Get number of partitions by doing count on PART_ID.
+    String queryText = "select count(" + PARTITIONS + ".\"PART_ID\") from " + 
PARTITIONS + ""
+      + "  inner join " + TBLS + " on " + PARTITIONS + ".\"TBL_ID\" = " + TBLS 
+ ".\"TBL_ID\" "
+      + "    and " + TBLS + ".\"TBL_NAME\" = ? "
+      + "  inner join " + DBS + " on " + TBLS + ".\"DB_ID\" = " + DBS + 
".\"DB_ID\" "
+      + "     and " + DBS + ".\"NAME\" = ? "
+      + " where " + DBS + ".\"CTLG_NAME\" = ? and " + PARTITIONS + 
".\"PART_NAME\" like ? ";
+
+    Object[] params = new Object[4];
+    params[0] = table.getTableName();
+    params[1] = table.getDbName();
+    params[2] = table.getCatName();
+    params[3] = partialName;
+
+    return getNumPartitionsViaSql(queryText, params);
+  }
+
+  private int getNumPartitionsViaSql(String queryText, Object[] params) {

Review Comment:
   can we rename this method to `getCountOfQuery` and move it to 
`MetastoreDirectSqlUtils`?



-- 
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