Skip to content

Commit 49c343a

Browse files
committed
Fix Copilot comments
1 parent 4991c8d commit 49c343a

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

common/src/java/org/apache/hadoop/hive/conf/HiveConf.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ public static enum ConfVars {
928928

929929
HIVE_METASTORE_CATALOG_WAREHOUSE_EXTERNAL("hive.metastore.warehouse.catalog.external.dir", null,
930930
"Default location for external tables created in the warehouse. " +
931-
"If not set or null, then the normal warehouse location(MetastoreConf.METASTORE_CATALOG_WAREHOUSE)" +
931+
"If not set or null, then the normal warehouse location (MetastoreConf.METASTORE_CATALOG_WAREHOUSE) " +
932932
"will be used as the default location."),
933933

934934
/**

ql/src/java/org/apache/hadoop/hive/ql/parse/EximUtil.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,9 @@ private static void updateIfCustomDbLocations(Database database, Configuration c
393393
String whLocation = MetastoreConf.getVar(conf,
394394
isDefaultCatalog ? MetastoreConf.ConfVars.WAREHOUSE_EXTERNAL : MetastoreConf.ConfVars.WAREHOUSE_CATALOG_EXTERNAL,
395395
MetastoreConf.getVar(conf,
396-
isDefaultCatalog ? MetastoreConf.ConfVars.WAREHOUSE : MetastoreConf.ConfVars.WAREHOUSE_CATALOG
397-
)
398-
);
396+
isDefaultCatalog ? MetastoreConf.ConfVars.WAREHOUSE : MetastoreConf.ConfVars.WAREHOUSE_CATALOG));
399397

398+
whLocation = isDefaultCatalog ? whLocation : whLocation + "/" + database.getCatalogName();
400399
Path dbDerivedLoc = new Path(whLocation, database.getName().toLowerCase() + DATABASE_PATH_SUFFIX);
401400
String defaultDbLoc = Utilities.getQualifiedPath((HiveConf) conf, dbDerivedLoc);
402401
database.putToParameters(ReplConst.REPL_IS_CUSTOM_DB_LOC,

ql/src/java/org/apache/hadoop/hive/ql/queryhistory/repository/AbstractRepository.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.hadoop.hive.ql.QueryState;
2929
import org.apache.hadoop.hive.ql.metadata.Hive;
3030
import org.apache.hadoop.hive.ql.metadata.HiveException;
31+
import org.apache.hadoop.hive.ql.metadata.HiveUtils;
3132
import org.apache.hadoop.hive.ql.metadata.Table;
3233
import org.apache.hadoop.hive.ql.parse.PartitionTransform;
3334
import org.apache.hadoop.hive.ql.parse.TransformSpec;
@@ -40,6 +41,8 @@
4041
import java.util.ArrayList;
4142
import java.util.List;
4243

44+
import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.getDefaultCatalog;
45+
4346
public abstract class AbstractRepository implements QueryHistoryRepository {
4447
protected Logger LOG = LoggerFactory.getLogger(getClass());
4548
@VisibleForTesting
@@ -82,7 +85,11 @@ protected Database initDatabase(Hive hive) {
8285
db = hive.getDatabase(QUERY_HISTORY_DB_NAME);
8386
if (db == null) {
8487
LOG.warn("Database ({}) for query history table hasn't been found, auto-creating one", QUERY_HISTORY_DB_NAME);
85-
String location = getDatabaseLocation(db);
88+
db = new Database();
89+
// TODO catalog. The Hive Query History functionality is currently limited to the default catalog.
90+
db.setCatalogName(getDefaultCatalog(conf));
91+
db.setName(QUERY_HISTORY_DB_NAME);
92+
String location = getDatabaseLocation(new Database());
8693
db = new Database(QUERY_HISTORY_DB_NAME, QUERY_HISTORY_DB_COMMENT,
8794
location, null);
8895
hive.createDatabase(db, false);

standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/CatalogUtil.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ public enum CatalogType {
2929
ICEBERG
3030
}
3131

32-
public static final Set<CatalogType> VALID_CATALOG_TYPES = EnumSet.of(CatalogType.NATIVE, CatalogType.ICEBERG);
33-
3432
public static boolean isValidCatalogType(String name) {
35-
CatalogType type = EnumUtils.getEnumIgnoreCase(CatalogType.class, name);
36-
return type != null && VALID_CATALOG_TYPES.contains(type);
33+
try {
34+
CatalogType.valueOf(name.toUpperCase());
35+
return true;
36+
} catch (IllegalArgumentException e) {
37+
return false;
38+
}
3739
}
3840
}
3941

standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
import org.apache.hadoop.hive.metastore.api.Partition;
5757
import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
5858
import org.apache.hadoop.hive.metastore.api.Table;
59-
import org.stringtemplate.v4.ST;
6059

6160
import static org.apache.hadoop.hive.common.AcidConstants.SOFT_DELETE_TABLE_PATTERN;
6261
import static org.apache.hadoop.hive.common.AcidConstants.SOFT_DELETE_PATH_SUFFIX;
@@ -203,7 +202,7 @@ public Path getWhRootExternal() throws MetaException {
203202
}
204203

205204
public Path getWhRootExternal(String catalogName) throws MetaException {
206-
boolean isDefault = DEFAULT_CATALOG_NAME.equals(catalogName);
205+
boolean isDefault = DEFAULT_CATALOG_NAME.equals(catalogName.trim());
207206

208207
Path rootExDir = isDefault ? whRootExternal : whCatRootExternal;
209208
if (rootExDir != null) {

standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,7 @@ public enum ConfVars {
17901790
WAREHOUSE_CATALOG_EXTERNAL("metastore.warehouse.catalog.external.dir",
17911791
"hive.metastore.warehouse.catalog.external.dir", "",
17921792
"Default location for external tables created in the warehouse. " +
1793-
"If not set or null, then the normal warehouse location(MetastoreConf.WAREHOUSE_CATALOG) " +
1793+
"If not set or null, then the normal warehouse location (MetastoreConf.WAREHOUSE_CATALOG) " +
17941794
"will be used as the default location."),
17951795
WM_DEFAULT_POOL_SIZE("metastore.wm.default.pool.size",
17961796
"hive.metastore.wm.default.pool.size", 4,

0 commit comments

Comments
 (0)