You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "tonywasson (via GitHub)" <gi...@apache.org> on 2026/04/17 09:33:48 UTC
[PR] [improvement](fe) Add current_database builtin alias [doris]
tonywasson opened a new pull request, #62591:
URL: https://github.com/apache/doris/pull/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
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [improvement](fe) Add current_database builtin alias [doris]
Posted by "morrySnow (via GitHub)" <gi...@apache.org>.
morrySnow commented on PR #62591:
URL: https://github.com/apache/doris/pull/62591#issuecomment-4279087380
/review
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [improvement](fe) Add current_database builtin alias [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #62591:
URL: https://github.com/apache/doris/pull/62591#issuecomment-4277936746
PR approved by anyone and no changes requested.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [improvement](fe) Add current_database builtin alias [doris]
Posted by "yiguolei (via GitHub)" <gi...@apache.org>.
yiguolei merged PR #62591:
URL: https://github.com/apache/doris/pull/62591
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [improvement](fe) Add current_database builtin alias [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #62591:
URL: https://github.com/apache/doris/pull/62591#issuecomment-4266873152
Thank you for your contribution to Apache Doris.
Don't know what should be done next? See [How to process your PR](https://cwiki.apache.org/confluence/display/DORIS/How+to+process+your+PR).
Please clearly describe your PR:
1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
3. What features were added. Why was this function added?
4. Which code was refactored and why was this part of the code refactored?
5. Which functions were optimized and what is the difference before and after the optimization?
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [improvement](fe) Add current_database builtin alias [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #62591:
URL: https://github.com/apache/doris/pull/62591#issuecomment-4277936569
PR approved by at least one committer and no changes requested.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [improvement](fe) Add current_database builtin alias [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #62591:
URL: https://github.com/apache/doris/pull/62591#issuecomment-4278514588
# FE Regression Coverage Report
Increment line coverage ` 100.00% (1/1)` :tada:
[Increment coverage report](http://coverage.selectdb-in.cc/coverage/62591_f56978f24b5a2f4ec5772d9518ec910350460035_merge_fe/increment_report/index.html)
[Complete coverage report](http://coverage.selectdb-in.cc/coverage/62591_f56978f24b5a2f4ec5772d9518ec910350460035_merge_fe/report/index.html)
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [improvement](fe) Add current_database builtin alias [doris]
Posted by "yiguolei (via GitHub)" <gi...@apache.org>.
yiguolei commented on PR #62591:
URL: https://github.com/apache/doris/pull/62591#issuecomment-4277849383
run buildall
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [improvement](fe) Add current_database builtin alias [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org