Skip to content

Commit

Permalink
fix some todo
Browse files Browse the repository at this point in the history
  • Loading branch information
TCeason committed Dec 4, 2024
1 parent 2a35711 commit add4db2
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 41 deletions.
27 changes: 0 additions & 27 deletions src/common/io/src/cursor_ext/cursor_read_interval_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,33 +369,6 @@ enum DatePartSpecifier {
Hour,
}

impl TryFrom<&str> for DatePartSpecifier {
type Error = ErrorCode;

fn try_from(value: &str) -> Result<Self> {
match value.to_lowercase().as_str() {
"millennium" | "millennia" => Ok(DatePartSpecifier::Millennium),
"century" | "centuries" => Ok(DatePartSpecifier::Century),
"decade" | "decades" => Ok(DatePartSpecifier::Decade),
"year" | "years" | "y" => Ok(DatePartSpecifier::Year),
"quarter" | "quarters" | "q" => Ok(DatePartSpecifier::Quarter),
"month" | "months" | "mon" => Ok(DatePartSpecifier::Month),
"day" | "days" | "d" => Ok(DatePartSpecifier::Day),

"week" | "weeks" | "w" => Ok(DatePartSpecifier::Week),
"microsecond" | "microseconds" | "us" => Ok(DatePartSpecifier::Microseconds),
"millisecond" | "milliseconds" | "ms" => Ok(DatePartSpecifier::Milliseconds),
"second" | "seconds" | "s" => Ok(DatePartSpecifier::Second),
"minute" | "minutes" | "m" => Ok(DatePartSpecifier::Minute),
"hour" | "hours" | "h" => Ok(DatePartSpecifier::Hour),
_ => Err(ErrorCode::BadArguments(format!(
"Invalid date part specifier: {}",
value
))),
}
}
}

fn try_get_date_part_specifier(specifier_str: &str) -> Result<DatePartSpecifier> {
match specifier_str.to_lowercase().as_str() {
"millennium" | "millennia" => Ok(DatePartSpecifier::Millennium),
Expand Down
5 changes: 3 additions & 2 deletions src/common/native/src/write/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::io::Write;

use databend_common_column::buffer::Buffer;
use databend_common_column::types::i256;
use databend_common_column::types::months_days_ns;
use databend_common_expression::types::DecimalColumn;
use databend_common_expression::types::GeographyColumn;
use databend_common_expression::types::NumberColumn;
Expand Down Expand Up @@ -67,8 +68,8 @@ pub fn write<W: Write>(
Column::Date(column) => {
write_primitive::<i32, W>(w, &column, validity, write_options, scratch)
}
Column::Interval(_column) => {
todo!()
Column::Interval(column) => {
write_primitive::<months_days_ns, W>(w, &column, validity, write_options, scratch)
}
Column::Binary(b)
| Column::Bitmap(b)
Expand Down
3 changes: 0 additions & 3 deletions src/query/expression/src/converts/arrow/from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,6 @@ impl Column {
}
DataType::Interval => {
todo!()
// let array = arrow_cast::cast(array.as_ref(), &ArrowDataType::Interval(IntervalUnit::MonthDayNano))?;
// let buffer: Buffer<months_days_ns> = array.to_data().buffers()[0].clone().into();
// Column::Interval(buffer)
}
DataType::Nullable(_) => {
let validity = match array.nulls() {
Expand Down
4 changes: 1 addition & 3 deletions src/query/expression/src/converts/arrow/to.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,7 @@ impl From<&Column> for ArrayData {
Column::String(col) => col.clone().into(),
Column::Timestamp(col) => buffer_to_array_data((col.clone(), arrow_type)),
Column::Date(col) => buffer_to_array_data((col.clone(), arrow_type)),
Column::Interval(_) => {
todo!()
}
Column::Interval(col) => buffer_to_array_data((col.clone(), arrow_type)),
Column::Array(col) => {
let child_data = ArrayData::from(&col.values);
let builder = ArrayDataBuilder::new(arrow_type)
Expand Down
9 changes: 8 additions & 1 deletion src/query/expression/src/kernels/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use crate::types::BooleanType;
use crate::types::DataType;
use crate::types::DateType;
use crate::types::DecimalType;
use crate::types::IntervalType;
use crate::types::MapType;
use crate::types::NumberType;
use crate::types::TimestampType;
Expand Down Expand Up @@ -166,6 +167,13 @@ impl Column {
);
Column::Date(buffer)
}
Column::Interval(_) => {
let buffer = Self::concat_primitive_types(
columns.map(|col| IntervalType::try_downcast_column(&col).unwrap()),
capacity,
);
Column::Interval(buffer)
}
Column::Array(col) => {
let mut offsets = Vec::with_capacity(capacity + 1);
offsets.push(0);
Expand Down Expand Up @@ -215,7 +223,6 @@ impl Column {
.collect::<Result<_>>()?;
Column::Tuple(fields)
}
Column::Interval(_) => todo!(),
Column::Variant(_)
| Column::Geometry(_)
| Column::Geography(_)
Expand Down
9 changes: 7 additions & 2 deletions src/query/expression/src/kernels/take_chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,13 @@ impl Column {
.unwrap();
Column::Date(d)
}
ColumnVec::Interval(_columns) => {
todo!()
ColumnVec::Interval(columns) => {
let builder = Self::take_block_vec_primitive_types(columns, indices);
let i =
<IntervalType>::upcast_column(<IntervalType>::column_from_vec(builder, &[]))
.into_interval()
.unwrap();
Column::Interval(i)
}
ColumnVec::Array(columns) => {
let data_type = data_type.as_array().unwrap();
Expand Down
8 changes: 6 additions & 2 deletions src/query/expression/src/utils/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use databend_common_column::bitmap::Bitmap;
use databend_common_column::buffer::Buffer;
use databend_common_column::types::months_days_ns;
use databend_common_exception::Result;
use decimal::DecimalType;
use geometry::GeometryType;
Expand Down Expand Up @@ -79,6 +80,10 @@ pub trait ValueVisitor {
self.visit_typed_column::<DateType>(buffer)
}

fn visit_interval(&mut self, buffer: Buffer<months_days_ns>) -> Result<()> {
self.visit_typed_column::<IntervalType>(buffer)
}

fn visit_array(&mut self, column: Box<ArrayColumn<AnyType>>) -> Result<()> {
self.visit_typed_column::<AnyType>(Column::Array(column))
}
Expand Down Expand Up @@ -132,8 +137,7 @@ pub trait ValueVisitor {
Column::String(column) => self.visit_string(column),
Column::Timestamp(buffer) => self.visit_timestamp(buffer),
Column::Date(buffer) => self.visit_date(buffer),
// TODO: impl visitor
Column::Interval(_) => unimplemented!(),
Column::Interval(buffer) => self.visit_interval(buffer),
Column::Array(column) => self.visit_array(column),
Column::Map(column) => self.visit_map(column),
Column::Tuple(columns) => self.visit_tuple(columns),
Expand Down
1 change: 0 additions & 1 deletion src/query/formats/src/field_decoder/fast_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ impl FastFieldDecoderValues {
ColumnBuilder::Geometry(c) => self.read_geometry(c, reader, positions),
ColumnBuilder::Geography(c) => self.read_geography(c, reader, positions),
ColumnBuilder::Binary(_) => Err(ErrorCode::Unimplemented("binary literal")),
// TODO
ColumnBuilder::Interval(c) => self.read_interval(c, reader, positions),
ColumnBuilder::EmptyArray { .. } | ColumnBuilder::EmptyMap { .. } => {
Err(ErrorCode::Unimplemented("empty array/map literal"))
Expand Down

0 comments on commit add4db2

Please sign in to comment.