Skip to content

test: ceil and floor works correctly for Decimal128#3848

Merged
kazuyukitanimura merged 7 commits into
apache:mainfrom
kazuyukitanimura:fix-1729
Apr 2, 2026
Merged

test: ceil and floor works correctly for Decimal128#3848
kazuyukitanimura merged 7 commits into
apache:mainfrom
kazuyukitanimura:fix-1729

Conversation

@kazuyukitanimura
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #1729

Rationale for this change

#1729 was opened due to PR #1728 (comment #1728 (comment))
Later #3675 disabled ceil and floor for decimals.

However, the rust test cases added in #1728 are incorrect in my opinion. When spark ceil/floor, Spark changes precision and scale. And later result precision and scale are set at https://github.com/apache/datafusion-comet/blob/main/native/spark-expr/src/math_funcs/ceil.rs#L51
The output of decimal_ceil_f is intermediate result. Therefore. decimal_ceil_f is correct and the expected values of rust test cases are incorrect.

What changes are included in this PR?

Corrected the rust test cases. Enabled ceil and floor again

How are these changes tested?

@kazuyukitanimura kazuyukitanimura marked this pull request as ready for review March 31, 2026 06:44
Comment thread native/spark-expr/src/math_funcs/ceil.rs

-- Config: spark.comet.expression.Ceil.allowIncompatible=true
-- ConfigMatrix: parquet.enable.dictionary=false,true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: It would be nice to add a decimal column to the SQL test data so that decimal ceil/floor is tested through the SQL file framework too. Something like adding a decimal(5,2) column to the test table

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.

added

Copy link
Copy Markdown
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

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

LGTM with one suggestion. Thanks @kazuyukitanimura

@kazuyukitanimura
Copy link
Copy Markdown
Contributor Author

Thanks @andygrove I have added decimal columns to ceil/floor sql
Once it passes CI, I plan to merge this

@kazuyukitanimura kazuyukitanimura merged commit 87d049b into apache:main Apr 2, 2026
181 of 182 checks passed
@kazuyukitanimura
Copy link
Copy Markdown
Contributor Author

Merged, thanks @andygrove

vaibhawvipul pushed a commit to vaibhawvipul/datafusion-comet that referenced this pull request Apr 4, 2026
## Which issue does this PR close?

Closes apache#1729

## Rationale for this change

apache#1729 was opened due to PR apache#1728 (comment apache#1728 (comment))
Later apache#3675 disabled `ceil` and `floor` for decimals.

However, the rust test cases added in apache#1728 are incorrect in my opinion. When spark `ceil`/`floor`, Spark changes precision and scale. And later result precision and scale are set at https://github.com/apache/datafusion-comet/blob/main/native/spark-expr/src/math_funcs/ceil.rs#L51
The output of `decimal_ceil_f` is intermediate result. Therefore. `decimal_ceil_f` is correct and the expected values of rust test cases are incorrect.

## What changes are included in this PR?

Corrected the rust test cases. Enabled `ceil` and `floor` again

## How are these changes tested?
andygrove pushed a commit to andygrove/datafusion-comet that referenced this pull request Apr 8, 2026
## Which issue does this PR close?

Closes apache#1729

## Rationale for this change

apache#1729 was opened due to PR apache#1728 (comment apache#1728 (comment))
Later apache#3675 disabled `ceil` and `floor` for decimals.

However, the rust test cases added in apache#1728 are incorrect in my opinion. When spark `ceil`/`floor`, Spark changes precision and scale. And later result precision and scale are set at https://github.com/apache/datafusion-comet/blob/main/native/spark-expr/src/math_funcs/ceil.rs#L51
The output of `decimal_ceil_f` is intermediate result. Therefore. `decimal_ceil_f` is correct and the expected values of rust test cases are incorrect.

## What changes are included in this PR?

Corrected the rust test cases. Enabled `ceil` and `floor` again

## How are these changes tested?
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.

Processing logic of the function ceil/floor for Decimal128 datatype seems to be wrong

2 participants