github-actions[bot] commented on code in PR #62591:
URL: https://github.com/apache/doris/pull/62591#discussion_r3109625122


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java:
##########
@@ -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"),

Review Comment:
   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.



##########
regression-test/suites/query_p0/system/test_query_sys.groovy:
##########
@@ -20,6 +20,7 @@ suite("test_query_sys", "query,p0") {
 
     def tableName = "test"
     sql "SELECT DATABASE();"
+    sql "SELECT CURRENT_DATABASE();"

Review Comment:
   `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()`.
   
   ```suggestion
       assertEquals((sql "SELECT DATABASE();")[0][0], (sql "SELECT 
CURRENT_DATABASE();")[0][0])
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to