@@ -2,10 +2,10 @@ use crate::error::{Error, Result};
22use arrow:: {
33 array:: {
44 new_null_array, Array , ArrayRef , ArrowPrimitiveType , BooleanArray , Decimal128Array , Decimal256Array ,
5- Float32Array , Float64Array , Int16Array , Int32Array , Int64Array , Int8Array , LargeStringArray , PrimitiveArray ,
6- StringArray , UInt16Array , UInt32Array , UInt64Array , UInt8Array ,
5+ Float32Array , Float64Array , Int16Array , Int32Array , Int64Array , Int8Array , IntervalMonthDayNanoArray ,
6+ LargeStringArray , PrimitiveArray , StringArray , UInt16Array , UInt32Array , UInt64Array , UInt8Array ,
77 } ,
8- datatypes:: { i256, DataType , Field } ,
8+ datatypes:: { i256, DataType , Field , IntervalMonthDayNano , IntervalUnit } ,
99} ;
1010use std:: any:: type_name;
1111use std:: { fmt:: Display , sync:: Arc } ;
@@ -99,6 +99,10 @@ pub enum ScalarValue {
9999 Decimal128 ( Option < i128 > , u8 , i8 ) ,
100100 /// 256bit decimal, using the i256 to represent the decimal, precision scale
101101 Decimal256 ( Option < i256 > , u8 , i8 ) ,
102+ /// A triple of the number of elapsed months, days, and nanoseconds.
103+ /// Months and days are encoded as 32-bit signed integers.
104+ /// Nanoseconds is encoded as a 64-bit signed integer (no leap seconds).
105+ IntervalMonthDayNano ( Option < IntervalMonthDayNano > ) ,
102106 Utf8 ( Option < String > ) ,
103107}
104108
@@ -130,6 +134,11 @@ impl ScalarValue {
130134 ScalarValue :: Utf8 ( _) => Field :: new ( "utf8" , DataType :: Utf8 , true ) ,
131135 ScalarValue :: Decimal128 ( _, p, s) => Field :: new ( "decimal128" , DataType :: Decimal128 ( * p, * s) , true ) ,
132136 ScalarValue :: Decimal256 ( _, p, s) => Field :: new ( "decimal256" , DataType :: Decimal256 ( * p, * s) , true ) ,
137+ ScalarValue :: IntervalMonthDayNano ( _) => Field :: new (
138+ "interval_month_day_nano" ,
139+ DataType :: Interval ( IntervalUnit :: MonthDayNano ) ,
140+ true ,
141+ ) ,
133142 }
134143 }
135144
@@ -150,6 +159,7 @@ impl ScalarValue {
150159 ScalarValue :: Utf8 ( _) => DataType :: Utf8 ,
151160 ScalarValue :: Decimal128 ( _, p, s) => DataType :: Decimal128 ( * p, * s) ,
152161 ScalarValue :: Decimal256 ( _, p, s) => DataType :: Decimal256 ( * p, * s) ,
162+ ScalarValue :: IntervalMonthDayNano ( _) => DataType :: Interval ( IntervalUnit :: MonthDayNano ) ,
153163 }
154164 }
155165
@@ -174,6 +184,9 @@ impl ScalarValue {
174184 ScalarValue :: Decimal256 ( v, p, s) => {
175185 Arc :: new ( build_decimal_array ! ( * v, Decimal256Array , num_row, * p, * s) ) as ArrayRef
176186 }
187+ ScalarValue :: IntervalMonthDayNano ( v) => {
188+ Arc :: new ( IntervalMonthDayNanoArray :: from ( vec ! [ * v; num_row] ) ) as ArrayRef
189+ }
177190 } )
178191 }
179192
@@ -275,6 +288,9 @@ impl Display for ScalarValue {
275288 ScalarValue :: Decimal128 ( v, p, s) => format_decimal ! ( f, v, "Decimal128" , p, s) ,
276289 ScalarValue :: Decimal256 ( v, p, s) => format_decimal ! ( f, v, "Decimal256" , p, s) ,
277290 ScalarValue :: Utf8 ( v) => format_string ! ( f, v, "Utf8" ) ,
291+ ScalarValue :: IntervalMonthDayNano ( v) => {
292+ format_string ! ( f, v. map( |v| format!( "{:?}" , v) ) , "IntervalMonthDayNano" )
293+ }
278294 }
279295 }
280296}
0 commit comments