Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
Description
A database name that ends with '#' is not properly considered by the parsing logic in method parseDBName:
public static String[] parseDbName(String dbName, Configuration conf) throws MetaException { 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);
The method checks whether the given string in dbName ends with '#', and if it does, it assumes that db name is null. This is inconsistent to how the split is performed. The split operation splits the db name at the first occurrence of a '#'. That means "@foo#bar#" would be considered as having a null db name, but the split operation would split it into "foo", "bar#".
The right solution appears to be that the first occurrence of '#' is searched for. If the first occurrence of '#' is the last character in dbName, then and only then the db name should be considered null.