Skip to content

Commit 8547fd8

Browse files
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 a46b97e. * 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
1 parent fbadebb commit 8547fd8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

datafusion/expr/src/type_coercion/binary.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,8 @@ fn temporal_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataTyp
561561
false => None,
562562
true => Some(Time64(unit.clone())),
563563
},
564+
(Timestamp(_, tz), Utf8) => Some(Timestamp(TimeUnit::Nanosecond, tz.clone())),
565+
(Utf8, Timestamp(_, tz)) => Some(Timestamp(TimeUnit::Nanosecond, tz.clone())),
564566
(Timestamp(lhs_unit, lhs_tz), Timestamp(rhs_unit, rhs_tz)) => {
565567
let tz = match (lhs_tz, rhs_tz) {
566568
// can't cast across timezones
@@ -886,6 +888,30 @@ mod tests {
886888
Operator::Eq,
887889
DataType::Time64(TimeUnit::Nanosecond)
888890
);
891+
test_coercion_binary_rule!(
892+
DataType::Utf8,
893+
DataType::Timestamp(TimeUnit::Second, None),
894+
Operator::Lt,
895+
DataType::Timestamp(TimeUnit::Nanosecond, None)
896+
);
897+
test_coercion_binary_rule!(
898+
DataType::Utf8,
899+
DataType::Timestamp(TimeUnit::Millisecond, None),
900+
Operator::Lt,
901+
DataType::Timestamp(TimeUnit::Nanosecond, None)
902+
);
903+
test_coercion_binary_rule!(
904+
DataType::Utf8,
905+
DataType::Timestamp(TimeUnit::Microsecond, None),
906+
Operator::Lt,
907+
DataType::Timestamp(TimeUnit::Nanosecond, None)
908+
);
909+
test_coercion_binary_rule!(
910+
DataType::Utf8,
911+
DataType::Timestamp(TimeUnit::Nanosecond, None),
912+
Operator::Lt,
913+
DataType::Timestamp(TimeUnit::Nanosecond, None)
914+
);
889915
test_coercion_binary_rule!(
890916
DataType::Utf8,
891917
DataType::Utf8,

0 commit comments

Comments
 (0)