Skip to content

Commit

Permalink
HIVE-28307: Fast return when database exists and IF NOT EXISTS clause…
Browse files Browse the repository at this point in the history
… is enabled (apache#5292)(Wechar Yu, reviewed by Butao Zhang)
  • Loading branch information
wecharyu committed Jun 20, 2024
1 parent 5114a8e commit 1c9969a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public void analyzeInternal(ASTNode root) throws SemanticException {
}
}

if (ifNotExists && getDatabase(databaseName, false) != null) {
return;
}

CreateDatabaseDesc desc = null;
Database database = new Database(databaseName, comment, locationUri, props);
if (type.equalsIgnoreCase(DatabaseType.NATIVE.name())) {
Expand Down
2 changes: 0 additions & 2 deletions ql/src/test/results/clientpositive/llap/database.q.out
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ default
test_db
PREHOOK: query: CREATE DATABASE IF NOT EXISTS test_db
PREHOOK: type: CREATEDATABASE
PREHOOK: Output: database:test_db
POSTHOOK: query: CREATE DATABASE IF NOT EXISTS test_db
POSTHOOK: type: CREATEDATABASE
POSTHOOK: Output: database:test_db
PREHOOK: query: SHOW DATABASES
PREHOOK: type: SHOWDATABASES
POSTHOOK: query: SHOW DATABASES
Expand Down

0 comments on commit 1c9969a

Please sign in to comment.