Skip to content

feat: Add ANSI mode support for unaryminus overflow detection#16672

Open
n0r0shi wants to merge 1 commit intofacebookincubator:mainfrom
n0r0shi:config-unaryminus
Open

feat: Add ANSI mode support for unaryminus overflow detection#16672
n0r0shi wants to merge 1 commit intofacebookincubator:mainfrom
n0r0shi:config-unaryminus

Conversation

@n0r0shi
Copy link
Contributor

@n0r0shi n0r0shi commented Mar 7, 2026

Summary

  • Make unaryminus config-based: when spark.ansi.enabled is true, negating the minimum value of an integer type (e.g., -(-128) for tinyint) throws an arithmetic overflow error instead of silently returning the minimum value
  • Follows the same pattern as abs, which already reads sparkAnsiEnabled from QueryConfig
  • Float/double types are unaffected by ANSI mode

Picks up the unaryminus portion from #16361, which has been inactive.

Test plan

  • Existing UnaryMinus tests pass (normal cases unaffected)
  • ANSI off: negating MIN returns MIN unchanged (existing behavior)
  • ANSI on: negating MIN throws arithmetic overflow for all integer types
  • TRY wrapping returns null instead of throwing

Make unaryminus config-based: when spark.ansi.enabled is true, negating
the minimum value of an integer type throws an arithmetic overflow error.
@netlify
Copy link

netlify bot commented Mar 7, 2026

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 594d5b8
🔍 Latest deploy log https://app.netlify.com/projects/meta-velox/deploys/69abfd3c0f3c1e000811da9f

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant