Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ public class BuiltinScalarFunctions implements FunctionHelper {
scalar(CurrentUser.class, "current_user"),
scalar(CutIpv6.class, "cut_ipv6"),
scalar(CutToFirstSignificantSubdomain.class, "cut_to_first_significant_subdomain"),
scalar(Database.class, "database", "schema"),
scalar(Database.class, "database", "schema", "current_database"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adding the alias here only covers FE binding. When debug_skip_fold_constant=true, FoldConstantRule.evaluate() returns Database unchanged (fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRule.java:66-77), then ExpressionTranslator.visitScalarFunction() lowers it to a generic FunctionCallExpr("database") (fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java:697-717). That is serialized as FUNCTION_CALL, and BE resolves it through SimpleFunctionFactory in be/src/exprs/vectorized_fn_call.cpp:162-170. I could not find any BE database function registration under be/src, so SELECT CURRENT_DATABASE() still looks broken as soon as constant folding is disabled. This needs either a dedicated lowering to the legacy InformationFunction/INFO_FUNC path or a real BE scalar implementation, plus regression coverage for that mode.

scalar(Date.class, "date"),
scalar(DateDiff.class, "datediff"),
scalar(DateFormat.class, "date_format"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ suite("test_query_sys", "query,p0") {

def tableName = "test"
sql "SELECT DATABASE();"
sql "SELECT CURRENT_DATABASE();"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sql here only smoke-tests that the statement does not throw. Suite.sql() just executes the query and returns rows (regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy:593-599), so this will not catch a wrong result or the non-folded runtime failure above. Since this is the only coverage for a new user-visible alias, please assert that it matches database().

Suggested change
sql "SELECT CURRENT_DATABASE();"
assertEquals((sql "SELECT DATABASE();")[0][0], (sql "SELECT CURRENT_DATABASE();")[0][0])

sql "SELECT \"welecome to my blog!\";"
sql "describe ${tableName};"
sql "select version();"
Expand Down
Loading