Skip to content

refactor: move aggregate expression support checks to getSupportLevel#4678

Merged
andygrove merged 1 commit into
apache:mainfrom
andygrove:refactor-aggregates-support-level
Jun 18, 2026
Merged

refactor: move aggregate expression support checks to getSupportLevel#4678
andygrove merged 1 commit into
apache:mainfrom
andygrove:refactor-aggregates-support-level

Conversation

@andygrove

Copy link
Copy Markdown
Member

Which issue does this PR close?

Part of #4673.

Rationale for this change

The serde framework intends that an expression declares whether it can be accelerated through getSupportLevel, with the central dispatcher in QueryPlanSerde translating Incompatible/Unsupported into the appropriate fallback. Several aggregate serdes instead made these decisions inside convert by calling withFallbackReason directly, even though the decisions are statically determinable from the expression.

What changes are included in this PR?

Move static support decisions out of convert and into getSupportLevel for the aggregate expressions:

  • Min, Max: unsupported data type and the strict-floating-point gate, via a shared AggSerde.minMaxSupportLevel helper.
  • Average, Sum, BitAndAgg, BitOrAgg, BitXorAgg: unsupported data type.
  • BloomFilterAggregate: unsupported child data type (the static type filter that was embedded in the convert guard).

This is behavior-preserving: every case that previously fell back to Spark continues to fall back. The remaining withFallbackReason calls in this file are child-reason rollups, including the serializeDataType rollups gated on dataType.isEmpty, which are the intended use inside convert.

How are these changes tested?

Covered by existing tests in CometAggregateSuite (80 tests covering min/max/sum/avg/bit aggregates and decimal/float paths) and the bloom_filter_agg test in CometExecSuite, which exercise both the supported and fallback paths.

Static data-type and strict-floating-point support decisions for the
aggregate expressions are moved out of the serde convert methods and into
getSupportLevel:

- Min, Max: unsupported data type and strict-floating-point gate (via a
  shared AggSerde.minMaxSupportLevel helper)
- Average, Sum, BitAndAgg, BitOrAgg, BitXorAgg: unsupported data type
- BloomFilterAggregate: unsupported child data type

Behavior is unchanged: each case that previously fell back to Spark now
reports Unsupported. The remaining withFallbackReason calls are child-reason
rollups, including the serializeDataType rollups gated on dataType.isEmpty.

object CometSum extends CometAggregateExpressionSerde[Sum] {

override def getSupportLevel(expr: Sum): SupportLevel =

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.

we prob should have datatype supported on object level rather than on AggSerde level

override def supportsMixedPartialFinal: Boolean = true

override def getSupportLevel(expr: BitAndAgg): SupportLevel =
if (AggSerde.bitwiseAggTypeSupported(expr.dataType)) {

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.

same

case _: ByteType | _: ShortType | _: IntegerType | _: LongType | _: StringType =>
Compatible()
case other =>
Unsupported(Some(s"Unsupported data type for bloom_filter_agg child: $other"))

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.

Btw this message can unified and be on the base class, unless overriden. Currently unsupported messages are not consistent

@comphead comphead 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.

Thanks @andygrove

@andygrove andygrove merged commit 2c5b842 into apache:main Jun 18, 2026
70 checks passed
@andygrove andygrove deleted the refactor-aggregates-support-level branch June 18, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants