@@ -1096,10 +1096,11 @@ fn parse_str_to_microsecond_timestamp<T: TimeZone>(
10961096 get_timestamp_values ( value, "microsecond" , tz)
10971097}
10981098
1099+ type TimestampPattern < T > = ( & ' static Regex , fn ( & str , & T ) -> SparkResult < Option < i64 > > ) ;
1100+
10991101static RE_YEAR : LazyLock < Regex > = LazyLock :: new ( || Regex :: new ( r"^\d{4,7}$" ) . unwrap ( ) ) ;
11001102static RE_MONTH : LazyLock < Regex > = LazyLock :: new ( || Regex :: new ( r"^\d{4,7}-\d{2}$" ) . unwrap ( ) ) ;
1101- static RE_DAY : LazyLock < Regex > =
1102- LazyLock :: new ( || Regex :: new ( r"^\d{4,7}-\d{2}-\d{2}$" ) . unwrap ( ) ) ;
1103+ static RE_DAY : LazyLock < Regex > = LazyLock :: new ( || Regex :: new ( r"^\d{4,7}-\d{2}-\d{2}$" ) . unwrap ( ) ) ;
11031104static RE_HOUR : LazyLock < Regex > =
11041105 LazyLock :: new ( || Regex :: new ( r"^\d{4,7}-\d{2}-\d{2}T\d{1,2}$" ) . unwrap ( ) ) ;
11051106static RE_MINUTE : LazyLock < Regex > =
@@ -1119,7 +1120,7 @@ fn timestamp_parser<T: TimeZone>(
11191120 if value. is_empty ( ) {
11201121 return Ok ( None ) ;
11211122 }
1122- let patterns: & [ ( & Regex , fn ( & str , & T ) -> SparkResult < Option < i64 > > ) ] = & [
1123+ let patterns: & [ TimestampPattern < T > ] = & [
11231124 ( & RE_YEAR , parse_str_to_year_timestamp) ,
11241125 ( & RE_MONTH , parse_str_to_month_timestamp) ,
11251126 ( & RE_DAY , parse_str_to_day_timestamp) ,
0 commit comments