Skip to content

Conversation

@SubhamSinghal
Copy link

@SubhamSinghal SubhamSinghal commented Jan 26, 2026

What changes are included in this PR?

Adds support for negative spark function in data fusion.

Are these changes tested?

yes, using UTs

Are there any user-facing changes?

yes, adds new function.

@SubhamSinghal SubhamSinghal changed the title Adds negative spark function feat(spark): Adds negative spark function Jan 26, 2026
@github-actions github-actions bot added the spark label Jan 26, 2026
@comphead
Copy link
Contributor

Running CI

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 @SubhamSinghal

Please add .slt tests for negative functions, the simplest case is https://spark.apache.org/docs/latest/api/sql/#negative

However you can generate bunch of other edge cases with LLM

@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Jan 27, 2026
| DataType::UInt8
| DataType::UInt16
| DataType::UInt32
| DataType::UInt64 => Ok(args[0].clone()),
Copy link
Member

Choose a reason for hiding this comment

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

I wonder whether this should be an error instead.
I cannot find how others do it: Spark does not support unsigned types, Postgres/DuckDB do not provide negative() function.

Copy link
Author

Choose a reason for hiding this comment

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

@Jefffrey @comphead should we throw error here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a need to throw an error here; it's easier to just allow it

Copy link
Contributor

Choose a reason for hiding this comment

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

@Jefffrey this doesn't seem right to me... semantically you're not returning the negative of the number here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes you're right, I'm sorry; I think my brain was thinking of abs for some reason here 😅

Copy link
Author

Choose a reason for hiding this comment

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

@xanderbailey thanks for pointing this out. Fixed this now.

@SubhamSinghal
Copy link
Author

Could you please also add some tests for them to negative.slt ?

Done

comphead
comphead previously approved these changes Jan 28, 2026
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 @SubhamSinghal IMO the PR is good to go, appreciate the contribution

UPD: CI is failing now for tests, I'll wait for green CI, however as I said before the PR looks good overall

@comphead comphead self-requested a review January 28, 2026 18:15
@comphead comphead dismissed their stale review January 28, 2026 18:15

waiting for CI

@SubhamSinghal
Copy link
Author

@comphead Changes Signature from Signature::numeric to Signature::any to allow IntervalType. Can you run CI again?

@comphead
Copy link
Contributor

@SubhamSinghal some tests are still failing

@SubhamSinghal
Copy link
Author

some tests are still failing
@comphead Fixed UT

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.

5 participants