Apache DataFusion SQL Query Engine
Support binary temporal coercion for Date64 and Timestamp types
Asura796926a488d6ae0f
diff --git a/datafusion/expr/src/type_coercion/binary.rs b/datafusion/expr/src/type_coercion/binary.rsindex dd94491987..1b62c1bc05 100644--- a/datafusion/expr/src/type_coercion/binary.rs+++ b/datafusion/expr/src/type_coercion/binary.rs@@ -785,6 +785,12 @@ fn temporal_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataTypmatch (lhs_type, rhs_type) {(Interval(_), Interval(_)) => Some(Interval(MonthDayNano)),(Date64, Date32) | (Date32, Date64) => Some(Date64),+ (Timestamp(_, None), Date64) | (Date64, Timestamp(_, None)) => {+ Some(Timestamp(Nanosecond, None))+ }+ (Timestamp(_, _tz), Date64) | (Date64, Timestamp(_, _tz)) => {+ Some(Timestamp(Nanosecond, None))+ }(Timestamp(_, None), Date32) | (Date32, Timestamp(_, None)) => {Some(Timestamp(Nanosecond, None))}diff --git a/datafusion/sqllogictest/test_files/timestamps.slt b/datafusion/sqllogictest/test_files/timestamps.sltindex f956d59b1d..2b3b4bf2e4 100644--- a/datafusion/sqllogictest/test_files/timestamps.slt+++ b/datafusion/sqllogictest/test_files/timestamps.slt@@ -1888,3 +1888,12 @@ true true true true true true#SELECT to_timestamp(-62125747200), to_timestamp(1926632005177), -62125747200::timestamp, 1926632005177::timestamp, cast(-62125747200 as timestamp), cast(1926632005177 as timestamp)#----#0001-04-25T00:00:00 +63022-07-16T12:59:37 0001-04-25T00:00:00 +63022-07-16T12:59:37 0001-04-25T00:00:00 +63022-07-16T12:59:37++##########+## Test binary temporal coercion for Date and Timestamp+##########++query B+select arrow_cast(now(), 'Date64') < arrow_cast('2022-02-02 02:02:02', 'Timestamp(Nanosecond, None)');+----+false