alamb commented on code in PR #7086:
URL: https://github.com/apache/arrow-datafusion/pull/7086#discussion_r1273413190
##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -169,19 +169,22 @@ fn signature(lhs: &DataType, op: &Operator, rhs:
&DataType) -> Result<Signature>
fn mathematics_temporal_result_type(
lhs_type: &DataType,
rhs_type: &DataType,
+ op: &Operator,
) -> Option<DataType> {
use arrow::datatypes::DataType::*;
use arrow::datatypes::IntervalUnit::*;
use arrow::datatypes::TimeUnit::*;
match (lhs_type, rhs_type) {
// datetime +/- interval
- (Interval(_), Timestamp(_, _)) => Some(rhs_type.clone()),
- (Timestamp(_, _), Interval(_)) => Some(lhs_type.clone()),
- (Interval(_), Date32) => Some(rhs_type.clone()),
- (Date32, Interval(_)) => Some(lhs_type.clone()),
- (Interval(_), Date64) => Some(rhs_type.clone()),
- (Date64, Interval(_)) => Some(lhs_type.clone()),
+ (Timestamp(_, _) | Date32 | Date64, Interval(_)) =>
Some(lhs_type.clone()),
Review Comment:
I didn't realize it was possible to do a match on a subfield of a tuple. TIL
🤯
##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -169,19 +169,22 @@ fn signature(lhs: &DataType, op: &Operator, rhs:
&DataType) -> Result<Signature>
fn mathematics_temporal_result_type(
lhs_type: &DataType,
rhs_type: &DataType,
+ op: &Operator,
) -> Option<DataType> {
use arrow::datatypes::DataType::*;
use arrow::datatypes::IntervalUnit::*;
use arrow::datatypes::TimeUnit::*;
match (lhs_type, rhs_type) {
// datetime +/- interval
- (Interval(_), Timestamp(_, _)) => Some(rhs_type.clone()),
- (Timestamp(_, _), Interval(_)) => Some(lhs_type.clone()),
- (Interval(_), Date32) => Some(rhs_type.clone()),
- (Date32, Interval(_)) => Some(lhs_type.clone()),
- (Interval(_), Date64) => Some(rhs_type.clone()),
- (Date64, Interval(_)) => Some(lhs_type.clone()),
+ (Timestamp(_, _) | Date32 | Date64, Interval(_)) =>
Some(lhs_type.clone()),
Review Comment:
I didn't realize it was possible to do a match on a subfield of a tuple. TIL
🤯
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]