zabetak commented on code in PR #5928: URL: https://github.com/apache/hive/pull/5928#discussion_r2218465720
########## standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/dbinstall/rules/MetastoreRuleFactory.java: ########## @@ -0,0 +1,48 @@ +/* + * 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.dbinstall.rules; + +/** + * A factory for creating a Metastore database rule for use in tests. + */ +public final class MetastoreRuleFactory { + private MetastoreRuleFactory() { + throw new IllegalStateException("Factory class should not be instantiated"); + } + + /** + * Creates a new Metastore rule based on the provided database type. + * + * @param dbType the type of database (e.g., "mysql", "postgres", etc.) + * @return a DatabaseRule instance for the specified database type + * @throws IllegalArgumentException if the database type is unsupported + */ + public static DatabaseRule create(String dbType) { + return switch (dbType.toLowerCase()) { + case "mysql" -> new Mysql(); + case "postgres" -> new Postgres(); + case "postgres.tpcds" -> new PostgresTPCDS(); + case "mariadb" -> new Mariadb(); + case "derby" -> new Derby(); + case "derby.clean" -> new Derby(true); Review Comment: In some places (e.g., in [QTestMetaStoreHandler](https://github.com/apache/hive/blob/93c765df0272523d5d70614b8ff422f1f2f2168a/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestMetaStoreHandler.java#L100)) there are some Derby specific optimizations to only truncate some tables instead of deleting the entire database for performance reasons. Implementing similar functionality for other DBMS may be useful but out-of-scope of the current PR. -- 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