You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by "wecharyu (via GitHub)" <gi...@apache.org> on 2024/04/21 12:41:41 UTC

[PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

wecharyu opened a new pull request, #5206:
URL: https://github.com/apache/hive/pull/5206

   ### What changes were proposed in this pull request?
   Implement direct sql for `getNumPartitionsByPs` and `listPartitionsPsWithAuth`.
   
   
   ### Why are the changes needed?
   To improve performance.
   
   
   ### Does this PR introduce _any_ user-facing change?
   No.
   
   ### Is the change a dependency upgrade?
   No.
   
   
   ### How was this patch tested?
   Passing existing tests and add benchmark test `benchmarkGetPartitionsByPs`:
   ```bash
   java -jar hmsbench.jar -H localhost --savedata /tmp/benchdata --sanitize -N 100 -N 1000 -o bench_results.csv -C -d testbench_http --params=100 -M 'getPartitionsByPs.*'
   ```
   
   - Before this patch
   ```bash
   Operation       Mean    Med     Min     Max     Err%
   getPartitionsByPs       14.0807 13.9823 12.8813 19.2509 5.63364
   getPartitionsByPs.100   276.291 275.259 267.642 301.320 2.33622
   getPartitionsByPs.1000  2631.50 2631.01 2551.76 2991.55 1.86420
   ```
   - After this patch
   ```bash
   Operation       Mean    Med     Min     Max     Err%
   getPartitionsByPs       11.6247 11.2780 10.7851 23.8686 12.7184
   getPartitionsByPs.100   18.3550 18.0011 17.1338 36.5164 10.8893
   getPartitionsByPs.1000  61.5760 60.6764 59.3697 78.2133 5.14500
   ```
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
wecharyu commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1600279193


##########
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:
   Although old server supports null part_vals, let's revert to the original client behavior.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1607409991


##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java:
##########
@@ -1201,7 +1201,7 @@ public List<String> listPartitionNames(String catName, String dbName, String tbl
   public List<String> listPartitionNames(String catName, String dbName, String tblName,
       List<String> partVals, int maxParts) throws TException {
     org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName);
-    if (table == null) {
+    if (table == null || partVals == null) {

Review Comment:
   > Because SessionHiveMetaStoreClient extends HiveMetaStoreClient, it should also check null for part_vals like HiveMetaStoreClient
   
   I think you cannot just push the null check of a temporary table in `HiveMetaStoreClient`,  and the `PartitionTree` is for the temporary table to process the partition request, it works at the client side, why not put the check here?
   
   



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
wecharyu commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1610290792


##########
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java:
##########
@@ -460,6 +460,26 @@ public static List<String> getPvals(List<FieldSchema> partCols,
     }
     return pvals;
   }
+
+  /**
+   * If all the values of partVals are empty strings, it means we are returning
+   * all the partitions and hence we can use get_partitions API.
+   * @param partVals The partitions values used to filter out the partitions.
+   * @return true if partVals is empty or if all the values in partVals is empty strings.
+   * other wise false.
+   */
+  public static boolean arePartValsEmpty(List<String> partVals) {
+    if (partVals == null || partVals.isEmpty()) {
+      return true;
+    }
+    for (String val : partVals) {
+      if (val != null && !val.isEmpty()) {

Review Comment:
   It's existing code, the val is determined in client side.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
wecharyu commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1594221045


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java:
##########
@@ -769,6 +769,28 @@ public List<Partition> run(List<Long> input) throws MetaException {
     });
   }
 
+  public List<Partition> getPartitionsViaSqlPs(Table table, GetPartitionsArgs args) throws MetaException {
+    String catName = table.getCatName();
+    String dbName = table.getDbName();
+    String tblName = table.getTableName();
+
+    String sqlFilter = "" + PARTITIONS + ".\"PART_NAME\" like ? ";
+    String partialName = MetaStoreUtils.makePartNameMatcher(table, args.getPart_vals(), "_%");

Review Comment:
   it has been used in: https://github.com/apache/hive/blob/978194b7739e53b4b0e555a8b616a1ccf7d8d437/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java#L825-L828



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
wecharyu commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1594220108


##########
standalone-metastore/metastore-tools/tools-common/src/main/java/org/apache/hadoop/hive/metastore/tools/Util.java:
##########
@@ -584,15 +584,30 @@ static List<Partition> createManyPartitions(@NotNull Table table,
                                               @Nullable Map<String, String> parameters,
                                               @NotNull List<String> arguments,
                                               int npartitions) {
-    return IntStream.range(0, npartitions)

Review Comment:
   Reverted.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #5206:
URL: https://github.com/apache/hive/pull/5206#issuecomment-2112323245

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [14 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5206&resolved=false&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=5206&metric=new_accepted_issues&view=list)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=5206&resolved=false&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Coverage  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Duplication  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206)
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
wecharyu commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1608576789


##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java:
##########
@@ -1201,7 +1201,7 @@ public List<String> listPartitionNames(String catName, String dbName, String tbl
   public List<String> listPartitionNames(String catName, String dbName, String tblName,
       List<String> partVals, int maxParts) throws TException {
     org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName);
-    if (table == null) {
+    if (table == null || partVals == null) {

Review Comment:
   > the PartitionTree is for the temporary table to process the partition request, it works at the client side, why not put the check here?
   
   Because `get_partitions_ps_with_auth` support null and empty part_vals, the null check is added in client side. So in `PartitionTree` we can also follow the server behavior and push null check in `SessionHiveMetaStoreClient`. This change seems to have no side effects, and in turn supports empty part_vals like `HiveMetaStoreClient`.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #5206:
URL: https://github.com/apache/hive/pull/5206#issuecomment-2162087942

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [14 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5206&resolved=false&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5206&resolutions=WONTFIX)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=5206&resolved=false&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Coverage  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Duplication  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206)
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1598476963


##########
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:
   I think the `part_vals` shouldn't be null according to the comment indicates: `Get a list of partitions based on a (possibly partial) list of partition values`.
   Another point is what would happen if the new client connects to the old server which hasn't upgraded?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 merged PR #5206:
URL: https://github.com/apache/hive/pull/5206


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
wecharyu commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1600340159


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetastoreDirectSqlUtils.java:
##########
@@ -609,4 +609,16 @@ public static void throwMetaOrRuntimeException(Exception e) throws MetaException
       throw new RuntimeException(e);
     }
   }
+
+  static int getCountOfQuery(PersistenceManager pm, String queryText, Object[] params) {

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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #5206:
URL: https://github.com/apache/hive/pull/5206#issuecomment-2110776697

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [14 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5206&resolved=false&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=5206&metric=new_accepted_issues&view=list)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=5206&resolved=false&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Coverage  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Duplication  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206)
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #5206:
URL: https://github.com/apache/hive/pull/5206#issuecomment-2076703753

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [13 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5206&resolved=false&inNewCodePeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=5206&metric=new_accepted_issues&view=list)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=5206&resolved=false&inNewCodePeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Coverage  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Duplication  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206)
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
wecharyu commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1606994350


##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java:
##########
@@ -1201,7 +1201,7 @@ public List<String> listPartitionNames(String catName, String dbName, String tbl
   public List<String> listPartitionNames(String catName, String dbName, String tblName,
       List<String> partVals, int maxParts) throws TException {
     org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName);
-    if (table == null) {
+    if (table == null || partVals == null) {

Review Comment:
   Because `SessionHiveMetaStoreClient` extends `HiveMetaStoreClient`, it should also check null for part_vals like `HiveMetaStoreClient`, and `PartitionTree` should support empty or even null part_vals like metastore server in my opinion.
   
   Otherwise it would cause the inconsistent test results in `TestListPartitions` for `HiveMetaStoreClient` and `SessionHiveMetaStoreClient`, for example `testListPartitionsByValuesNoVals()`. The master branch mark this test expect `MetaException`, but actually it should return all partitions for empty part_vals. It could pass the test in master because it throws `MetaException` when making part name for empty partVals in `getNumPartitionsByPs`, which should be a bug in implement this method.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1582004128


##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/PartitionTree.java:
##########
@@ -121,8 +122,8 @@ List<Partition> addPartitions(List<Partition> partitions, boolean ifNotExists)
    * {@link MetaStoreUtils#getPvals(List, Map)}
    */
   List<Partition> getPartitionsByPartitionVals(List<String> partialPartVals) throws MetaException {
-    if (partialPartVals == null || partialPartVals.isEmpty()) {
-      throw new MetaException("Partition partial vals cannot be null or empty");
+    if (MetaStoreUtils.arePartValsEmpty(partialPartVals)) {

Review Comment:
   same as above



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #5206:
URL: https://github.com/apache/hive/pull/5206#issuecomment-2100960807

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [13 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5206&resolved=false&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=5206&metric=new_accepted_issues&view=list)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=5206&resolved=false&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Coverage  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Duplication  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206)
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1598478460


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetastoreDirectSqlUtils.java:
##########
@@ -609,4 +609,16 @@ public static void throwMetaOrRuntimeException(Exception e) throws MetaException
       throw new RuntimeException(e);
     }
   }
+
+  static int getCountOfQuery(PersistenceManager pm, String queryText, Object[] params) {

Review Comment:
   nit: how about declaring this method as `getCountOfQuery(Query query, Object[] params)`



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1601182288


##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/PartitionTree.java:
##########
@@ -22,6 +22,7 @@
 import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
 import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;

Review Comment:
   nit: can we revert the import as well?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1604667856


##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java:
##########
@@ -1201,7 +1201,7 @@ public List<String> listPartitionNames(String catName, String dbName, String tbl
   public List<String> listPartitionNames(String catName, String dbName, String tblName,
       List<String> partVals, int maxParts) throws TException {
     org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName);
-    if (table == null) {
+    if (table == null || partVals == null) {

Review Comment:
   why if the table is a temporary table while the `partVals` is null?



##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java:
##########
@@ -1201,7 +1201,7 @@ public List<String> listPartitionNames(String catName, String dbName, String tbl
   public List<String> listPartitionNames(String catName, String dbName, String tblName,
       List<String> partVals, int maxParts) throws TException {
     org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName);
-    if (table == null) {
+    if (table == null || partVals == null) {

Review Comment:
   what if the table is a temporary table while the `partVals` is null?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1582003402


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java:
##########
@@ -769,6 +769,28 @@ public List<Partition> run(List<Long> input) throws MetaException {
     });
   }
 
+  public List<Partition> getPartitionsViaSqlPs(Table table, GetPartitionsArgs args) throws MetaException {
+    String catName = table.getCatName();
+    String dbName = table.getDbName();
+    String tblName = table.getTableName();
+
+    String sqlFilter = "" + PARTITIONS + ".\"PART_NAME\" like ? ";
+    String partialName = MetaStoreUtils.makePartNameMatcher(table, args.getPart_vals(), "_%");

Review Comment:
   have you tested the matcher against other db? such as Postgres, MySQL, etc.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1582005400


##########
standalone-metastore/metastore-tools/tools-common/src/main/java/org/apache/hadoop/hive/metastore/tools/Util.java:
##########
@@ -584,15 +584,30 @@ static List<Partition> createManyPartitions(@NotNull Table table,
                                               @Nullable Map<String, String> parameters,
                                               @NotNull List<String> arguments,
                                               int npartitions) {
-    return IntStream.range(0, npartitions)

Review Comment:
   why split this method?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #5206:
URL: https://github.com/apache/hive/pull/5206#issuecomment-2075691582

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [11 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5206&resolved=false&inNewCodePeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=5206&metric=new_accepted_issues&view=list)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=5206&resolved=false&inNewCodePeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Coverage  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Duplication  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206)
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
wecharyu commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1600350330


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java:
##########
@@ -3960,9 +3926,57 @@ public List<Partition> listPartitionsPsWithAuth(String catName, String db_name,
     return partitions;
   }
 
+  private Integer getNumPartitionsViaOrmPs(Table table, List<String> partVals) throws MetaException {
+    // size is known since it contains dbName, catName, tblName and partialRegex pattern
+    Map<String, String> params = new HashMap<>(4);

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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
wecharyu commented on PR #5206:
URL: https://github.com/apache/hive/pull/5206#issuecomment-2159624493

   @dengzhhu653 @zhangbutao pls take a look again, I have reverted all client-related changes.


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1609034079


##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java:
##########
@@ -1201,7 +1201,7 @@ public List<String> listPartitionNames(String catName, String dbName, String tbl
   public List<String> listPartitionNames(String catName, String dbName, String tblName,
       List<String> partVals, int maxParts) throws TException {
     org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName);
-    if (table == null) {
+    if (table == null || partVals == null) {

Review Comment:
   I don't like this idea: null check for temporary table in HiveMetaStoreClient, let check others' opinion. cc @deniskuzZ @zhangbutao 



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #5206:
URL: https://github.com/apache/hive/pull/5206#issuecomment-2068051112

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [11 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5206&resolved=false&inNewCodePeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=5206&metric=new_accepted_issues&view=list)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=5206&resolved=false&inNewCodePeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Coverage  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Duplication  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206)
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1582004017


##########
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:
   nit: if the client invokes this method specifically, I would like to add a check `part_vals == null`



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1601191696


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetastoreDirectSqlUtils.java:
##########
@@ -609,4 +609,10 @@ public static void throwMetaOrRuntimeException(Exception e) throws MetaException
       throw new RuntimeException(e);
     }
   }
+
+  static int getCountOfQuery(Query query, Object[] params) {

Review Comment:
   nit: how about move the QueryWrapper here as well, like:
   ```
   long start = doTrace ? System.nanoTime() : 0;
   try (QueryWrapper query = new QueryWrapper(query)) {
        query.setUnique(true);
        int sqlResult = MetastoreDirectSqlUtils.extractSqlInt(query.executeWithArray(params));
        long queryTime = doTrace ? System.nanoTime() : 0;
        MetastoreDirectSqlUtils.timingTrace(doTrace, queryText, start, queryTime);
        return sqlResult;
      }
   ```



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
wecharyu commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1601403285


##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/PartitionTree.java:
##########
@@ -121,8 +122,8 @@ List<Partition> addPartitions(List<Partition> partitions, boolean ifNotExists)
    * {@link MetaStoreUtils#getPvals(List, Map)}
    */
   List<Partition> getPartitionsByPartitionVals(List<String> partialPartVals) throws MetaException {
-    if (partialPartVals == null || partialPartVals.isEmpty()) {
-      throw new MetaException("Partition partial vals cannot be null or empty");
+    if (MetaStoreUtils.arePartValsEmpty(partialPartVals)) {

Review Comment:
   Add null check in `SessionHiveMetaStoreClient`, here we can follow the server side behavior to support empty values.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1606442035


##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java:
##########
@@ -1201,7 +1201,7 @@ public List<String> listPartitionNames(String catName, String dbName, String tbl
   public List<String> listPartitionNames(String catName, String dbName, String tblName,
       List<String> partVals, int maxParts) throws TException {
     org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName);
-    if (table == null) {
+    if (table == null || partVals == null) {

Review Comment:
   Why not revert back the check on [PartitionTree.java](https://github.com/apache/hive/pull/5206/files#diff-f83827d7c6ec0a73bbc558101e64145afb555daff397c999c7491373253168c7), it's a bit confusing a temporary table just performs the null check in `HiveMetaStoreClient`



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
wecharyu commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1610292673


##########
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java:
##########
@@ -460,6 +460,26 @@ public static List<String> getPvals(List<FieldSchema> partCols,
     }
     return pvals;
   }
+
+  /**
+   * If all the values of partVals are empty strings, it means we are returning
+   * all the partitions and hence we can use get_partitions API.
+   * @param partVals The partitions values used to filter out the partitions.
+   * @return true if partVals is empty or if all the values in partVals is empty strings.
+   * other wise false.
+   */
+  public static boolean arePartValsEmpty(List<String> partVals) {
+    if (partVals == null || partVals.isEmpty()) {
+      return true;
+    }
+    for (String val : partVals) {
+      if (val != null && !val.isEmpty()) {
+        return false;
+      }
+    }
+    return true;
+  }

Review Comment:
   Good suggestion, will update together with the final discussion result of part_val null check.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #5206:
URL: https://github.com/apache/hive/pull/5206#issuecomment-2158958472

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [14 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5206&resolved=false&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5206&resolutions=WONTFIX)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=5206&resolved=false&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Coverage  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Duplication  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206)
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #5206:
URL: https://github.com/apache/hive/pull/5206#issuecomment-2159660574

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [14 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5206&resolved=false&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5206&resolutions=WONTFIX)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=5206&resolved=false&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Coverage  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Duplication  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206)
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1606442035


##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java:
##########
@@ -1201,7 +1201,7 @@ public List<String> listPartitionNames(String catName, String dbName, String tbl
   public List<String> listPartitionNames(String catName, String dbName, String tblName,
       List<String> partVals, int maxParts) throws TException {
     org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName);
-    if (table == null) {
+    if (table == null || partVals == null) {

Review Comment:
   Why not revert back the check on [PartitionTree.java](https://github.com/apache/hive/pull/5206/files#diff-f83827d7c6ec0a73bbc558101e64145afb555daff397c999c7491373253168c7), it's a bit confusing a temporary table just for performing a null check in `HiveMetaStoreClient`



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
wecharyu commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1601398528


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetastoreDirectSqlUtils.java:
##########
@@ -609,4 +609,10 @@ public static void throwMetaOrRuntimeException(Exception e) throws MetaException
       throw new RuntimeException(e);
     }
   }
+
+  static int getCountOfQuery(Query query, Object[] params) {

Review Comment:
   Reuse `executeWithArray()` to replace this method.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #5206:
URL: https://github.com/apache/hive/pull/5206#issuecomment-2114036695

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [14 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5206&resolved=false&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=5206&metric=new_accepted_issues&view=list)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=5206&resolved=false&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Coverage  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Duplication  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5206)
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
wecharyu commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1604790500


##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java:
##########
@@ -1201,7 +1201,7 @@ public List<String> listPartitionNames(String catName, String dbName, String tbl
   public List<String> listPartitionNames(String catName, String dbName, String tblName,
       List<String> partVals, int maxParts) throws TException {
     org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName);
-    if (table == null) {
+    if (table == null || partVals == null) {

Review Comment:
   It would throw MetaException like `HiveMetaStoreClient`.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "zhangbutao (via GitHub)" <gi...@apache.org>.
zhangbutao commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1609589477


##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java:
##########
@@ -1201,7 +1201,7 @@ public List<String> listPartitionNames(String catName, String dbName, String tbl
   public List<String> listPartitionNames(String catName, String dbName, String tblName,
       List<String> partVals, int maxParts) throws TException {
     org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName);
-    if (table == null) {
+    if (table == null || partVals == null) {

Review Comment:
   I tried to understand you folk's talk:
   
   @wecharyu thinks that some hms partition api support `null ` & `empty `, such as `get_partitions_ps_with_auth`, but some hms partition api don't support `null ` & `empty`. So, for temp table, check `null `& `empry` and always throw exception in `PartitionTree ` in not inappropriate. 
   I think in this case, @wecharyu you need to make sure all the api's behaviors which invoke the `PartitionTree ::getPartitionsByPartitionVals`  are unaffected. For example, `TempTable::getPartitionsByPartitionVals`  is invoked in four api, but i see that two of them are not changed after you change `PartitionTree ::getPartitionsByPartitionVals`, is that safe?
   
   
   @dengzhhu653 I am not very familair with temp table's ability.  `PartitionTree` is only used for temp table, if temp table has same ability with common table, especially partition ability, and  meanwhile some hms api like `get_partitions_ps_with_auth` can allow `null `& `empty `, i think we can check in `HiveMetaStoreClient` side, and it is good for me to unify the behavior of common table and temp table.



##########
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java:
##########
@@ -460,6 +460,26 @@ public static List<String> getPvals(List<FieldSchema> partCols,
     }
     return pvals;
   }
+
+  /**
+   * If all the values of partVals are empty strings, it means we are returning
+   * all the partitions and hence we can use get_partitions API.
+   * @param partVals The partitions values used to filter out the partitions.
+   * @return true if partVals is empty or if all the values in partVals is empty strings.
+   * other wise false.
+   */
+  public static boolean arePartValsEmpty(List<String> partVals) {
+    if (partVals == null || partVals.isEmpty()) {
+      return true;
+    }
+    for (String val : partVals) {
+      if (val != null && !val.isEmpty()) {

Review Comment:
   Why we did this check?
   
   In which case, the val will be equal the `null `or `empty`?



##########
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java:
##########
@@ -460,6 +460,26 @@ public static List<String> getPvals(List<FieldSchema> partCols,
     }
     return pvals;
   }
+
+  /**
+   * If all the values of partVals are empty strings, it means we are returning
+   * all the partitions and hence we can use get_partitions API.
+   * @param partVals The partitions values used to filter out the partitions.
+   * @return true if partVals is empty or if all the values in partVals is empty strings.
+   * other wise false.
+   */
+  public static boolean arePartValsEmpty(List<String> partVals) {
+    if (partVals == null || partVals.isEmpty()) {
+      return true;
+    }
+    for (String val : partVals) {
+      if (val != null && !val.isEmpty()) {
+        return false;
+      }
+    }
+    return true;
+  }

Review Comment:
   ```suggestion
   public static boolean arePartValsEmpty(List<String> partVals) {
       return partVals == null || partVals.stream().allMatch(val -> val == null || val.isEmpty());
   }
   ```



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
wecharyu commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1610289343


##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java:
##########
@@ -1201,7 +1201,7 @@ public List<String> listPartitionNames(String catName, String dbName, String tbl
   public List<String> listPartitionNames(String catName, String dbName, String tblName,
       List<String> partVals, int maxParts) throws TException {
     org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tblName);
-    if (table == null) {
+    if (table == null || partVals == null) {

Review Comment:
   > but i see that two of them are not changed
   
   One is that `SessionHiveMetaStoreClient#istPartitionNamesRequest` does not check null for part_vals, I think it's acceptable because `HiveMetaStoreClient#listPartitionNamesRequest` also not check it. 
   
   The other is `SessionHiveMetaStoreClient#exchangePartitions` where part_vals can not be null.
   
   I can not find out the side effect on enable null or empty part_vals in these calls if we do regard null or empty part_vals is used to fetch all parts or part names.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "wecharyu (via GitHub)" <gi...@apache.org>.
wecharyu commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1578205825


##########
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java:
##########
@@ -409,10 +409,13 @@ public void testListPartitionsByValues() throws Exception {
     assertEquals(0, partitions.size());
   }
 
-  @Test(expected = MetaException.class)

Review Comment:
   Empty part_vals should not throw `MetaException` because we support it in `ObjectStore` and regard it as fetching all partitions:
   https://github.com/apache/hive/blob/2d855b27d31db6476f18870651db6987816bb5e3/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java#L3890-L3893



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28205: Implement direct sql for get_partitions_ps_with_auth api [hive]

Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5206:
URL: https://github.com/apache/hive/pull/5206#discussion_r1582005228


##########
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:
   why not merge these two methods? `addManyPartitionsNoException` and `addManyPartitions`?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org