You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by co...@apache.org on 2023/12/22 18:18:59 UTC
(arrow-datafusion) branch main updated: Support binary temporal coercion for Date64 and Timestamp types
This is an automated email from the ASF dual-hosted git repository.
comphead pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 26a488d6ae Support binary temporal coercion for Date64 and Timestamp types
26a488d6ae is described below
commit 26a488d6ae0f45b33d2566b8b97d4f82a2e80fa3
Author: Asura7969 <14...@qq.com>
AuthorDate: Sat Dec 23 02:18:53 2023 +0800
Support binary temporal coercion for Date64 and Timestamp types
---
datafusion/expr/src/type_coercion/binary.rs | 6 ++++++
datafusion/sqllogictest/test_files/timestamps.slt | 9 +++++++++
2 files changed, 15 insertions(+)
diff --git a/datafusion/expr/src/type_coercion/binary.rs b/datafusion/expr/src/type_coercion/binary.rs
index 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<DataTyp
match (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.slt
index 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