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 3 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 evaluation for independent lambdas with constant input, initialize Java UDF random-value flag, and add SQL tests validating UDF with any_match.

  • Exprs:
    • be/src/exprs/array_map_expr.cpp: When lambda is independent and inputs are constant, coerce evaluated result to a single-row const (or const-null) column before replication; then align return type. Prevents incorrect results from constant unary expressions.
    • 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, table t1, data population via generate_series, and query using any_match((x)->cast(echoint(1) as boolean), c2) with expected count 40960.

Written by Cursor Bugbot for commit c963b0b980c9d81fcbfaccddfb257bcbf65152ec. 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 c963b0b9.

🟢 All jobs passed!

But CI Insights is watching 👀

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

@cursor review

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