Registry Mirror
Skip to content

Conversation

@TechWizard9999

@TechWizard9999 TechWizard9999 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Callers that run it without the simplifier, such as comet, got an internal error instead of the result.

What changes are included in this PR?

Add a working invoke with args that adds the months to the date, the same as the simplified form.

Are these changes tested?

Yes, the existing slt tests now also run without simplify, and added tests with column arguments.

Are there any user-facing changes?

Yes, callers that run it without the simplifier, such as comet, now get the result instead of an internal error.

@TechWizard9999

Copy link
Copy Markdown
Contributor Author

@andygrove Please review. Thanks.

@andygrove andygrove left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, this is a nice small fix and it follows the issue closely. I checked that the evaluate path really matches the rewrite. simplify produces a BinaryExpr that uses add_wrapping, and this uses add, but for Date32 + Interval(YearMonth) arrow-arith sends both to the same checked add_year_month. So overflow behaves the same either way. I also restored the old add_months.rs with your .slt in place, and the [evaluate] run fails with the internal error, so the dropped skipif evaluate lines are doing their job.

I ran a few extra cases in both modes and against PySpark 4.2.0 and 3.5.9 with ANSI on and off. They covered an array of dates with a scalar month count, 2016-03-31 minus one month, ±2^31 months as scalars and in a column, a NULL date next to an overflowing month count, and ANSI mode. Everything matched. The overflow message text differs from Spark's [ARITHMETIC_OVERFLOW], but that was already true before this PR.

One test suggestion inline. Also, could you update "Are there any user-facing changes?" in the description before merge, since it becomes the commit message? Callers that evaluate add_months without simplify, such as Comet, now get a result instead of Internal error: invoke should not be called on a simplified add_months() function.

@TechWizard9999

Copy link
Copy Markdown
Contributor Author

@andygrove Ready for another look.

# Conflicts:
#	crates/spark/src/function/datetime/add_months.rs

@andygrove andygrove left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the follow-up. The column-with-scalar record is in and the description is updated. I merged this with current main locally, and add_months.slt passes in both modes and on Spark 3.5.9 and 4.2.0.

@andygrove
andygrove enabled auto-merge (squash) December 4, 2026 14:30
@TechWizard9999

Copy link
Copy Markdown
Contributor Author

@andygrove Thanks for reviewing

@andygrove
andygrove merged commit 7b5bb6d into apache:main Dec 4, 2026
15 checks passed
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.

[Bug] add_months errors when evaluated without simplify: invoke_with_args is not implemented

2 participants