Skip to content

Adds support for ANSI mode in negative function#20189

Merged
comphead merged 5 commits intoapache:mainfrom
SubhamSinghal:support-ansi-mode-for-negative-function
Feb 14, 2026
Merged

Adds support for ANSI mode in negative function#20189
comphead merged 5 commits intoapache:mainfrom
SubhamSinghal:support-ansi-mode-for-negative-function

Conversation

@SubhamSinghal
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

#20034

Rationale for this change

ANSI mode support for negative function

What changes are included in this PR?

Added support for ANSI mode for negative function

Are these changes tested?

yes through UT

Are there any user-facing changes?

yes, adds ANSI support to existing function.

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) spark labels Feb 6, 2026
Copy link
Copy Markdown
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 @SubhamSinghal I'll check it soon, however ansi mode now makes me think how to better structure tests. What I mean is ANSI edge cases are rare and most of cases should have same results no matter of ANSI flag. That can generate test scenarios duplication which would be nice to avoid

@SubhamSinghal
Copy link
Copy Markdown
Contributor Author

@comphead Modified UTs to contain only overflow tests in ANSI mode.

let result: PrimitiveArray<Int8Type> = if enable_ansi_mode {
array.try_unary(|x| {
x.checked_neg().ok_or_else(|| {
ArrowError::ComputeError(format!(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lets use
exec_err! to be in sync with other functions

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.

@comphead I was looking at this which throw Arrow::ComputeError. Do we need to throw exec_err! instead?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Arrow::ComputeError is for errors happening inside Arrow kernels, and here I believe is checked_neg from core::num ?

Comment thread datafusion/spark/src/function/math/negative.rs Outdated
Copy link
Copy Markdown
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.

@comphead comphead added this pull request to the merge queue Feb 14, 2026
Merged via the queue into apache:main with commit 98cc753 Feb 14, 2026
28 checks passed
de-bgunter pushed a commit to de-bgunter/datafusion that referenced this pull request Mar 24, 2026
## Which issue does this PR close?

apache#20034


## Rationale for this change

ANSI mode support for negative function

## What changes are included in this PR?

Added support for ANSI mode for negative function

## Are these changes tested?

yes through UT

## Are there any user-facing changes?

yes, adds ANSI support to existing function.

---------

Co-authored-by: Subham Singhal <subhamsinghal@Subhams-MacBook-Air.local>
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