Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: impl interval type #1952

Merged
merged 14 commits into from
Jul 31, 2023
5 changes: 3 additions & 2 deletions src/api/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ impl TryFrom<ConcreteDataType> for ColumnDataTypeWrapper {
TimeType::Microsecond(_) => ColumnDataType::TimeMicrosecond,
TimeType::Nanosecond(_) => ColumnDataType::TimeNanosecond,
},
ConcreteDataType::Null(_)
ConcreteDataType::Interval(_)
| ConcreteDataType::Null(_)
| ConcreteDataType::List(_)
| ConcreteDataType::Dictionary(_) => {
return error::IntoColumnDataTypeSnafu { from: datatype }.fail()
Expand Down Expand Up @@ -255,7 +256,7 @@ pub fn push_vals(column: &mut Column, origin_count: usize, vector: VectorRef) {
TimeUnit::Microsecond => values.time_microsecond_values.push(val.value()),
TimeUnit::Nanosecond => values.time_nanosecond_values.push(val.value()),
},
Value::List(_) => unreachable!(),
Value::Interval(_) | Value::List(_) => unreachable!(),
});
column.null_mask = null_mask.into_vec();
}
Expand Down
10 changes: 8 additions & 2 deletions src/common/grpc-expr/src/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,10 @@ fn values_to_vector(data_type: &ConcreteDataType, values: Values) -> VectorRef {
)),
},

ConcreteDataType::Null(_) | ConcreteDataType::List(_) | ConcreteDataType::Dictionary(_) => {
ConcreteDataType::Interval(_)
| ConcreteDataType::Null(_)
| ConcreteDataType::List(_)
| ConcreteDataType::Dictionary(_) => {
unreachable!()
}
}
Expand Down Expand Up @@ -553,7 +556,10 @@ fn convert_values(data_type: &ConcreteDataType, values: Values) -> Vec<Value> {
.map(|v| Value::Time(Time::new_nanosecond(v)))
.collect(),

ConcreteDataType::Null(_) | ConcreteDataType::List(_) | ConcreteDataType::Dictionary(_) => {
ConcreteDataType::Interval(_)
| ConcreteDataType::Null(_)
| ConcreteDataType::List(_)
| ConcreteDataType::Dictionary(_) => {
unreachable!()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/grpc/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ macro_rules! convert_arrow_array_to_grpc_vals {
return Ok(vals);
},
)+
ConcreteDataType::Null(_) | ConcreteDataType::List(_) | ConcreteDataType::Dictionary(_) => unreachable!("Should not send {:?} in gRPC", $data_type),
ConcreteDataType::Null(_) | ConcreteDataType::List(_) | ConcreteDataType::Dictionary(_)| ConcreteDataType::Interval(_) => unreachable!("Should not send {:?} in gRPC", $data_type),
}
}};
}
Expand Down
5 changes: 5 additions & 0 deletions src/common/time/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ pub enum Error {
#[snafu(display("Failed to parse a string into Timestamp, raw string: {}", raw))]
ParseTimestamp { raw: String, location: Location },

#[snafu(display("Failed to parse a string into Interval, raw string: {}", raw))]
ParseInterval { raw: String, location: Location },

#[snafu(display("Current timestamp overflow, source: {}", source))]
TimestampOverflow {
source: TryFromIntError,
Expand Down Expand Up @@ -71,6 +74,7 @@ impl ErrorExt for Error {
Error::InvalidDateStr { .. } | Error::ArithmeticOverflow { .. } => {
StatusCode::InvalidArguments
}
Error::ParseInterval { .. } => StatusCode::InvalidArguments,
}
}

Expand All @@ -88,6 +92,7 @@ impl ErrorExt for Error {
| Error::ParseOffsetStr { .. }
| Error::ParseTimeZoneName { .. } => None,
Error::InvalidDateStr { location, .. } => Some(*location),
Error::ParseInterval { location, .. } => Some(*location),
}
}
}
Expand Down
Loading