You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2022/12/07 19:03:26 UTC
[arrow-datafusion] branch master updated: Support type coercion for timestamp and utf8 (#4312)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/master by this push:
new 8547fd8a5 Support type coercion for timestamp and utf8 (#4312)
8547fd8a5 is described below
commit 8547fd8a562ed9071d765a6b8ddcaec0e9461503
Author: André Calado Coroado <11...@users.noreply.github.com>
AuthorDate: Wed Dec 7 20:03:20 2022 +0100
Support type coercion for timestamp and utf8 (#4312)
* Support Time32 and Time64 for Type Coercion
* Revert "Support Time32 and Time64 for Type Coercion"
This reverts commit a46b97ea8bfb4370964d661d20603acee42e4f8a.
* Implement Time32 and Time64 in hash_join and hash_util
* Add review comments
* Qualify TimeUnits
* Changes in proto to provide full support for Time32 and Time64
* Add test to ensure Time32 and Time64 are fully supported
* Add support for type coercion for pair (Timestamp, Utf8) and add corresponding test cases
* Implement Time32 and Time64 in hash_join and hash_util
* Add review comments
* Changes in proto to provide full support for Time32 and Time64
* Add test to ensure Time32 and Time64 are fully supported
* Add support for type coercion for pair (Timestamp, Utf8) and add corresponding test cases
* Revert to_proto.rs
* Revert to_proto.rs
* Revert timestamp.rs
* Revert mod.rs
* Revert select.rs
* Revert group_by.rs
* Revert aggregates.rs
* Delete generated file
---
datafusion/expr/src/type_coercion/binary.rs | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/datafusion/expr/src/type_coercion/binary.rs b/datafusion/expr/src/type_coercion/binary.rs
index 6ca0c4e04..18ea51d0d 100644
--- a/datafusion/expr/src/type_coercion/binary.rs
+++ b/datafusion/expr/src/type_coercion/binary.rs
@@ -561,6 +561,8 @@ fn temporal_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataTyp
false => None,
true => Some(Time64(unit.clone())),
},
+ (Timestamp(_, tz), Utf8) => Some(Timestamp(TimeUnit::Nanosecond, tz.clone())),
+ (Utf8, Timestamp(_, tz)) => Some(Timestamp(TimeUnit::Nanosecond, tz.clone())),
(Timestamp(lhs_unit, lhs_tz), Timestamp(rhs_unit, rhs_tz)) => {
let tz = match (lhs_tz, rhs_tz) {
// can't cast across timezones
@@ -886,6 +888,30 @@ mod tests {
Operator::Eq,
DataType::Time64(TimeUnit::Nanosecond)
);
+ test_coercion_binary_rule!(
+ DataType::Utf8,
+ DataType::Timestamp(TimeUnit::Second, None),
+ Operator::Lt,
+ DataType::Timestamp(TimeUnit::Nanosecond, None)
+ );
+ test_coercion_binary_rule!(
+ DataType::Utf8,
+ DataType::Timestamp(TimeUnit::Millisecond, None),
+ Operator::Lt,
+ DataType::Timestamp(TimeUnit::Nanosecond, None)
+ );
+ test_coercion_binary_rule!(
+ DataType::Utf8,
+ DataType::Timestamp(TimeUnit::Microsecond, None),
+ Operator::Lt,
+ DataType::Timestamp(TimeUnit::Nanosecond, None)
+ );
+ test_coercion_binary_rule!(
+ DataType::Utf8,
+ DataType::Timestamp(TimeUnit::Nanosecond, None),
+ Operator::Lt,
+ DataType::Timestamp(TimeUnit::Nanosecond, None)
+ );
test_coercion_binary_rule!(
DataType::Utf8,
DataType::Utf8,