Skip to content

Commit

Permalink
feat: Add more coercion rules for interval
Browse files Browse the repository at this point in the history
  • Loading branch information
paveltiunov committed Sep 20, 2023
1 parent 915a600 commit 00ed6a6
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions datafusion/physical-expr/src/coercion_rule/binary_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,41 @@ pub fn interval_coercion(
| (Interval(_), Timestamp(unit, zone)) => {
Some(Timestamp(unit.clone(), zone.clone()))
}
(Date32, Interval(_)) | (Interval(_), Date32) => {
// TODO: this is not correct and should be replaced with correctly typed timestamp
Some(Date32)
}
(Date64, Interval(_)) | (Interval(_), Date64) => {
// TODO: this is not correct and should be replaced with correctly typed timestamp
Some(Date64)
}
_ => None,
},
Operator::Multiply => match (lhs_type, rhs_type) {
(Int64, Interval(itype)) | (Interval(itype), Int64) => {
Some(Interval(itype.clone()))
}
(Int32, Interval(itype)) | (Interval(itype), Int32) => {
Some(Interval(itype.clone()))
}
(Int16, Interval(itype)) | (Interval(itype), Int16) => {
Some(Interval(itype.clone()))
}
(Int8, Interval(itype)) | (Interval(itype), Int8) => {
Some(Interval(itype.clone()))
}
(UInt64, Interval(itype)) | (Interval(itype), UInt64) => {
Some(Interval(itype.clone()))
}
(UInt32, Interval(itype)) | (Interval(itype), UInt32) => {
Some(Interval(itype.clone()))
}
(UInt16, Interval(itype)) | (Interval(itype), UInt16) => {
Some(Interval(itype.clone()))
}
(UInt8, Interval(itype)) | (Interval(itype), UInt8) => {
Some(Interval(itype.clone()))
}
_ => None,
},
_ => None,
Expand Down

0 comments on commit 00ed6a6

Please sign in to comment.