Skip to content

Commit 9125b17

Browse files
authored
[improvement](fe) Add current_database builtin alias (apache#62591)
### What problem does this PR solve? Issue Number: None Related PR: None Problem Summary: Add current_database() as a small compatibility alias for the existing database() builtin so portable SQL can resolve the current database name without rewrites. ### Release note Support current_database() as an alias of database(). ### Check List (For Author) - Test: FE checkstyle and regression test update - Manual test / No need to test (with reason) - Behavior changed: Yes (adds a compatibility alias for current database lookup) - Does this need documentation: No
1 parent 4ed1f21 commit 9125b17

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ public class BuiltinScalarFunctions implements FunctionHelper {
728728
scalar(CurrentUser.class, "current_user"),
729729
scalar(CutIpv6.class, "cut_ipv6"),
730730
scalar(CutToFirstSignificantSubdomain.class, "cut_to_first_significant_subdomain"),
731-
scalar(Database.class, "database", "schema"),
731+
scalar(Database.class, "database", "schema", "current_database"),
732732
scalar(Date.class, "date"),
733733
scalar(DateDiff.class, "datediff"),
734734
scalar(DateFormat.class, "date_format"),

regression-test/suites/query_p0/system/test_query_sys.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ suite("test_query_sys", "query,p0") {
2020

2121
def tableName = "test"
2222
sql "SELECT DATABASE();"
23+
sql "SELECT CURRENT_DATABASE();"
2324
sql "SELECT \"welecome to my blog!\";"
2425
sql "describe ${tableName};"
2526
sql "select version();"

0 commit comments

Comments
 (0)