@@ -3,19 +3,16 @@ use std::borrow::Cow;
33use std:: collections:: HashMap ;
44use std:: sync:: Arc ;
55
6- use chrono:: Utc ;
76use itertools:: Itertools ;
87use tracing:: warn;
98
10- use super :: timestamp_timezone:: TimestampTimezone ;
119use crate :: arrow:: array:: types:: * ;
1210use crate :: arrow:: array:: {
1311 self as arrow_array, make_array, new_null_array, Array , ArrayBuilder , ArrayData , ArrayRef ,
1412 AsArray , BooleanArray , Datum , ListArray , MapArray , MutableArrayData , NullBufferBuilder ,
1513 RecordBatch , StringArray , StructArray ,
1614} ;
1715use crate :: arrow:: buffer:: { NullBuffer , OffsetBuffer } ;
18- use crate :: arrow:: compute:: kernels:: cast_utils:: { string_to_datetime, Parser } ;
1916use crate :: arrow:: compute:: kernels:: cmp:: { distinct, eq, gt, gt_eq, lt, lt_eq, neq, not_distinct} ;
2017use crate :: arrow:: compute:: kernels:: comparison:: in_list_utf8;
2118use crate :: arrow:: compute:: kernels:: numeric:: { add, div, mul, sub} ;
@@ -44,6 +41,7 @@ use crate::expressions::{
4441 UnaryPredicateOp , VariadicExpression , VariadicExpressionOp ,
4542} ;
4643use crate :: schema:: { DataType , PrimitiveType , StructField , StructType } ;
44+ use crate :: timestamp_timezone:: { parse_partition_scalar, TimestampTimezone } ;
4745
4846#[ internal_api]
4947pub ( crate ) trait ProvidesColumnByName {
@@ -934,44 +932,6 @@ fn coalesce_arrays(
934932 Ok ( make_array ( mutable. freeze ( ) ) )
935933}
936934
937- /// Parses one raw partition-value string into its target [`Scalar`], or `None` for a null value.
938- ///
939- /// An empty string casts via [`PrimitiveType::empty_string_partition_cast`].
940- /// `timestamp_timezone` applies only to `TIMESTAMP` values without an embedded offset or named
941- /// timezone; it does not affect `DATE` or `TIMESTAMP_NTZ`.
942- fn parse_partition_scalar (
943- prim : & PrimitiveType ,
944- raw : & str ,
945- timestamp_timezone : TimestampTimezone ,
946- ) -> DeltaResult < Option < Scalar > > {
947- if raw. is_empty ( ) {
948- return Ok ( prim. empty_string_partition_cast ( ) ) ;
949- }
950- match prim {
951- PrimitiveType :: Date => {
952- let days = Date32Type :: parse ( raw) . ok_or_else ( || {
953- Error :: ParseError ( raw. to_string ( ) , DataType :: Primitive ( prim. clone ( ) ) )
954- } ) ?;
955- return Ok ( Some ( Scalar :: Date ( days) ) ) ;
956- }
957- PrimitiveType :: Timestamp => {
958- let micros = timestamp_timezone. parse_timestamp ( raw) . ok_or_else ( || {
959- Error :: ParseError ( raw. to_string ( ) , DataType :: Primitive ( prim. clone ( ) ) )
960- } ) ?;
961- return Ok ( Some ( Scalar :: Timestamp ( micros) ) ) ;
962- }
963- PrimitiveType :: TimestampNtz => {
964- let micros = string_to_datetime ( & Utc , raw)
965- . map_err ( |_| Error :: ParseError ( raw. to_string ( ) , DataType :: Primitive ( prim. clone ( ) ) ) ) ?
966- . timestamp_micros ( ) ;
967- return Ok ( Some ( Scalar :: TimestampNtz ( micros) ) ) ;
968- }
969- _ => { }
970- }
971- let scalar = prim. parse_scalar ( raw) ?;
972- Ok ( ( !matches ! ( scalar, Scalar :: Null ( _) ) ) . then_some ( scalar) )
973- }
974-
975935/// Evaluates `MAP_TO_STRUCT(map_col, output_schema)`: extracts keys from a `Map<String, String>`
976936/// and parses each value into its target type, producing a `StructArray`. An empty-string value
977937/// casts via [`PrimitiveType::empty_string_partition_cast`].
0 commit comments