diff --git a/src/datatypes/src/types/cast.rs b/src/datatypes/src/types/cast.rs index 1af07fae4184..f4c32a94b440 100644 --- a/src/datatypes/src/types/cast.rs +++ b/src/datatypes/src/types/cast.rs @@ -115,8 +115,8 @@ pub fn can_cast_type(src_value: &Value, dest_type: &ConcreteDataType) -> bool { (Time(Microsecond(_)), Int64(_)) => true, (Time(Nanosecond(_)), Int64(_)) => true, // TODO(QuenKar): interval type cast - // (Interval(_), String(_)) => true, - + (Interval(_), String(_)) => true, + (Duration(_), String(_)) => true, // other situations return false (_, _) => false, } diff --git a/src/datatypes/src/types/duration_type.rs b/src/datatypes/src/types/duration_type.rs index 8e4516ef41e0..94c80a7962b3 100644 --- a/src/datatypes/src/types/duration_type.rs +++ b/src/datatypes/src/types/duration_type.rs @@ -101,6 +101,11 @@ macro_rules! impl_data_type_for_duration { fn is_timestamp_compatible(&self) -> bool { false } + + fn try_cast(&self, _: Value) -> Option { + // TODO(QuenKar): Implement casting for duration types. + None + } } impl LogicalPrimitiveType for [] { diff --git a/src/datatypes/src/types/string_type.rs b/src/datatypes/src/types/string_type.rs index 47dbc61da92d..85a970f116d6 100644 --- a/src/datatypes/src/types/string_type.rs +++ b/src/datatypes/src/types/string_type.rs @@ -83,6 +83,7 @@ impl DataType for StringType { Value::Timestamp(v) => Some(Value::String(StringBytes::from(v.to_iso8601_string()))), Value::Time(v) => Some(Value::String(StringBytes::from(v.to_iso8601_string()))), Value::Interval(v) => Some(Value::String(StringBytes::from(v.to_iso8601_string()))), + Value::Duration(v) => Some(Value::String(StringBytes::from(v.to_string()))), // StringBytes is only support for utf-8, Value::Binary is not allowed. Value::Binary(_) | Value::List(_) => None,