Skip to content

[Enhancement] lead/lag/first_value/last_value support array type - #63547

Merged
andyziye merged 1 commit into
mainfrom
lead_lag_array_type
Oct 11, 2025
Merged

andyziye merged 1 commit into
mainfrom
lead_lag_array_type

Conversation

@satanson

@satanson satanson commented Sep 25, 2025 •

Copy link
Copy Markdown
Contributor

Why I'm doing:

Window functions last_value/first_value/lead/lag accept array type as argument.

What I'm doing:

Fixes #issue

What type of PR is this:

  • 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.
  • 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:

  • 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
  • This is a backport pr

Bugfix cherry-pick branch check:

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

Note

Add array-type support to window functions (lead/lag/first_value/last_value) across BE/FE, including low-cardinality integration and comprehensive tests.

  • Window functions (Array support):
    • BE: Enable TYPE_ARRAY in resolver and dispatch; add array handling in AggDataTypeTraits, ValueWindowStrategy, and default value parsing for lead/lag.
    • FE: Register array variants of first_value/last_value/lead/lag in FunctionSet; extend low-cardinality rewrite (DecodeContext) to handle array args and window functions.
  • Optimization/compatibility:
    • Integrate array window functions with low-cardinality dict decoding flows and ignore-nulls behavior.
  • Tests:
    • Update/extend unit and SQL tests to validate array arguments for window functions and adjust expected plans/results accordingly; add new lead/lag array test suite.

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

@satanson
satanson requested review from a team as code owners September 25, 2025 06:22
@satanson
satanson force-pushed the lead_lag_array_type branch 2 times, most recently from d2f9479 to 2cb4427 Compare September 25, 2025 11:34
@satanson

Copy link
Copy Markdown
Contributor Author

@Mergifyio rebase

@mergify

mergify Bot commented Sep 26, 2025

Copy link
Copy Markdown
Contributor

rebase

✅ Branch has been successfully rebased

@satanson

Copy link
Copy Markdown
Contributor Author

@Mergifyio rebase

@mergify

mergify Bot commented Sep 29, 2025

Copy link
Copy Markdown
Contributor

rebase

✅ Branch has been successfully rebased

@satanson
satanson force-pushed the lead_lag_array_type branch 2 times, most recently from b099130 to 33b2c26 Compare September 30, 2025 06:17
kangkaisen
kangkaisen previously approved these changes Oct 9, 2025
ZiheLiu
ZiheLiu previously approved these changes Oct 9, 2025
silverbullet233
silverbullet233 previously approved these changes Oct 9, 2025
@alvin-phoenix-ai

Copy link
Copy Markdown
Contributor

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no bugs!


Signed-off-by: satanson <ranpanf@gmail.com>
@satanson
satanson force-pushed the lead_lag_array_type branch from 8ae09d0 to e25a572 Compare October 10, 2025 09:01
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

[Java-Extensions Incremental Coverage Report]

✅ pass : 0 / 0 (0%)

@github-actions

Copy link
Copy Markdown
Contributor

[FE Incremental Coverage Report]

✅ pass : 10 / 10 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/sql/optimizer/rule/tree/lowcardinality/DecodeContext.java 2 2 100.00% []
🔵 com/starrocks/catalog/FunctionSet.java 8 8 100.00% []

@github-actions

Copy link
Copy Markdown
Contributor

[BE Incremental Coverage Report]

❌ fail : 1 / 24 (04.17%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 be/src/exprs/agg/window.h 0 14 00.00% [132, 571, 572, 573, 575, 576, 684, 685, 686, 688, 707, 708, 709, 711]
🔵 be/src/exprs/agg/aggregate_traits.h 0 9 00.00% [89, 92, 93, 94, 95, 97, 98, 99, 101]
🔵 be/src/exprs/agg/factory/aggregate_resolver.hpp 1 1 100.00% []

@andyziye
andyziye merged commit 78945fd into main Oct 11, 2025
3 of 4 checks passed
@andyziye
andyziye deleted the lead_lag_array_type branch October 11, 2025 02:05
@satanson

Copy link
Copy Markdown
Contributor Author

@Mergifyio backport branch-3.5

@mergify

mergify Bot commented Oct 15, 2025 •

Copy link
Copy Markdown
Contributor

backport branch-3.5

✅ Backports have been created

Details

@satanson

Copy link
Copy Markdown
Contributor Author

@Mergifyio backport branch-4.0

@mergify

mergify Bot commented Oct 15, 2025 •

Copy link
Copy Markdown
Contributor

backport branch-4.0

✅ Backports have been created

Details

mergify Bot pushed a commit that referenced this pull request Oct 15, 2025
)

Signed-off-by: satanson <ranpanf@gmail.com>
(cherry picked from commit 78945fd)

# Conflicts:
#	be/src/exprs/agg/factory/aggregate_resolver.hpp
#	fe/fe-core/src/main/java/com/starrocks/catalog/FunctionSet.java
#	fe/fe-core/src/test/java/com/starrocks/sql/plan/LowCardinalityArrayTest.java
mergify Bot pushed a commit that referenced this pull request Oct 15, 2025
)

Signed-off-by: satanson <ranpanf@gmail.com>
(cherry picked from commit 78945fd)
satanson added a commit that referenced this pull request Oct 15, 2025
)

Signed-off-by: satanson <ranpanf@gmail.com>
(cherry picked from commit 78945fd)
satanson added a commit that referenced this pull request Oct 15, 2025
…kport #63547)

Signed-off-by: satanson <ranpanf@gmail.com>
(cherry picked from commit 78945fd)
Signed-off-by: satanson <ranpanf@gmail.com>
satanson added a commit that referenced this pull request Oct 15, 2025
…kport #63547)

Signed-off-by: satanson <ranpanf@gmail.com>
(cherry picked from commit 78945fd)
Signed-off-by: satanson <ranpanf@gmail.com>
satanson added a commit that referenced this pull request Oct 15, 2025
…kport #63547)

Signed-off-by: satanson <ranpanf@gmail.com>
(cherry picked from commit 78945fd)
Signed-off-by: satanson <ranpanf@gmail.com>
satanson added a commit that referenced this pull request Oct 16, 2025
)

Signed-off-by: satanson <ranpanf@gmail.com>
(cherry picked from commit 78945fd)
Signed-off-by: satanson <ranpanf@gmail.com>
satanson added a commit that referenced this pull request Oct 16, 2025
…kport #63547)

Signed-off-by: satanson <ranpanf@gmail.com>
(cherry picked from commit 78945fd)
Signed-off-by: satanson <ranpanf@gmail.com>
ZiheLiu pushed a commit that referenced this pull request Oct 16, 2025
…kport #63547) (#64100)

Signed-off-by: satanson <ranpanf@gmail.com>
andyziye pushed a commit that referenced this pull request Oct 16, 2025
…kport #63547) (#64084)

Signed-off-by: satanson <ranpanf@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants