|
20 | 20 | use std::{convert::TryFrom, fmt, iter::repeat, sync::Arc}; |
21 | 21 |
|
22 | 22 | use arrow::array::{ |
23 | | - Int16Builder, Int32Builder, Int64Builder, Int8Builder, ListBuilder, |
| 23 | + Date64Array, Int16Builder, Int32Builder, Int64Builder, Int8Builder, ListBuilder, |
24 | 24 | TimestampMicrosecondArray, TimestampNanosecondArray, UInt16Builder, UInt32Builder, |
25 | 25 | UInt64Builder, UInt8Builder, |
26 | 26 | }; |
@@ -75,6 +75,8 @@ pub enum ScalarValue { |
75 | 75 | List(Option<Vec<ScalarValue>>, DataType), |
76 | 76 | /// Date stored as a signed 32bit int |
77 | 77 | Date32(Option<i32>), |
| 78 | + /// Date stored as a signed 64bit int |
| 79 | + Date64(Option<i64>), |
78 | 80 | /// Timestamp Microseconds |
79 | 81 | TimeMicrosecond(Option<i64>), |
80 | 82 | /// Timestamp Nanoseconds |
@@ -156,6 +158,7 @@ impl ScalarValue { |
156 | 158 | DataType::List(Box::new(Field::new("item", data_type.clone(), true))) |
157 | 159 | } |
158 | 160 | ScalarValue::Date32(_) => DataType::Date32, |
| 161 | + ScalarValue::Date64(_) => DataType::Date64, |
159 | 162 | ScalarValue::IntervalYearMonth(_) => { |
160 | 163 | DataType::Interval(IntervalUnit::YearMonth) |
161 | 164 | } |
@@ -329,6 +332,12 @@ impl ScalarValue { |
329 | 332 | } |
330 | 333 | None => Arc::new(repeat(None).take(size).collect::<Date32Array>()), |
331 | 334 | }, |
| 335 | + ScalarValue::Date64(e) => match e { |
| 336 | + Some(value) => { |
| 337 | + Arc::new(Date64Array::from_iter_values(repeat(*value).take(size))) |
| 338 | + } |
| 339 | + None => Arc::new(repeat(None).take(size).collect::<Date64Array>()), |
| 340 | + }, |
332 | 341 | ScalarValue::IntervalDayTime(e) => match e { |
333 | 342 | Some(value) => Arc::new(IntervalDayTimeArray::from_iter_values( |
334 | 343 | repeat(*value).take(size), |
@@ -386,6 +395,9 @@ impl ScalarValue { |
386 | 395 | DataType::Date32 => { |
387 | 396 | typed_cast!(array, index, Date32Array, Date32) |
388 | 397 | } |
| 398 | + DataType::Date64 => { |
| 399 | + typed_cast!(array, index, Date64Array, Date64) |
| 400 | + } |
389 | 401 | other => { |
390 | 402 | return Err(DataFusionError::NotImplemented(format!( |
391 | 403 | "Can't create a scalar of array of type \"{:?}\"", |
@@ -580,6 +592,7 @@ impl fmt::Display for ScalarValue { |
580 | 592 | None => write!(f, "NULL")?, |
581 | 593 | }, |
582 | 594 | ScalarValue::Date32(e) => format_option!(f, e)?, |
| 595 | + ScalarValue::Date64(e) => format_option!(f, e)?, |
583 | 596 | ScalarValue::IntervalDayTime(e) => format_option!(f, e)?, |
584 | 597 | ScalarValue::IntervalYearMonth(e) => format_option!(f, e)?, |
585 | 598 | }; |
@@ -609,6 +622,7 @@ impl fmt::Debug for ScalarValue { |
609 | 622 | ScalarValue::LargeUtf8(Some(_)) => write!(f, "LargeUtf8(\"{}\")", self), |
610 | 623 | ScalarValue::List(_, _) => write!(f, "List([{}])", self), |
611 | 624 | ScalarValue::Date32(_) => write!(f, "Date32(\"{}\")", self), |
| 625 | + ScalarValue::Date64(_) => write!(f, "Date64(\"{}\")", self), |
612 | 626 | ScalarValue::IntervalDayTime(_) => { |
613 | 627 | write!(f, "IntervalDayTime(\"{}\")", self) |
614 | 628 | } |
|
0 commit comments