wecharyu commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1594219760
##########
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:
Addressed.
##########
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java:
##########
@@ -2245,8 +2245,8 @@ public List<Partition> listPartitions(String db_name,
String tbl_name,
public List<Partition> listPartitions(String catName, String db_name, String
tbl_name,
List<String> part_vals, int max_parts)
throws TException {
// TODO should we add capabilities here as well as it returns Partition
objects
- if (db_name == null || tbl_name == null || part_vals == null) {
- throw new MetaException("Database name/Table name/partition values
should not be null");
+ if (db_name == null || tbl_name == null) {
Review Comment:
Since metastore server supports null and empty partial values, I think
client can also support it.
##########
standalone-metastore/metastore-tools/tools-common/src/main/java/org/apache/hadoop/hive/metastore/tools/Util.java:
##########
@@ -648,6 +682,15 @@ static void addManyPartitionsNoException(@NotNull
HMSClient client,
addManyPartitions(client, dbName, tableName, parameters,
arguments, npartitions));
}
+ static void addManyPartitionsNoException(@NotNull HMSClient client,
+ @NotNull String dbName,
+ @NotNull String tableName,
+ @Nullable Map<String, String>
parameters,
+ List<List<String>> values) {
+ throwingSupplierWrapper(() ->
+ addManyPartitions(client, dbName, tableName, parameters, values));
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]