-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: allow scalars to appear as the LHS arg in arithmetic operations on temporal values #6196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
24d8c27
a0d4f88
8b7479c
3f785d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,16 +120,21 @@ impl PhysicalExpr for DateTimeIntervalExpr { | |
| (ColumnarValue::Array(array_lhs), ColumnarValue::Scalar(array_rhs)) => { | ||
| resolve_temporal_op_scalar(&array_lhs, sign, &array_rhs) | ||
| } | ||
| // This function evaluates operations between a scalar value and an array of temporal | ||
| // values. One example is calculating the duration between a scalar timestamp and an | ||
| // array of timestamps (i.e. `now() - some_column`). | ||
| (ColumnarValue::Scalar(scalar_lhs), ColumnarValue::Array(array_rhs)) => { | ||
| let array_lhs = scalar_lhs.to_array_of_size(array_rhs.len()); | ||
| Ok(ColumnarValue::Array(resolve_temporal_op( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of the
Thank you for working on this issue. I can assist further if needed.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @berkaysynnada are you suggesting we should change this PR? Or can it be merged as is? I am not quite sure what action your comment is suggesting
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There is an operation creating an array from the scalar value. My suggestions intended to prevent this. I think we can merge this PR, I can update that part with a quick PR in the following days. |
||
| &array_lhs, sign, &array_rhs, | ||
| )?)) | ||
| } | ||
| // This function evaluates temporal array operations, such as timestamp - timestamp, interval + interval, | ||
| // timestamp + interval, and interval + timestamp. It takes two arrays as input and an integer sign representing | ||
| // the operation (+1 for addition and -1 for subtraction). | ||
| (ColumnarValue::Array(array_lhs), ColumnarValue::Array(array_rhs)) => Ok( | ||
| ColumnarValue::Array(resolve_temporal_op(&array_lhs, sign, &array_rhs)?), | ||
| ), | ||
| (_, _) => { | ||
| let msg = "If RHS of the operation is an array, then LHS also must be"; | ||
| Err(DataFusionError::Internal(msg.to_string())) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍