Skip to content

Commit

Permalink
Enable IsDistinctFrom and IsNotDistinctFrom on interval types
Browse files Browse the repository at this point in the history
  • Loading branch information
joroKr21 committed Jun 27, 2023
1 parent 06240ab commit 4d8ccc6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
15 changes: 15 additions & 0 deletions datafusion/core/tests/sqllogictests/test_files/interval.slt
Original file line number Diff line number Diff line change
Expand Up @@ -489,5 +489,20 @@ select interval '1 month' + '2012-01-01'::date;
----
2012-02-01

# is (not) distinct from
query BBBBBB
select
i is distinct from null,
i is distinct from (interval '1 month'),
i is distinct from i,
i is not distinct from null,
i is not distinct from (interval '1 day'),
i is not distinct from i
from t;
----
true false false false false true
true true false false true true
true true false false false true

statement ok
drop table t
9 changes: 9 additions & 0 deletions datafusion/physical-expr/src/expressions/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,15 @@ macro_rules! binary_array_op {
DataType::Time64(TimeUnit::Nanosecond) => {
compute_op!($LEFT, $RIGHT, $OP, Time64NanosecondArray)
}
DataType::Interval(IntervalUnit::YearMonth) => {
compute_op!($LEFT, $RIGHT, $OP, IntervalYearMonthArray)
}
DataType::Interval(IntervalUnit::DayTime) => {
compute_op!($LEFT, $RIGHT, $OP, IntervalDayTimeArray)
}
DataType::Interval(IntervalUnit::MonthDayNano) => {
compute_op!($LEFT, $RIGHT, $OP, IntervalMonthDayNanoArray)
}
DataType::Boolean => compute_bool_op!($LEFT, $RIGHT, $OP, BooleanArray),
other => Err(DataFusionError::Internal(format!(
"Data type {:?} not supported for binary operation '{}' on dyn arrays",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub(crate) fn is_distinct_from<T>(
right: &PrimitiveArray<T>,
) -> Result<BooleanArray>
where
T: ArrowNumericType,
T: ArrowPrimitiveType,
{
distinct(
left,
Expand Down Expand Up @@ -140,7 +140,7 @@ fn distinct<
mut op: F,
) -> Result<BooleanArray>
where
T: ArrowNumericType,
T: ArrowPrimitiveType,
{
let left_values = left.values();
let right_values = right.values();
Expand Down

0 comments on commit 4d8ccc6

Please sign in to comment.