Skip to content

[GLUTEN] Route bitmap_or_agg to native Velox execution#12242

Open
minni31 wants to merge 4 commits into
apache:mainfrom
minni31:bitmap-or-agg
Open

[GLUTEN] Route bitmap_or_agg to native Velox execution#12242
minni31 wants to merge 4 commits into
apache:mainfrom
minni31:bitmap-or-agg

Conversation

@minni31

@minni31 minni31 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

Route bitmap_or_agg aggregate function to native Velox execution, following the same pattern as bitmap_construct_agg (#12142).

Changes:

  • Add BITMAP_OR_AGG constant to ExpressionNames
  • Add bitmap_or_agg to C++ plan validator supportedAggFuncs
  • Register Sig[BitmapOrAgg] in Spark 3.5/4.0/4.1 shims
  • Add DefaultValidator() to CH_AGGREGATE_FUNC_BLACKLIST (CH fallback)
  • Add plan-shape assertion tests that specifically validate the bitmap_or_agg aggregate is routed to a native HashAggregateExecBaseTransformer
  • Add ClickHouse test exclusions for native-only tests

How was this patch tested?

  • Added GlutenBitmapExpressionsQuerySuite tests for Spark 3.5, 4.0, and 4.1 that:
    • Execute a query using bitmap_or_agg over a subquery producing bitmaps
    • Assert that the executed plan contains a HashAggregateExecBaseTransformer whose aggregateExpressions include a BitmapOrAgg function instance
  • ClickHouse backend tests are excluded since bitmap aggregates are not supported natively in CH

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude claude-sonnet-4-6

Copilot AI review requested due to automatic review settings June 4, 2026 16:43
@github-actions github-actions Bot added CORE works for Gluten Core VELOX CLICKHOUSE labels Jun 4, 2026
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support wiring for the bitmap_or_agg aggregate across Spark shims and backend validation, plus query-plan routing tests (with backend-specific exclusions where not yet supported).

Changes:

  • Register bitmap_or_agg in Spark 3.5/4.0/4.1 shims and add the expression name constant.
  • Add query suite coverage asserting bitmap_or_agg routes to native aggregation.
  • Update backend allow/deny lists (Velox validator + CH function validation / test exclusions).

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
shims/spark41/.../Spark41Shims.scala Registers bitmap_or_agg expression signature for Spark 4.1 shim.
shims/spark40/.../Spark40Shims.scala Registers bitmap_or_agg expression signature for Spark 4.0 shim.
shims/spark35/.../Spark35Shims.scala Registers bitmap_or_agg expression signature for Spark 3.5 shim.
shims/common/.../ExpressionNames.scala Adds BITMAP_OR_AGG SQL function name constant.
gluten-ut/spark41/.../GlutenBitmapExpressionsQuerySuite.scala Adds routing-to-native test for bitmap_or_agg.
gluten-ut/spark41/.../VeloxTestSettings.scala Excludes new bitmap_or_agg test for Velox backend pending support.
gluten-ut/spark41/.../ClickHouseTestSettings.scala Excludes new bitmap_or_agg test for CH backend.
gluten-ut/spark40/.../GlutenBitmapExpressionsQuerySuite.scala Adds routing-to-native test for bitmap_or_agg.
gluten-ut/spark40/.../VeloxTestSettings.scala Excludes new bitmap_or_agg test for Velox backend pending support.
gluten-ut/spark40/.../ClickHouseTestSettings.scala Excludes new bitmap_or_agg test for CH backend.
gluten-ut/spark35/.../GlutenBitmapExpressionsQuerySuite.scala Adds routing-to-native test for bitmap_or_agg.
gluten-ut/spark35/.../VeloxTestSettings.scala Excludes new bitmap_or_agg test for Velox backend pending support.
gluten-ut/spark35/.../ClickHouseTestSettings.scala Excludes new bitmap_or_agg test for CH backend.
cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc Whitelists bitmap_or_agg as a supported aggregate in Velox plan validation.
backends-clickhouse/.../CHExpressionUtil.scala Adds bitmap_or_agg to CH expression validation map.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI review requested due to automatic review settings June 4, 2026 16:50
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Comment on lines +41 to +54
test("bitmap_or_agg routes to native") {
val df = spark.sql(
"SELECT bitmap_or_agg(bm) FROM (" +
"SELECT bitmap_construct_agg(bitmap_bit_position(col)) AS bm " +
"FROM values (1L), (2L), (3L) AS t(col)" +
") sub")
df.collect()
assert(
collectWithSubqueries(df.queryExecution.executedPlan) {
case h: HashAggregateExecBaseTransformer => h
}.nonEmpty,
"Expected native HashAggregateExecBaseTransformer in plan"
)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Valid concern. The native Velox bitmap_or_agg function has since landed upstream (the test exclusion was removed in a follow-up commit). The validator entry and runtime capability are now consistent.

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

1 similar comment
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Minni Mittal and others added 4 commits July 7, 2026 06:09
Register bitmap_or_agg aggregate function for native Velox execution:
- Add BITMAP_OR_AGG constant to ExpressionNames
- Add bitmap_or_agg to C++ plan validator supportedAggFuncs
- Register Sig[BitmapOrAgg] in Spark 3.5/4.0/4.1 shims
- Add DefaultValidator() to CH_AGGREGATE_FUNC_BLACKLIST (CH fallback)
- Add plan-shape assertion test (excluded until Velox function lands)
- Add ClickHouse test exclusions for native-only test

Note: The native Velox bitmap_or_agg function is pending upstream
(facebookincubator/velox). The test is excluded in VeloxTestSettings
until that PR is merged and Gluten's Velox dependency is updated.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The native bitmap_or_agg function has been merged upstream in Velox.
Remove the .exclude() entries from VeloxTestSettings so the plan-shape
assertion test now runs on CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use a subquery to avoid nesting bitmap_construct_agg inside
bitmap_or_agg at the same aggregation level.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…omment

- Assert specifically that HashAggregateExecBaseTransformer contains a
  BitmapOrAgg aggregate function, not just that any native aggregate
  exists in the plan (spark35/spark40/spark41 test suites)
- Update CH test settings comment to mention both bitmap_construct_agg
  and bitmap_or_agg exclusions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 7, 2026 06:25
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLICKHOUSE CORE works for Gluten Core VELOX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants