@@ -28,6 +28,7 @@ use std::{
2828 task:: { Context , Poll } ,
2929} ;
3030
31+ use crate :: compile:: date_parser:: parse_date_str;
3132use crate :: {
3233 compile:: {
3334 engine:: df:: wrapper:: { CubeScanWrappedSqlNode , CubeScanWrapperNode , SqlQuery } ,
@@ -38,7 +39,7 @@ use crate::{
3839 transport:: { CubeStreamReceiver , LoadRequestMeta , SpanId , TransportService } ,
3940 CubeError ,
4041} ;
41- use chrono:: { Datelike , NaiveDate , NaiveDateTime } ;
42+ use chrono:: { Datelike , NaiveDate } ;
4243use datafusion:: {
4344 arrow:: {
4445 array:: {
@@ -917,15 +918,7 @@ pub fn transform_response<V: ValueObject>(
917918 field_name,
918919 {
919920 ( FieldValue :: String ( s) , builder) => {
920- let timestamp = NaiveDateTime :: parse_from_str( s. as_ref( ) , "%Y-%m-%dT%H:%M:%S%.f" )
921- . or_else( |_| NaiveDateTime :: parse_from_str( s. as_ref( ) , "%Y-%m-%d %H:%M:%S%.f" ) )
922- . or_else( |_| NaiveDateTime :: parse_from_str( s. as_ref( ) , "%Y-%m-%dT%H:%M:%S" ) )
923- . or_else( |_| NaiveDateTime :: parse_from_str( s. as_ref( ) , "%Y-%m-%dT%H:%M:%S%.fZ" ) )
924- . or_else( |_| {
925- NaiveDate :: parse_from_str( s. as_ref( ) , "%Y-%m-%d" ) . map( |date| {
926- date. and_hms_opt( 0 , 0 , 0 ) . unwrap( )
927- } )
928- } )
921+ let timestamp = parse_date_str( s. as_ref( ) )
929922 . map_err( |e| {
930923 DataFusionError :: Execution ( format!(
931924 "Can't parse timestamp: '{}': {}" ,
@@ -959,15 +952,7 @@ pub fn transform_response<V: ValueObject>(
959952 field_name,
960953 {
961954 ( FieldValue :: String ( s) , builder) => {
962- let timestamp = NaiveDateTime :: parse_from_str( s. as_ref( ) , "%Y-%m-%dT%H:%M:%S%.f" )
963- . or_else( |_| NaiveDateTime :: parse_from_str( s. as_ref( ) , "%Y-%m-%d %H:%M:%S%.f" ) )
964- . or_else( |_| NaiveDateTime :: parse_from_str( s. as_ref( ) , "%Y-%m-%dT%H:%M:%S" ) )
965- . or_else( |_| NaiveDateTime :: parse_from_str( s. as_ref( ) , "%Y-%m-%dT%H:%M:%S%.fZ" ) )
966- . or_else( |_| {
967- NaiveDate :: parse_from_str( s. as_ref( ) , "%Y-%m-%d" ) . map( |date| {
968- date. and_hms_opt( 0 , 0 , 0 ) . unwrap( )
969- } )
970- } )
955+ let timestamp = parse_date_str( s. as_ref( ) )
971956 . map_err( |e| {
972957 DataFusionError :: Execution ( format!(
973958 "Can't parse timestamp: '{}': {}" ,
0 commit comments