Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add overflow behavior to integer division #223

Merged
merged 1 commit into from
Jul 12, 2022

Conversation

westonpace
Copy link
Member

When working on apache/arrow#13285 we noticed that there is no overflow behavior for division. My first thought was that overflow is not possible on division but it turns out that there is one special case of overflow when the data type is signed integers.

For example, consider 8 bit signed integers. The range is -128,127. However, -128 / -1 => 128 which is outside the range. I'm not entirely sure what SATURATE would mean in this case but it seems it could mean 127 for the simplicity of having one set of overflow handling options for all the arithmetic.

@westonpace
Copy link
Member Author

CC @sanjibansg who discovered this discrepency

@jacques-n
Copy link
Contributor

Good catch. Do we need to add to decimal as well?

As a note, I don't see the the introduction of an optional argument to a function as a breaking change so consider this fix identification as a valid non-breaking change. (I think you went through this as well but want to call out explicitly.)

@jacques-n
Copy link
Contributor

Ping here on Decimal.

Copy link
Contributor

@jacques-n jacques-n left a comment

Choose a reason for hiding this comment

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

Looking for same changes wrt to Decimal.

@westonpace
Copy link
Member Author

@jacques-n I'm not sure I understand. Division for decimal already specifies overflow I think:

@westonpace westonpace requested a review from jacques-n July 12, 2022 15:24
Copy link
Contributor

@jacques-n jacques-n left a comment

Choose a reason for hiding this comment

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

Thanks for being patient!

@jacques-n jacques-n merged commit cf552d7 into substrait-io:main Jul 12, 2022
curino pushed a commit to curino/substrait that referenced this pull request Jul 20, 2022
BREAKING CHANGE: The signature of divide functions for multiple types now specify an enumeration prior to specifying operands.
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