Skip to content

SparkDateAdd should use wrapping addition/subtraction #17987

@andygrove

Description

@andygrove

Describe the bug

Comet recently replaced its own implementation of DateAdd with the version in datafusion-spark, and we found a regression where overflows are not caught in release builds.

The fix is likely as simple as using checked operations, so replacing ...

                |date, days| date + days,

... with ...

                |date, days| date.checked_add(days).unwrap(), // TODO with appropriate error handling, of course

This likely affects SparkDateSub as well.

To Reproduce

No response

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingspark

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions