Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions ql/src/test/queries/clientpositive/hive_27193.q
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE DATABASE `@test`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use meaningful test file names that can help understand the purpose of the qtest file in future

USE `@test`;
CREATE TABLE testtable (c1 INT);
ALTER TABLE testtable ADD COLUMNS (c2 INT);
Copy link
Contributor

@Neer393 Neer393 Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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??

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please confirm if below needs to be executed:

create database@hive#test; create table @hive#test.testtable (c1 INT); ALTER TABLE @hive#test.testtable ADD COLUMNS (c2 INT); DROP TABLE @hive#test.testtable;

In that case this works? Can you please confirm, so that I can put in qtest

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`;

DROP TABLE testtable;
DROP DATABASE `@test`;
44 changes: 44 additions & 0 deletions ql/src/test/results/clientpositive/hive_27193.q.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
PREHOOK: query: CREATE DATABASE `@test`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this

PREHOOK: type: CREATEDATABASE
PREHOOK: Output: database:@test
POSTHOOK: query: CREATE DATABASE `@test`
POSTHOOK: type: CREATEDATABASE
POSTHOOK: Output: database:@test
PREHOOK: query: USE `@test`
PREHOOK: type: SWITCHDATABASE
PREHOOK: Input: database:@test
POSTHOOK: query: USE `@test`
POSTHOOK: type: SWITCHDATABASE
POSTHOOK: Input: database:@test
PREHOOK: query: CREATE TABLE testtable (c1 INT)
PREHOOK: type: CREATETABLE
PREHOOK: Output: @test@testtable
PREHOOK: Output: database:@test
POSTHOOK: query: CREATE TABLE testtable (c1 INT)
POSTHOOK: type: CREATETABLE
POSTHOOK: Output: @test@testtable
POSTHOOK: Output: database:@test
PREHOOK: query: ALTER TABLE testtable ADD COLUMNS (c2 INT)
PREHOOK: type: ALTERTABLE_ADDCOLS
PREHOOK: Input: @test@testtable
PREHOOK: Output: @test@testtable
POSTHOOK: query: ALTER TABLE testtable ADD COLUMNS (c2 INT)
POSTHOOK: type: ALTERTABLE_ADDCOLS
POSTHOOK: Input: @test@testtable
POSTHOOK: Output: @test@testtable
PREHOOK: query: DROP TABLE testtable
PREHOOK: type: DROPTABLE
PREHOOK: Input: @test@testtable
PREHOOK: Output: @test@testtable
POSTHOOK: query: DROP TABLE testtable
POSTHOOK: type: DROPTABLE
POSTHOOK: Input: @test@testtable
POSTHOOK: Output: @test@testtable
PREHOOK: query: DROP DATABASE `@test`
PREHOOK: type: DROPDATABASE
PREHOOK: Input: database:@test
PREHOOK: Output: database:@test
POSTHOOK: query: DROP DATABASE `@test`
POSTHOOK: type: DROPDATABASE
POSTHOOK: Input: database:@test
POSTHOOK: Output: database:@test
Original file line number Diff line number Diff line change
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
Loading