Skip to content

Commit

Permalink
chore: duration type
Browse files Browse the repository at this point in the history
  • Loading branch information
QuenKar committed Sep 18, 2023
1 parent 874a15e commit 357c0fc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/datatypes/src/types/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
5 changes: 5 additions & 0 deletions src/datatypes/src/types/duration_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ macro_rules! impl_data_type_for_duration {
fn is_timestamp_compatible(&self) -> bool {
false
}

fn try_cast(&self, _: Value) -> Option<Value> {
// TODO(QuenKar): Implement casting for duration types.
None
}
}

impl LogicalPrimitiveType for [<Duration $unit Type>] {
Expand Down
1 change: 1 addition & 0 deletions src/datatypes/src/types/string_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 357c0fc

Please sign in to comment.