Skip to content

[datafusion-spark] Add Spark-compatible ceil function#20593

Open
shivbhatia10 wants to merge 9 commits intoapache:mainfrom
shivbhatia10:sb/datafusion-math-ceil
Open

[datafusion-spark] Add Spark-compatible ceil function#20593
shivbhatia10 wants to merge 9 commits intoapache:mainfrom
shivbhatia10:sb/datafusion-math-ceil

Conversation

@shivbhatia10
Copy link
Contributor

@shivbhatia10 shivbhatia10 commented Feb 27, 2026

Which issue does this PR close?

Part of #15914 and apache/datafusion-comet#1704

I also just noticed #15916 butI believe work has been stale on this one.

Rationale for this change

Helping to continue adding Spark compatible expressions to datafusion-spark.

What changes are included in this PR?

Add new ceil function.

Are these changes tested?

Yes, unit tests.

Are there any user-facing changes?

No.

@github-actions github-actions bot added the spark label Feb 27, 2026
@shivbhatia10 shivbhatia10 changed the title Add ceil [datafusion-spark] Add Spark-compatible ceil function Feb 27, 2026
@shivbhatia10 shivbhatia10 marked this pull request as ready for review February 27, 2026 13:35
Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

Thanks @shivbhatia10 it would be nice having Spark .slt tests covering edge cases and datatypes as well as commenting in file body what is the difference between Spark and current DF implementation

@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Feb 28, 2026
@shivbhatia10
Copy link
Contributor Author

Hey @comphead, I've added some .slt tests and uncommented a few existing ones that seem have been there as placeholders for when we got this implementation, and I expanded on the comment explaining the differences between this and the DataFusion ceil function.

@comphead
Copy link
Contributor

comphead commented Mar 2, 2026

Thanks @shivbhatia10 would you mind providing an example where DF ceil and Spark ceil return diff result? I'm still struggling to understand the difference between them

/// - Spark's ceil on Decimal128(p, s) returns Decimal128(p−s+1, 0), reducing scale
/// to 0; DataFusion preserves the original precision and scale
/// - Spark only supports Decimal128; DataFusion also supports Decimal32/64/256
/// - Spark does not check for decimal overflow; DataFusion errors on overflow
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @comphead , I've documented the differences here between the Spark and DataFusion ceil functions

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I was going through this, and this actually causing a question to find a query using ceil that currently behaves differently in DF and in Spark? it can be Spark Ansi mode as well

Copy link
Contributor

Choose a reason for hiding this comment

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

Please check #20611 as the example

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

Labels

spark sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants