HIVE-27193: Database names starting with '@' cause error during ALTER…#6371
HIVE-27193: Database names starting with '@' cause error during ALTER…#6371zabetak merged 18 commits intoapache:masterfrom
Conversation
ashniku
left a comment
There was a problem hiding this comment.
can someone please review
|
CI is failing. Can you please fix it first ? |
|
closing the PR, I will re-open again |
|
retest this please |
| @@ -0,0 +1,6 @@ | |||
| CREATE DATABASE `@test`; | |||
There was a problem hiding this comment.
Please use meaningful test file names that can help understand the purpose of the qtest file in future
| @@ -0,0 +1,44 @@ | |||
| PREHOOK: query: CREATE DATABASE `@test` | |||
| CREATE DATABASE `@test`; | ||
| USE `@test`; | ||
| CREATE TABLE testtable (c1 INT); | ||
| ALTER TABLE testtable ADD COLUMNS (c2 INT); |
There was a problem hiding this comment.
Instead of using the database and alter and drop table, can you run the query as mentioned in the JIRA as I see that the issue is seen when hive tries to parse dbName.tableName where the dbName has the special character @ as it looks out for the catalog name.
Change queries to
ALTER TABLE `@test`.testtable ADD COLUMNS (c2 INT);
DROP TABLE `@test`.testtable;
You should also create another table named testtable2 and try the following queries as well
ALTER TABLE `@hive#@test`.testtable ADD COLUMNS (c2 INT);
DROP TABLE `@hive#@test`.testtable;
There was a problem hiding this comment.
@Neer393 The Jira was created
ALTER TABLE @test.testtable ADD COLUMNS (c2 INT);
DROP TABLE @test.testtable;
This above one succeeds.
I just have a doubt on below:
ALTER TABLE @hive#test.testtable ADD COLUMNS (c2 INT);
DROP TABLE @hive#test.testtable;In this case @hive#test the whole word is database or it is deciphered as catalog#database. The purpose is to check with @ as per the kita.
Could you please let me know??
There was a problem hiding this comment.
There was a problem hiding this comment.
In this case @hive#test the whole word is database or it is deciphered as catalog#database. The purpose is to check with @ as per the kita.
It is deciphered as @catalog#database
So as per this JIRA, ALTER TABLE queries are failing because they call the MetastoreUtils.parseDbName() method which is calling the MetastoreUtils.hasCatalogName() method which you have fixed but the purpose of parseDbName is that it should return an array of size 2 where the 1st element is catalog name and the 2nd element is the database name.
So just to make sure both with and without catalog name works, I have asked you to run both queries
There was a problem hiding this comment.
CREATE DATABASE `@test`;
CREATE TABLE `@test`.testtable (c1 INT);
ALTER TABLE `@hive#@test`.testtable ADD COLUMNS (c2 INT);
DROP TABLE `@hive#@test`.testtable;
DROP DATABASE `@test`;
There was a problem hiding this comment.
@Neer393 I have addressed the TestDanglingQOuts failure by promoting the result file to the correct directory: ql/src/test/results/clientpositive/llap/hive_27193.q.out.
Tests: The test case hive_27193 is now correctly integrated into the LLAP test suite.
Could you please trigger the Hive QA (Jenkins) run again when you have a moment? Thank you!"
…e to llap directory.
…n reviewer feedback
…ompilation without JUnit 5
| assertArrayEquals(new String[]{"cat1", null}, 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[]{"cat1!", null}, parseDbName("@cat1!", conf)); | ||
| assertArrayEquals(new String[]{"hive", "#db1"}, parseDbName("#db1", conf)); | ||
| assertArrayEquals(new String[]{"hive", "#!"}, parseDbName("#!", conf)); | ||
| assertArrayEquals(new String[]{"hive", "#"}, parseDbName("#", conf)); |
There was a problem hiding this comment.
All these test cases are duplicated below and some even contradict each other. This test is probably not passing as it is.
As a side note keep in mind that CI resources are limited so be mindful about pushing things in the PR that are guaranteed to fail.
There was a problem hiding this comment.
removed duplicates and only below test are present
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));
Drop duplicated and contradictory parseDbName expectations; keep a single assert per edge-case input aligned with hasCatalogName (@ plus #) behavior. Made-with: Cursor
ashniku
left a comment
There was a problem hiding this comment.
@zabetak The CI has failed for one test:
Error expected:<1> but was:<0> Stacktrace java.lang.AssertionError: expected:<1> but was:<0> at org.junit.Assert.fail(Assert.java:89) at org.junit.Assert.failNotEquals(Assert.java:835) at org.junit.Assert.assertEquals(Assert.java:647) at org.junit.Assert.assertEquals(Assert.java:633) at org.apache.hadoop.hive.ql.parse.repl.metric.TestReplicationMetricCollector.testSuccessOptimizedBootstrapDumpMetrics(TestReplicationMetricCollector.java:286) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.mockito.internal.runners.DefaultInternalRunner$1$1.evaluate(DefaultInternalRunner.java:55) at org.mockito.internal.runners.DefaultInternalRunner$1.run(DefaultInternalRunner.java:100) at org.mockito.internal.runners.DefaultInternalRunner.run(DefaultInternalRunner.java:107) at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:42) at org.mockito.junit.MockitoJUnitRunner.run(MockitoJUnitRunner.java:163) Standard Error 2026-03-31T07:18:52,313 WARN [main] conf.HiveConf: HiveConf of name hive.dummyparam.test.server.specific.config.override does not exist 2026-03-31T07:18:52,314 WARN [main] conf.HiveConf: HiveConf of name hive.dummyparam.test.server.specific.config.hivesite does not exist 2026-03-31T07:18:52,315 WARN [main] conf.HiveConf: HiveConf of name hive.dummyparam.test.server.specific.config.metastoresite does not exist
Is this related to my change or its flaky??
|
@ashniku The test failure in |
zabetak
left a comment
There was a problem hiding this comment.
LGTM pending tests. I will merge this tomorrow. If there are any objections let me know.
Thank you for your help @zabetak . I dont have anything from my end :) |
|



…/DROP table
What changes were proposed in this pull request?
I have mofified "MetaStoreUtils.java", updated "hasCatalogName" to return true only if the database name both starts with the catalog marker (@) and contains the catalog-database separator (#).
-->
Why are the changes needed?
The issue is caused by MetaStoreUtils.hasCatalogName incorrectly identifying database names that start with the '@' character as catalog-prepended names. This leads to a failure in MetaStoreUtils.parseDbName when it tries to split the name using the '#' separator, which is missing in regular database names starting with '@'.
Proposed Changes
[Metastore Common]
[MODIFY] MetaStoreUtils.java
Update hasCatalogName
to return true only if the database name both starts with the catalog marker (@) and contains the catalog-database separator (#).
Does this PR introduce any user-facing change?
NO
-->
How was this patch tested?
CREATE DATABASE @test;
USE @test;
CREATE TABLE testtable (c1 INT);
ALTER TABLE testtable ADD COLUMNS (c2 INT);
DROP TABLE testtable;
DROP DATABASE @test;