Conversation
|
@andygrove Please review. Thanks. |
andygrove
left a comment
There was a problem hiding this comment.
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.
|
@andygrove Ready for another look. |
# Conflicts: # crates/spark/src/function/datetime/add_months.rs
andygrove
left a comment
There was a problem hiding this comment.
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 Thanks for reviewing |
Which issue does this PR close?
add_monthserrors when evaluated withoutsimplify:invoke_with_argsis not implemented #312.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.