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


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/handler/GetPartitionsHandler.java:
##########
@@ -0,0 +1,532 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.handler;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.function.Consumer;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.common.StatsSetupConst;
+import org.apache.hadoop.hive.common.TableName;
+import org.apache.hadoop.hive.metastore.HMSHandler;
+import org.apache.hadoop.hive.metastore.IHMSHandler;
+import org.apache.hadoop.hive.metastore.MetaStoreFilterHook;
+import org.apache.hadoop.hive.metastore.RawStore;
+import org.apache.hadoop.hive.metastore.Warehouse;
+import org.apache.hadoop.hive.metastore.api.ColumnStatistics;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.metastore.api.GetTableRequest;
+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.api.PartitionValuesResponse;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.client.builder.GetPartitionsArgs;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.apache.hadoop.hive.metastore.events.PreReadTableEvent;
+import org.apache.hadoop.hive.metastore.utils.FilterUtils;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static 
org.apache.hadoop.hive.metastore.ExceptionHandler.handleException;
+import static 
org.apache.hadoop.hive.metastore.HMSHandler.PARTITION_NUMBER_EXCEED_LIMIT_MSG;
+import static 
org.apache.hadoop.hive.metastore.utils.StringUtils.normalizeIdentifier;
+
+// Collect get partitions APIs together
+@SuppressWarnings({"unchecked", "rawtypes"})
+@RequestHandler(requestBody = GetPartitionsHandler.GetPartitionsRequest.class)
+public class GetPartitionsHandler<T> extends 
AbstractRequestHandler<GetPartitionsHandler.GetPartitionsRequest,
+    GetPartitionsHandler.GetPartitionsResult<T>> {
+  private static final Logger LOG = 
LoggerFactory.getLogger(GetPartitionsHandler.class);
+  private static final String NO_FILTER_STRING = "";
+  private RawStore rs;
+  private String catName;
+  private String dbName;
+  private String tblName;
+  private GetPartitionsArgs args;
+  private Table table;
+  private Configuration conf;
+  private GetPartitionsMethod getMethod;
+  private MetaStoreFilterHook filterHook;
+  private boolean isServerFilterEnabled;
+
+  enum GetPartitionsMethod {
+    EXPR, NAMES, FILTER, PART_VALS, ALL, VALUES
+  }
+
+  GetPartitionsHandler(IHMSHandler handler, GetPartitionsRequest request) {
+    super(handler, false, request);
+  }
+
+  @Override
+  protected void beforeExecute() throws TException, IOException {
+    this.args = request.getGetPartitionsArgs();
+    if (request.isGetPartitionValues()) {
+      getMethod = GetPartitionsMethod.VALUES;
+    } else if (args.getExpr() != null) {
+      getMethod = GetPartitionsMethod.EXPR;
+    } else if (args.getFilter() != null) {
+      getMethod = GetPartitionsMethod.FILTER;
+    } else if (args.getPartNames() != null) {
+      getMethod = GetPartitionsMethod.NAMES;
+    } else if (args.getPart_vals() != null) {
+      getMethod = GetPartitionsMethod.PART_VALS;
+    } else {
+      getMethod = GetPartitionsMethod.ALL;
+    }
+    
+    this.catName = normalizeIdentifier(request.getTableName().getCat());
+    this.dbName = normalizeIdentifier(request.getTableName().getDb());
+    this.tblName = normalizeIdentifier(request.getTableName().getTable());
+    this.conf = handler.getConf();
+    this.rs = handler.getMS();
+    this.filterHook = handler.getMetaFilterHook();
+    this.isServerFilterEnabled = filterHook != null;
+    GetTableRequest getTableRequest = new GetTableRequest(dbName, tblName);
+    getTableRequest.setCatName(catName);
+    this.table = handler.get_table_core(getTableRequest);
+    ((HMSHandler) handler).firePreEvent(new PreReadTableEvent(table, handler));
+    authorizeTableForPartitionMetadata();

Review Comment:
   The `preListeners` should not be empty, it should have the 
`TransactionalValidationListener` always.
   The old fetching partition names APIs will fire a 
`fireReadTablePreEvent(catName, dbName, tblName);`, which will create this 
Table eventually.
   This check will also ensure the target table is exist before executing the 
request.



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