@@ -228,7 +228,9 @@ Status DataTypeDateSerDe<T>::_read_column_from_arrow(IColumn& column,
228228 for (auto value_i = start; value_i < end; ++value_i) {
229229 auto val_str = concrete_array->GetString (value_i);
230230 VecDateTimeValue v;
231- v.from_date_str (val_str.c_str (), val_str.length (), ctz);
231+ CastParameters params;
232+ CastToDateOrDatetime::from_string_non_strict_mode<DatelikeTargetType::DATE_TIME >(
233+ {val_str.c_str (), val_str.length ()}, v, &ctz, params);
232234 if constexpr (is_date) {
233235 v.cast_to_date ();
234236 }
@@ -331,8 +333,10 @@ Status DataTypeDateSerDe<T>::from_string_batch(
331333 // then we rely on return value to check success.
332334 // return value only represent OK or InvalidArgument for other error(like InternalError) in parser, MUST throw
333335 // Exception!
334- if (!CastToDateOrDatetime::from_string_non_strict_mode<IsDatetime>(
335- str, res, options.timezone , params)) [[unlikely]] {
336+ if (!CastToDateOrDatetime::from_string_non_strict_mode < IsDatetime
337+ ? DatelikeTargetType::DATE_TIME
338+ : DatelikeTargetType::DATE > (str, res, options.timezone , params))
339+ [[unlikely]] {
336340 col_nullmap.get_data ()[i] = true ;
337341 // TODO: we should set `for` functions who need it then skip to set default value for null rows.
338342 col_data.get_data ()[i] = VecDateTimeValue::FIRST_DAY ;
@@ -360,8 +364,10 @@ Status DataTypeDateSerDe<T>::from_string_strict_mode_batch(
360364 }
361365 auto str = col_str.get_data_at (i);
362366 CppType res;
363- CastToDateOrDatetime::from_string_strict_mode<true , IsDatetime>(str, res, options.timezone ,
364- params);
367+ CastToDateOrDatetime::from_string_strict_mode<DatelikeParseMode::STRICT ,
368+ IsDatetime ? DatelikeTargetType::DATE_TIME
369+ : DatelikeTargetType::DATE >(
370+ str, res, options.timezone , params);
365371 // only after we called something with `IS_STRICT = true`, params.status will be set
366372 if (!params.status .ok ()) [[unlikely]] {
367373 params.status .prepend (
@@ -386,8 +392,9 @@ Status DataTypeDateSerDe<T>::from_string(StringRef& str, IColumn& column,
386392 // then we rely on return value to check success.
387393 // return value only represent OK or InvalidArgument for other error(like InternalError) in parser, MUST throw
388394 // Exception!
389- if (!CastToDateOrDatetime::from_string_non_strict_mode<IsDatetime>(str, res, options.timezone ,
390- params)) [[unlikely]] {
395+ if (!CastToDateOrDatetime::from_string_non_strict_mode < IsDatetime
396+ ? DatelikeTargetType::DATE_TIME
397+ : DatelikeTargetType::DATE > (str, res, options.timezone , params)) [[unlikely]] {
391398 return Status::InvalidArgument (" parse date or datetime fail, string: '{}'" ,
392399 str.to_string ());
393400 }
@@ -417,8 +424,10 @@ Status DataTypeDateSerDe<T>::from_olap_string(const std::string& str, Field& fie
417424 // then we rely on return value to check success.
418425 // return value only represent OK or InvalidArgument for other error(like InternalError) in parser, MUST throw
419426 // Exception!
420- if (!CastToDateOrDatetime::from_string_non_strict_mode<IsDatetime>(
421- StringRef (str), res, options.timezone , params)) [[unlikely]] {
427+ if (!CastToDateOrDatetime::from_string_non_strict_mode < IsDatetime
428+ ? DatelikeTargetType::DATE_TIME
429+ : DatelikeTargetType::DATE > (StringRef (str), res, options.timezone , params))
430+ [[unlikely]] {
422431 return Status::InvalidArgument (" parse date or datetime fail, string: '{}'" , str);
423432 }
424433 field = Field::create_field<T>(std::move (res));
@@ -433,8 +442,10 @@ Status DataTypeDateSerDe<T>::from_string_strict_mode(StringRef& str, IColumn& co
433442 CastParameters params {.status = Status::OK (), .is_strict = true };
434443
435444 CppType res;
436- CastToDateOrDatetime::from_string_strict_mode<true , IsDatetime>(str, res, options.timezone ,
437- params);
445+ CastToDateOrDatetime::from_string_strict_mode<DatelikeParseMode::STRICT ,
446+ IsDatetime ? DatelikeTargetType::DATE_TIME
447+ : DatelikeTargetType::DATE >(
448+ str, res, options.timezone , params);
438449 // only after we called something with `IS_STRICT = true`, params.status will be set
439450 if (!params.status .ok ()) [[unlikely]] {
440451 params.status .prepend (fmt::format (" parse {} to {} failed: " , str.to_string_view (), name ()));
@@ -457,8 +468,10 @@ Status DataTypeDateSerDe<T>::from_int_batch(const typename IntDataType::ColumnTy
457468 CastParameters params {.status = Status::OK (), .is_strict = false };
458469 for (size_t i = 0 ; i < int_col.size (); ++i) {
459470 CppType val;
460- if (CastToDateOrDatetime::from_integer<false , IsDatetime>(int_col.get_element (i), val,
461- params)) [[likely]] {
471+ if (CastToDateOrDatetime::from_integer < DatelikeParseMode::NON_STRICT ,
472+ IsDatetime ? DatelikeTargetType::DATE_TIME
473+ : DatelikeTargetType::DATE > (int_col.get_element (i), val, params))
474+ [[likely]] {
462475 // did cast_to_type in `from_integer`
463476 col_data.get_data ()[i] = val;
464477 col_nullmap.get_data ()[i] = false ;
@@ -480,7 +493,10 @@ Status DataTypeDateSerDe<T>::from_int_strict_mode_batch(
480493 CastParameters params {.status = Status::OK (), .is_strict = true };
481494 for (size_t i = 0 ; i < int_col.size (); ++i) {
482495 CppType val;
483- CastToDateOrDatetime::from_integer<true , IsDatetime>(int_col.get_element (i), val, params);
496+ CastToDateOrDatetime::from_integer<DatelikeParseMode::STRICT ,
497+ IsDatetime ? DatelikeTargetType::DATE_TIME
498+ : DatelikeTargetType::DATE >(
499+ int_col.get_element (i), val, params);
484500 if (!params.status .ok ()) [[unlikely]] {
485501 params.status .prepend (
486502 fmt::format (" parse {} to {} failed: " , int_col.get_element (i), name ()));
@@ -504,8 +520,10 @@ Status DataTypeDateSerDe<T>::from_float_batch(const typename FloatDataType::Colu
504520 CastParameters params {.status = Status::OK (), .is_strict = false };
505521 for (size_t i = 0 ; i < float_col.size (); ++i) {
506522 CppType val;
507- if (CastToDateOrDatetime::from_float<false , IsDatetime>(float_col.get_data ()[i], val,
508- params)) [[likely]] {
523+ if (CastToDateOrDatetime::from_float < DatelikeParseMode::NON_STRICT ,
524+ IsDatetime ? DatelikeTargetType::DATE_TIME
525+ : DatelikeTargetType::DATE > (float_col.get_data ()[i], val, 0 , params))
526+ [[likely]] {
509527 col_data.get_data ()[i] = val;
510528 col_nullmap.get_data ()[i] = false ;
511529 } else {
@@ -526,7 +544,10 @@ Status DataTypeDateSerDe<T>::from_float_strict_mode_batch(
526544 CastParameters params {.status = Status::OK (), .is_strict = true };
527545 for (size_t i = 0 ; i < float_col.size (); ++i) {
528546 CppType val;
529- CastToDateOrDatetime::from_float<true , IsDatetime>(float_col.get_data ()[i], val, params);
547+ CastToDateOrDatetime::from_float<DatelikeParseMode::STRICT ,
548+ IsDatetime ? DatelikeTargetType::DATE_TIME
549+ : DatelikeTargetType::DATE >(
550+ float_col.get_data ()[i], val, 0 , params);
530551 if (!params.status .ok ()) [[unlikely]] {
531552 params.status .prepend (
532553 fmt::format (" parse {} to {} failed: " , float_col.get_data ()[i], name ()));
@@ -550,9 +571,12 @@ Status DataTypeDateSerDe<T>::from_decimal_batch(
550571 CastParameters params {.status = Status::OK (), .is_strict = false };
551572 for (size_t i = 0 ; i < decimal_col.size (); ++i) {
552573 CppType val;
553- if (CastToDateOrDatetime::from_decimal<true , IsDatetime>(
554- decimal_col.get_intergral_part (i), decimal_col.get_fractional_part (i),
555- decimal_col.get_scale (), val, params)) [[likely]] {
574+ if (CastToDateOrDatetime::from_decimal < DatelikeParseMode::NON_STRICT ,
575+ IsDatetime ? DatelikeTargetType::DATE_TIME
576+ : DatelikeTargetType::DATE > (decimal_col.get_intergral_part (i),
577+ decimal_col.get_fractional_part (i),
578+ decimal_col.get_scale (), val, params))
579+ [[likely]] {
556580 col_data.get_data ()[i] = val;
557581 col_nullmap.get_data ()[i] = false ;
558582 } else {
@@ -573,9 +597,11 @@ Status DataTypeDateSerDe<T>::from_decimal_strict_mode_batch(
573597 CastParameters params {.status = Status::OK (), .is_strict = true };
574598 for (size_t i = 0 ; i < decimal_col.size (); ++i) {
575599 CppType val;
576- CastToDateOrDatetime::from_decimal<true , IsDatetime>(decimal_col.get_intergral_part (i),
577- decimal_col.get_fractional_part (i),
578- decimal_col.get_scale (), val, params);
600+ CastToDateOrDatetime::from_decimal<DatelikeParseMode::STRICT ,
601+ IsDatetime ? DatelikeTargetType::DATE_TIME
602+ : DatelikeTargetType::DATE >(
603+ decimal_col.get_intergral_part (i), decimal_col.get_fractional_part (i),
604+ decimal_col.get_scale (), val, params);
579605 if (!params.status .ok ()) [[unlikely]] {
580606 params.status .prepend (
581607 fmt::format (" parse {}.{} to {} failed: " , decimal_col.get_intergral_part (i),
0 commit comments