starrocks icon indicating copy to clipboard operation
starrocks copied to clipboard

[BugFix] Fix array_map expr get wrong result from constant unary expr (backport #66514)

Open mergify[bot] opened this issue 2 weeks ago โ€ข 2 comments

Why I'm doing:

see reproduce case

What I'm doing:

Fixes #issue

What type of PR is this:

  • [x] BugFix
  • [ ] Feature
  • [ ] Enhancement
  • [ ] Refactor
  • [ ] UT
  • [ ] Doc
  • [ ] Tool

Does this PR entail a change in behavior?

  • [ ] Yes, this PR will result in a change in behavior.
  • [x] No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • [ ] Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • [ ] Parameter changes: default values, similar parameters but with different default values
  • [ ] Policy changes: use new policy to replace old one, functionality automatically enabled
  • [ ] Feature removed
  • [ ] Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • [x] I have added test cases for my bug fix or my new feature
  • [ ] This pr needs user documentation (for new or modified features or behaviors)
    • [ ] I have added documentation for my new feature or new function
  • [x] This is a backport pr

Bugfix cherry-pick branch check:

  • [x] I have checked the version labels which the pr will be auto-backported to the target branch
    • [x] 4.0
    • [x] 3.5
    • [x] 3.4
    • [x] 3.3

[!NOTE] Fix array_map evaluation for independent lambdas with constant input, initialize Java UDF random-value flag, and add SQL tests validating UDF usage with any_match.

  • Exprs:
    • array_map: When evaluating independent lambdas without input columns, ensure the lambda result is treated as a single-row const (or const-null) column before replication; aligns return types and prevents incorrect results from constant unary expressions (be/src/exprs/array_map_expr.cpp).
    • Java UDF: Initialize _is_returning_random_value to false to avoid uninitialized state (be/src/exprs/java_function_call_expr.h).
  • Tests:
    • Add UDF echoint, table t1, data load via generate_series, and query using any_match((x)->cast(echoint(1) as boolean), c2) with expected count 40960 (test/sql/test_udf/T|R/test_jvm_udf).

Written by Cursor Bugbot for commit 0a51ce5fb594e1d64350baf23396d24ec81df8be. This will update automatically on new commits. Configure here.


This is an automatic backport of pull request #66514 done by [Mergify](https://mergify.com).

[!NOTE] Fix array_map for independent lambdas with constant input by forcing a single-row const result before replication; initialize Java UDF random-value flag; add SQL tests using echoint with any_match.

  • Exprs:
    • array_map (be/src/exprs/array_map_expr.cpp): For independent lambdas with no input columns, treat evaluated result as a 1-row const (or const-null) column before replication; enforce size check and align return type.
    • Java UDF (be/src/exprs/java_function_call_expr.h): Initialize _is_returning_random_value to false.
  • Tests (test/sql/test_udf/T|R/test_jvm_udf):
    • Add UDF echoint, create table t1, load data via generate_series, and validate any_match((x)->cast(echoint(1) as boolean), c2) returns 40960.

Written by Cursor Bugbot for commit 0bf1c2ba57414dd6f0b66705bd46a646c8795ba1. This will update automatically on new commits. Configure here.

mergify[bot] avatar Dec 12 '25 06:12 mergify[bot]

๐Ÿงช CI Insights

Here's what we observed from your CI run for 0bf1c2ba.

โœ… Passed Jobs With Interesting Signals

Pipeline Job Signal Health on branch-3.5 Retries ๐Ÿ” CI Insights ๐Ÿ“„ Logs
PR CHECKER automerge-check Base branch is broken, but the job passed. Looks like this might be a real fix ๐Ÿ’ช Broken 0 View View

mergify[bot] avatar Dec 12 '25 06:12 mergify[bot]

@cursor review

alvin-celerdata avatar Dec 12 '25 07:12 alvin-celerdata