Skip to content

Test: Add test coverage and documentation for SumDecimal/AvgDecimal nullability behavior#3766

Merged
parthchandra merged 7 commits intoapache:mainfrom
vaibhawvipul:issue-961
Mar 25, 2026
Merged

Test: Add test coverage and documentation for SumDecimal/AvgDecimal nullability behavior#3766
parthchandra merged 7 commits intoapache:mainfrom
vaibhawvipul:issue-961

Conversation

@vaibhawvipul
Copy link
Copy Markdown
Contributor

@vaibhawvipul vaibhawvipul commented Mar 23, 2026

Which issue does this PR close?

Closes #961 .

Rationale for this change

SumDecimal and AvgDecimal hardcode nullable=true. In Spark, Sum.nullable and Average.nullable both return true irrespective of ANSI mode. This PR documents that behavior and adds test coverage to ensure Comet stays consistent with Spark.

What changes are included in this PR?

  • Added comments to SumDecimal.is_nullable() and AvgDecimal.is_nullable() documenting that Spark always returns true for nullable, regardless of ANSI mode.
  • Added an explicit is_nullable() override to AvgDecimal (previously relied on default) with the same documentation.

How are these changes tested?

Added a test in CometAggregateSuite that exercises SUM and AVG on decimal columns with both nullable and non-nullable inputs, under both ANSI and non-ANSI modes. The test asserts nullable == true in all cases and uses checkSparkAnswerAndOperator to verify results match Spark.

Copy link
Copy Markdown
Contributor

@parthchandra parthchandra left a comment

Choose a reason for hiding this comment

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

Ci is failing because the benchmarks have a couple of call sites that need to be updated.

Comment thread native/spark-expr/src/agg_funcs/avg_decimal.rs
…vior

In Spark, Sum.nullable and Average.nullable both return true irrespective
of ANSI mode. Reverted the ANSI-aware is_nullable logic and added comments
documenting this Spark behavior. Test updated to assert nullable is always true.
@vaibhawvipul vaibhawvipul changed the title fix: Make SumDecimal/AvgDecimal nullable only when not in ANSI mode or input is nullable Test: Add test coverage and documentation for SumDecimal/AvgDecimal nullability behavior Mar 24, 2026
@vaibhawvipul
Copy link
Copy Markdown
Contributor Author

@parthchandra I have added a test in CometAggregateSuite to ensure that our behviour matches with spark, under both modes for nullability behaviour.

I have reverted my changes in the rust code to keep comet's behaviour consistent with spark.

@parthchandra
Copy link
Copy Markdown
Contributor

rebasing on main should fix the check-missing-suites ci failure

Copy link
Copy Markdown
Contributor

@parthchandra parthchandra left a comment

Choose a reason for hiding this comment

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

lgtm. pending ci

@vaibhawvipul
Copy link
Copy Markdown
Contributor Author

rebasing on main should fix the check-missing-suites ci failure

@parthchandra thank you for the approval. I think this can be merged.

@vaibhawvipul
Copy link
Copy Markdown
Contributor Author

@parthchandra thank you for re-basing. i missed it.

@parthchandra parthchandra merged commit bc5fa00 into apache:main Mar 25, 2026
166 of 167 checks passed
@parthchandra
Copy link
Copy Markdown
Contributor

Merged. Thanks @vaibhawvipul

@vaibhawvipul vaibhawvipul deleted the issue-961 branch March 25, 2026 16:39
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.

SumDecimal always returns nullable=true

2 participants