You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "morrySnow (via GitHub)" <gi...@apache.org> on 2026/05/14 10:57:10 UTC
[PR] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
morrySnow opened a new pull request, #63254:
URL: https://github.com/apache/doris/pull/63254
### What problem does this PR solve?
Issue Number: N/A
Related PR: N/A
Problem Summary:
1. When an alias function body has a cast as the outermost expression (e.g., `cast(n as varchar(20))`), AliasUdf.translateToNereidsFunction attempted to cast the parsed expression to UnboundFunction, causing ClassCastException. Fixed by changing the unboundFunction field type from UnboundFunction to Expression so any expression can be stored.
2. Alias functions whose body contains aggregate functions, window expressions, subqueries, or other non-scalar expressions could be created successfully, which is incorrect. Added a containsType check in translateToLegacyExpr that throws AnalysisException("Alias function only supports scalar functions.") before attempting the legacy translation.
### Release note
Fix alias function creation failure when the outermost expression is a cast, and reject alias functions containing aggregate/window/subquery expressions.
### Check List (For Author)
- Test: Unit Test (UdfTest#testAliasFunctionWithCastOutermostExpression, UdfTest#testAliasFunctionWithIllegalExpressionsRejected)
- Behavior changed: Yes — alias functions with aggregate/window/subquery bodies are now rejected at creation time instead of being silently accepted.
- Does this need documentation: No
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg: https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
--
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] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
Posted by "morrySnow (via GitHub)" <gi...@apache.org>.
morrySnow commented on PR #63254:
URL: https://github.com/apache/doris/pull/63254#issuecomment-4456352303
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] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #63254:
URL: https://github.com/apache/doris/pull/63254#issuecomment-4457129124
# FE Regression Coverage Report
Increment line coverage ` 33.33% (1/3)` :tada:
[Increment coverage report](http://coverage.selectdb-in.cc/coverage/63254_d6a35c03b4c9265cfe4d114879d2dc19a28b6493_merge_fe/increment_report/index.html)
[Complete coverage report](http://coverage.selectdb-in.cc/coverage/63254_d6a35c03b4c9265cfe4d114879d2dc19a28b6493_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] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #63254:
URL: https://github.com/apache/doris/pull/63254#issuecomment-4475233866
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] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
Posted by "morrySnow (via GitHub)" <gi...@apache.org>.
morrySnow commented on PR #63254:
URL: https://github.com/apache/doris/pull/63254#issuecomment-4456386984
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] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #63254:
URL: https://github.com/apache/doris/pull/63254#issuecomment-4457755405
# FE UT Coverage Report
Increment line coverage ` 100.00% (3/3)` :tada:
[Increment coverage report](http://coverage.selectdb-in.cc/coverage/63254_d6a35c03b4c9265cfe4d114879d2dc19a28b6493/fe_increment_report/index.html)
[Complete coverage report](http://coverage.selectdb-in.cc/coverage/63254_d6a35c03b4c9265cfe4d114879d2dc19a28b6493/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] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
Posted by "morrySnow (via GitHub)" <gi...@apache.org>.
morrySnow commented on PR #63254:
URL: https://github.com/apache/doris/pull/63254#issuecomment-4450071600
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] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
Posted by "morrySnow (via GitHub)" <gi...@apache.org>.
morrySnow commented on PR #63254:
URL: https://github.com/apache/doris/pull/63254#issuecomment-4450070924
/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] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #63254:
URL: https://github.com/apache/doris/pull/63254#issuecomment-4450070710
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] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on code in PR #63254:
URL: https://github.com/apache/doris/pull/63254#discussion_r3240884342
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/udf/AliasUdf.java:
##########
@@ -44,23 +44,14 @@
* alias function
*/
public class AliasUdf extends ScalarFunction implements ExplicitlyCastableSignature {
- private final UnboundFunction unboundFunction;
+ private final Expression unboundFunction;
Review Comment:
Changing this field from `UnboundFunction` to `Expression` removes the last use of `UnboundFunction` in this file, but the import at line 25 is still present. FE checkstyle enables `UnusedImports`, so this will fail style validation. Please remove `import org.apache.doris.nereids.analyzer.UnboundFunction;`.
--
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] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #63254:
URL: https://github.com/apache/doris/pull/63254#issuecomment-4456490827
<details>
<summary>TPC-H: <b>Total hot run time: 29375 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit d6a35c03b4c9265cfe4d114879d2dc19a28b6493, data reload: false
------ Round 1 ----------------------------------
orders Doris NULL NULL 0 0 0 NULL 0 NULL NULL 2023-12-26 18:27:23 2023-12-26 18:42:55 NULL utf-8 NULL NULL
============================================
q1 17729 3919 3787 3787
q2 q3 10730 866 595 595
q4 4663 459 336 336
q5 7436 1326 1120 1120
q6 180 166 136 136
q7 909 934 756 756
q8 9326 1375 1251 1251
q9 6001 5354 5277 5277
q10 6292 2073 1819 1819
q11 502 261 254 254
q12 698 435 296 296
q13 18166 3286 2722 2722
q14 298 286 256 256
q15 q16 902 866 783 783
q17 1130 1000 743 743
q18 6455 5735 5582 5582
q19 1737 1252 1092 1092
q20 505 409 271 271
q21 4982 2316 1966 1966
q22 474 385 333 333
Total cold run time: 99115 ms
Total hot run time: 29375 ms
----- Round 2, with runtime_filter_mode=off -----
orders Doris NULL NULL 150000000 42 6422171781 NULL 22778155 NULL NULL 2023-12-26 18:27:23 2023-12-26 18:42:55 NULL utf-8 NULL NULL
============================================
q1 4691 4529 4482 4482
q2 q3 4661 4740 4154 4154
q4 2086 2139 1407 1407
q5 4939 4950 5208 4950
q6 201 171 132 132
q7 2040 1844 1630 1630
q8 3347 3060 3119 3060
q9 8310 8545 8493 8493
q10 4494 4537 4257 4257
q11 598 418 388 388
q12 701 751 510 510
q13 3181 3530 2935 2935
q14 298 303 269 269
q15 q16 783 824 693 693
q17 1314 1279 1256 1256
q18 7886 7014 7142 7014
q19 1150 1180 1156 1156
q20 2215 2227 1915 1915
q21 6041 5222 4710 4710
q22 510 466 394 394
Total cold run time: 59446 ms
Total hot run time: 53805 ms
```
</details>
--
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] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
Posted by "morrySnow (via GitHub)" <gi...@apache.org>.
morrySnow commented on PR #63254:
URL: https://github.com/apache/doris/pull/63254#issuecomment-4459188306
/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] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #63254:
URL: https://github.com/apache/doris/pull/63254#issuecomment-4457067820
# FE Regression Coverage Report
Increment line coverage ` 33.33% (1/3)` :tada:
[Increment coverage report](http://coverage.selectdb-in.cc/coverage/63254_d6a35c03b4c9265cfe4d114879d2dc19a28b6493_merge_fe/increment_report/index.html)
[Complete coverage report](http://coverage.selectdb-in.cc/coverage/63254_d6a35c03b4c9265cfe4d114879d2dc19a28b6493_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] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #63254:
URL: https://github.com/apache/doris/pull/63254#issuecomment-4456534260
<details>
<summary>TPC-DS: <b>Total hot run time: 169676 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit d6a35c03b4c9265cfe4d114879d2dc19a28b6493, data reload: false
query5 4325 647 502 502
query6 339 211 201 201
query7 4235 568 302 302
query8 324 231 222 222
query9 8857 4045 3994 3994
query10 452 338 289 289
query11 5758 2424 2239 2239
query12 180 130 132 130
query13 1275 600 432 432
query14 6625 5300 4994 4994
query14_1 4343 4375 4311 4311
query15 210 202 183 183
query16 1014 439 412 412
query17 1111 735 634 634
query18 2799 479 343 343
query19 216 230 154 154
query20 134 128 128 128
query21 210 134 117 117
query22 13497 13540 13337 13337
query23 17065 16292 15982 15982
query23_1 16107 16163 16186 16163
query24 7376 1769 1336 1336
query24_1 1348 1335 1370 1335
query25 609 512 528 512
query26 1312 314 177 177
query27 2668 609 345 345
query28 4430 1976 1957 1957
query29 1007 654 543 543
query30 312 244 202 202
query31 1155 1056 953 953
query32 90 76 76 76
query33 580 375 315 315
query34 1164 1175 645 645
query35 767 793 678 678
query36 1337 1360 1149 1149
query37 156 108 92 92
query38 3224 3122 3040 3040
query39 920 923 919 919
query39_1 865 891 870 870
query40 238 161 138 138
query41 74 66 68 66
query42 110 112 112 112
query43 326 328 282 282
query44
query45 217 209 204 204
query46 1071 1186 727 727
query47 2298 2346 2276 2276
query48 411 427 301 301
query49 659 549 463 463
query50 750 308 230 230
query51 4384 4339 4321 4321
query52 107 110 96 96
query53 260 294 210 210
query54 325 283 266 266
query55 97 94 89 89
query56 320 310 311 310
query57 1403 1409 1301 1301
query58 306 278 298 278
query59 1536 1633 1392 1392
query60 361 349 320 320
query61 179 224 154 154
query62 679 612 561 561
query63 248 202 210 202
query64 2322 822 639 639
query65
query66 1682 501 409 409
query67 29965 29850 29792 29792
query68
query69 455 340 307 307
query70 989 996 952 952
query71 316 271 268 268
query72 2982 2670 2016 2016
query73 827 775 407 407
query74 5068 4873 4703 4703
query75 2794 2639 2333 2333
query76 2310 1120 770 770
query77 427 422 359 359
query78 12972 12934 12315 12315
query79 1519 1036 762 762
query80 1387 579 498 498
query81 504 279 239 239
query82 1340 158 121 121
query83 350 288 255 255
query84 270 149 115 115
query85 919 520 458 458
query86 434 328 334 328
query87 3457 3349 3167 3167
query88 3587 2689 2656 2656
query89 447 378 341 341
query90 1914 177 184 177
query91 178 168 138 138
query92 74 77 76 76
query93 954 971 575 575
query94 691 348 315 315
query95 678 477 352 352
query96 996 796 324 324
query97 2681 2674 2551 2551
query98 235 231 229 229
query99 1099 1122 1007 1007
Total cold run time: 255027 ms
Total hot run time: 169676 ms
```
</details>
--
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] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
Posted by "morrySnow (via GitHub)" <gi...@apache.org>.
morrySnow merged PR #63254:
URL: https://github.com/apache/doris/pull/63254
--
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] [fix](fe) Fix alias function with cast outermost expr and reject illegal expressions [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #63254:
URL: https://github.com/apache/doris/pull/63254#issuecomment-4475234139
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