wecharyu commented on code in PR #5198:
URL: https://github.com/apache/hive/pull/5198#discussion_r1583342090
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java:
##########
@@ -868,19 +895,6 @@ boolean getPartitionsByExpr(String catName, String dbName,
String tblName,
int getNumPartitionsByFilter(String catName, String dbName, String tblName,
String filter)
throws MetaException, NoSuchObjectException;
- /**
- * Get the number of partitions that match an already parsed expression.
- * @param catName catalog name.
- * @param dbName database name.
- * @param tblName table name.
- * @param expr an already parsed Hive expression
- * @return number of matching partitions.
- * @throws MetaException error accessing the RDBMS or working with the
expression.
- * @throws NoSuchObjectException no such table.
- */
- int getNumPartitionsByExpr(String catName, String dbName, String tblName,
byte[] expr)
Review Comment:
Reverted.
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java:
##########
@@ -4154,18 +4209,14 @@ private String getDefaultPartitionName(String
inputDefaultPartName) {
* @param result The resulting names.
* @return Whether the result contains any unknown partitions.
*/
- private boolean getPartitionNamesPrunedByExprNoTxn(String catName, String
dbName, String tblName, List<FieldSchema> partColumns, byte[] expr,
Review Comment:
Reverted.
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java:
##########
@@ -3466,11 +3467,49 @@ protected List<String> getJdoResult(
}.run(true);
}
- private List<String> getPartitionNamesViaOrm(Table table, ExpressionTree
tree, String order,
- Integer maxParts, boolean isValidatedFilter) throws MetaException {
+ @Override
+ public List<String> listPartitionNamesByFilter(String catName, String
dbName, String tblName,
+ GetPartitionsArgs args) throws MetaException, NoSuchObjectException {
+
+ catName = normalizeIdentifier(catName);
+ dbName = normalizeIdentifier(dbName);
+ tblName = normalizeIdentifier(tblName);
+
+ MTable mTable = ensureGetMTable(catName, dbName, tblName);
+ List<FieldSchema> partitionKeys =
convertToFieldSchemas(mTable.getPartitionKeys());
+ String filter = args.getFilter();
+ final ExpressionTree tree = (filter != null && !filter.isEmpty())
+ ? PartFilterExprUtil.parseFilterTree(filter) :
ExpressionTree.EMPTY_TREE;
+ return new GetListHelper<String>(catName, dbName, tblName, true, true) {
+ private final SqlFilterForPushdown filter = new SqlFilterForPushdown();
+
+ @Override
+ protected boolean canUseDirectSql(GetHelper<List<String>> ctx) throws
MetaException {
+ return directSql.generateSqlFilterForPushdown(catName, dbName, tblName,
+ partitionKeys, tree, null, filter);
+ }
+
+ @Override
+ protected List<String> getSqlResult(GetHelper<List<String>> ctx) throws
MetaException {
+ return directSql.getPartitionNamesViaSql(filter, partitionKeys,
+ getDefaultPartitionName(args.getDefaultPartName()), null,
args.getMax());
+ }
+
+ @Override
+ protected List<String> getJdoResult(GetHelper<List<String>> ctx)
+ throws MetaException, NoSuchObjectException, InvalidObjectException {
+ return getPartitionNamesViaOrm(catName, dbName, tblName, tree, null,
Review Comment:
Throw exception in `ObjectStore#getPartitionNamesViaOrm`, because the rest
api `get_partition_names_req` also use this method, we can not return a null
value in the rest response.
https://github.com/apache/hive/blob/b970c980f187124ea850b8233fa4434288319254/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java#L3492-L3499
--
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]