abstractdog commented on code in PR #5786:
URL: https://github.com/apache/hive/pull/5786#discussion_r2113555223


##########
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/TableFetcher.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.utils;
+
+import com.google.common.annotations.VisibleForTesting;
+import org.apache.hadoop.hive.common.TableName;
+import org.apache.hadoop.hive.metastore.IMetaStoreClient;
+import org.apache.hadoop.hive.metastore.TableType;
+import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+
+public class TableFetcher {
+  private static final Logger LOG = 
LoggerFactory.getLogger(TableFetcher.class);
+
+  // mandatory client passed to this fetcher, has to be closed from caller
+  private final IMetaStoreClient client;
+  // mandatory catalogName
+  private final String catalogName;
+  // mandatory dbPattern: use "*" to fetch all, empty to fetch none
+  private final String dbPattern;
+  // optional tableTypes: comma separated table types to fetch, fetcher result 
is empty list if this is empty
+  // typical value: "MANAGED_TABLE,EXTERNAL_TABLE"
+  @VisibleForTesting
+  final Set<String> tableTypes = new HashSet<>();
+  // tableFilter built from the input tablePattern and custom table conditions
+  @VisibleForTesting
+  String tableFilter;
+
+  private TableFetcher(Builder builder) {
+    this.client = builder.client;
+    if ("*".equalsIgnoreCase(builder.catalogName)) {
+      LOG.warn("Invalid wildcard '*' parameter for catalogName, exact catalog 
name is expected instead of regexp");
+    }
+    this.catalogName = Optional.ofNullable(builder.catalogName).orElse("hive");

Review Comment:
   I like DEFAULT_CATALOG_NAME



-- 
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-unsubscr...@hive.apache.org

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


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

Reply via email to