Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
cf34861
HIVE-27193: Database names starting with '@' cause error during ALTER…
ashniku Mar 15, 2026
adf24e5
Update hive_27193.q and its results for LLAP. Use @firstdb and promot…
ashniku Mar 19, 2026
fc177d9
Rename test file hive_27193.q to database_special_character.q
ashniku Mar 20, 2026
de09fab
Triggering Jenkins retest
ashniku Mar 20, 2026
d9471a7
Triggering Jenkins CI re-run
ashniku Mar 20, 2026
9605213
Triggering Jenkins CI re-run
ashniku Mar 20, 2026
a38a36f
HIVE-27193: Fix parseDbName for edge cases and add unit tests
ashniku Mar 23, 2026
d51538d
HIVE-27193: Refine parseDbName logic and modernize unit tests based o…
ashniku Mar 24, 2026
d71ed19
HIVE-27193: Re-add junit-jupiter-api for classpath alignment in metas…
ashniku Mar 24, 2026
66f647b
Triggering Jenkins CI re-run
ashniku Mar 24, 2026
d7706d0
HIVE-27193: Fix dangling qout by removing leftover database_special_c…
ashniku Mar 25, 2026
0e30e7f
HIVE-27193: Fix Sonar and reviewer comments for parseDbName
ashniku Mar 25, 2026
2a86770
HIVE-27193: Fix catalog parsing bug and expand parseDbName test cases
ashniku Mar 27, 2026
50beb17
HIVE-27193: Fix catalog parsing bug and verify all provided edge case…
ashniku Mar 27, 2026
c267df6
HIVE-27193: Restore system-stubs-core (v1.2.0) to fix HTTP JWT test c…
ashniku Mar 27, 2026
e70c820
HIVE-27193: Remove duplicate assertions in TestMetastoreUtilsParseDbName
ashniku Mar 27, 2026
168ae42
Remove system-stubs-core from metastore-server pom
ashniku Mar 30, 2026
066a151
Revert all changes in pom.xml
zabetak Mar 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
*
* 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.
Expand Down Expand Up @@ -1027,7 +1027,8 @@ public static WMPoolSchedulingPolicy parseSchedulingPolicy(String schedulingPoli

private static boolean hasCatalogName(String dbName) {
return dbName != null && dbName.length() > 0 &&
dbName.charAt(0) == CATALOG_DB_THRIFT_NAME_MARKER;
dbName.charAt(0) == CATALOG_DB_THRIFT_NAME_MARKER &&
dbName.contains(CATALOG_DB_SEPARATOR);
}

/**
Expand Down Expand Up @@ -1092,25 +1093,20 @@ public static String prependCatalogToDbName(String dbName, Configuration conf) {
* in the database name.
* @return an array of two elements, the first being the catalog name, the second the database
* name.
* @throws MetaException if the name is not either just a database name or a catalog plus
* database name with the proper delimiters.
*/
public static String[] parseDbName(String dbName, Configuration conf) throws MetaException {
public static String[] parseDbName(String dbName, Configuration conf) {
if (dbName == null) {
return Arrays.copyOf(nullCatalogAndDatabase, nullCatalogAndDatabase.length);
}
if (hasCatalogName(dbName)) {
if (dbName.endsWith(CATALOG_DB_SEPARATOR)) {
// This means the DB name is null
return new String[] {dbName.substring(1, dbName.length() - 1), null};
} else if (dbName.endsWith(DB_EMPTY_MARKER)) {
// This means the DB name is empty
return new String[] {dbName.substring(1, dbName.length() - DB_EMPTY_MARKER.length() - 1), ""};
}
String[] names = dbName.substring(1).split(CATALOG_DB_SEPARATOR, 2);
if (names.length != 2) {
throw new MetaException(dbName + " is prepended with the catalog marker but does not " +
"appear to have a catalog name in it");
Comment thread
zabetak marked this conversation as resolved.
if (names.length == 1) {
return new String[] {names[0], null};
}
if (names[1].isEmpty()) {
names[1] = null;
} else if (names[1].equals(DB_EMPTY_MARKER)) {
names[1] = "";
}
return names;
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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 org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest;
import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.parseDbName;
import static org.junit.Assert.assertArrayEquals;

@Category(MetastoreUnitTest.class)
public class TestMetastoreUtilsParseDbName {

@Test
public void testParseDbNameEdgeCases() {
Configuration conf = MetastoreConf.newMetastoreConf();
MetastoreConf.setVar(conf, MetastoreConf.ConfVars.CATALOG_DEFAULT, "hive");

assertArrayEquals(new String[]{"hive", "@"}, parseDbName("@", conf));
assertArrayEquals(new String[]{"hive", "@!"}, parseDbName("@!", conf));
assertArrayEquals(new String[]{"", null}, parseDbName("@#", conf));
assertArrayEquals(new String[]{"", "db1"}, parseDbName("@#db1", conf));
assertArrayEquals(new String[]{"hive", "@cat1"}, parseDbName("@cat1", conf));
assertArrayEquals(new String[]{"cat1", null}, parseDbName("@cat1#", conf));
assertArrayEquals(new String[]{"cat1", ""}, parseDbName("@cat1#!", conf));
assertArrayEquals(new String[]{"cat1", "@db1"}, parseDbName("@cat1#@db1", conf));
assertArrayEquals(new String[]{"cat1", "#db1"}, parseDbName("@cat1##db1", conf));
assertArrayEquals(new String[]{"cat1", "db1"}, parseDbName("@cat1#db1", conf));
assertArrayEquals(new String[]{"cat1", "db1!"}, parseDbName("@cat1#db1!", conf));
assertArrayEquals(new String[]{"hive", "@cat1!"}, parseDbName("@cat1!", conf));
assertArrayEquals(new String[]{"hive", "#db1"}, parseDbName("#db1", conf));
assertArrayEquals(new String[]{"hive", "#!"}, parseDbName("#!", conf));
assertArrayEquals(new String[]{"hive", "#"}, parseDbName("#", conf));
}
}
Loading