[GLUTEN-12255][VL] Rewrite multi-children Count in window expressions#12256
Open
WangGuangxin wants to merge 2 commits into
Open
[GLUTEN-12255][VL] Rewrite multi-children Count in window expressions#12256WangGuangxin wants to merge 2 commits into
WangGuangxin wants to merge 2 commits into
Conversation
d73f23f to
537af67
Compare
|
Run Gluten Clickhouse CI on x86 |
1 similar comment
|
Run Gluten Clickhouse CI on x86 |
537af67 to
d9d7c01
Compare
|
Run Gluten Clickhouse CI on x86 |
d9d7c01 to
059a493
Compare
|
Run Gluten Clickhouse CI on x86 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends Gluten’s physical-plan rewrite rule for multi-argument count to also cover window functions, enabling WindowExec offload to Velox by rewriting Spark’s count(c1, c2, ...) form into an equivalent single-argument count(if(...)) expression.
Changes:
- Extend
RewriteMultiChildrenCountto rewrite multi-childrenCountinsideWindowExecwindow expressions (in addition to the existing partial-aggregate rewrite). - Add Velox backend validation to explicitly reject un-rewritten multi-argument window
countand fallback to vanilla Spark instead of crashing. - Add Velox UTs to ensure (a) offload happens after rewrite and (b) results match vanilla Spark semantics for nullable inputs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| gluten-substrait/src/main/scala/org/apache/gluten/extension/columnar/rewrite/RewriteMultiChildrenCount.scala | Add WindowExec support and factor out shared “single-child Count” construction logic. |
| backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxBackend.scala | Mark multi-arg window Count as unsupported to force fallback when rewrite is not applied. |
| backends-velox/src/test/scala/org/apache/gluten/functions/WindowFunctionsValidateSuite.scala | Add tests covering offload + semantic equivalence for rewritten multi-arg window count. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Run Gluten Clickhouse CI on x86 |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
b986a5a to
f2f113d
Compare
|
Run Gluten Clickhouse CI on x86 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are proposed in this pull request?
Similiar to #4471, since Velox only supports count() / count(T) for window functions. Spark's
count(c1, c2, ...)variant must be rewritten intocount(if(or(isnull(c1),isnull(c2), ...), null, 1))so theWindowExeccan still be offloaded, which has already be handled inAggregateExecHow was this patch tested?
More UT
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Copilot
Related issue: #12255