ngsg commented on code in PR #5771: URL: https://github.com/apache/hive/pull/5771#discussion_r2184037817
########## standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/client/BaseMetaStoreClient.java: ########## @@ -0,0 +1,751 @@ +/* + * 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.client; + +import org.apache.commons.lang3.tuple.Pair; +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.common.ValidTxnList; +import org.apache.hadoop.hive.metastore.IMetaStoreClient; +import org.apache.hadoop.hive.metastore.PartitionDropOptions; +import org.apache.hadoop.hive.metastore.TableType; +import org.apache.hadoop.hive.metastore.api.*; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy; +import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils; +import org.apache.thrift.TException; + +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.convertToGetPartitionsByNamesRequest; +import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.getDefaultCatalog; + +public abstract class BaseMetaStoreClient implements IMetaStoreClient { + + // Keep a copy of HiveConf so if Session conf changes, we may need to get a new HMS client. + protected final Configuration conf; + + public BaseMetaStoreClient(Configuration conf) { + if (conf == null) { + conf = MetastoreConf.newMetastoreConf(); + this.conf = conf; + } else { + this.conf = new Configuration(conf); + } + } + + @Override + public final void dropCatalog(String catName) + throws NoSuchObjectException, InvalidOperationException, MetaException, TException { + dropCatalog(catName, true); + } + + @Override + public final List<String> getDatabases(String databasePattern) throws MetaException, TException { + return getDatabases(getDefaultCatalog(conf), databasePattern); + } + + @Override + public final List<String> getAllDatabases() throws MetaException, TException { + return getAllDatabases(getDefaultCatalog(conf)); + } + + @Override + public final List<String> getTables(String dbName, String tablePattern) + throws MetaException, TException, UnknownDBException { + try { + return getTables(getDefaultCatalog(conf), dbName, tablePattern); + } catch (Exception e) { + MetaStoreUtils.throwMetaException(e); + return null; + } + } + + @Override + public final List<String> getTables(String dbName, String tablePattern, TableType tableType) + throws MetaException, TException, UnknownDBException { + try { + return getTables(getDefaultCatalog(conf), dbName, tablePattern, tableType); + } catch (Exception e) { + MetaStoreUtils.throwMetaException(e); + return null; + } + } + + @Override + public final List<String> getMaterializedViewsForRewriting(String dbName) + throws MetaException, TException, UnknownDBException { + return getMaterializedViewsForRewriting(getDefaultCatalog(conf), dbName); Review Comment: The original `HiveMetaStoreClient` uses `MetaStoreUtils.throwMetaException` only in some methods, and I tried to preserve this logic in the new design as well. However, as you pointed it out, it seems that this logic may not need to be maintained in the base classes. Let me remove them and check whether CI tests still pass. cf. FYI, this is a list of the methods that wraps their exceptions by `MetaStoreUtils.throwMetaException`. ``` getAllMaterializedViewObjectsForRewriting getMaterializedViewsForRewriting getAllTables getTableMeta getTables ``` -- 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