11use std:: { error:: Error , str:: FromStr , sync:: Arc } ;
22
3+ use arrow:: {
4+ datatypes:: {
5+ Date32Type , Date64Type , Time32MillisecondType , Time32SecondType , Time64MicrosecondType ,
6+ Time64NanosecondType ,
7+ } ,
8+ temporal_conversions:: { as_date, as_time} ,
9+ } ;
310use bytes:: { BufMut , BytesMut } ;
411use chrono:: { DateTime , TimeZone , Utc } ;
512use datafusion:: arrow:: {
@@ -152,6 +159,7 @@ pub(crate) fn encode_list(
152159 . downcast_ref :: < Date32Array > ( )
153160 . unwrap ( )
154161 . iter ( )
162+ . map ( |val| val. and_then ( |x| as_date :: < Date32Type > ( x as i64 ) ) )
155163 . collect ( ) ;
156164 encode_field ( & value, type_, format)
157165 }
@@ -161,6 +169,7 @@ pub(crate) fn encode_list(
161169 . downcast_ref :: < Date64Array > ( )
162170 . unwrap ( )
163171 . iter ( )
172+ . map ( |val| val. and_then ( as_date :: < Date64Type > ) )
164173 . collect ( ) ;
165174 encode_field ( & value, type_, format)
166175 }
@@ -171,6 +180,7 @@ pub(crate) fn encode_list(
171180 . downcast_ref :: < Time32SecondArray > ( )
172181 . unwrap ( )
173182 . iter ( )
183+ . map ( |val| val. and_then ( |x| as_time :: < Time32SecondType > ( x as i64 ) ) )
174184 . collect ( ) ;
175185 encode_field ( & value, type_, format)
176186 }
@@ -180,6 +190,7 @@ pub(crate) fn encode_list(
180190 . downcast_ref :: < Time32MillisecondArray > ( )
181191 . unwrap ( )
182192 . iter ( )
193+ . map ( |val| val. and_then ( |x| as_time :: < Time32MillisecondType > ( x as i64 ) ) )
183194 . collect ( ) ;
184195 encode_field ( & value, type_, format)
185196 }
@@ -194,6 +205,7 @@ pub(crate) fn encode_list(
194205 . downcast_ref :: < Time64MicrosecondArray > ( )
195206 . unwrap ( )
196207 . iter ( )
208+ . map ( |val| val. and_then ( as_time :: < Time64MicrosecondType > ) )
197209 . collect ( ) ;
198210 encode_field ( & value, type_, format)
199211 }
@@ -203,6 +215,7 @@ pub(crate) fn encode_list(
203215 . downcast_ref :: < Time64NanosecondArray > ( )
204216 . unwrap ( )
205217 . iter ( )
218+ . map ( |val| val. and_then ( as_time :: < Time64NanosecondType > ) )
206219 . collect ( ) ;
207220 encode_field ( & value, type_, format)
208221 }
0 commit comments