Skip to content

Commit

Permalink
fix(query): fix time parser with enable_strict_datetime_parser = 0 (#โ€ฆ
Browse files Browse the repository at this point in the history
  • Loading branch information
sundy-li authored Feb 3, 2025
1 parent 8dfab90 commit ac71ae1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/query/functions/src/scalars/timestamp/src/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,15 @@ fn string_to_format_timestamp(
let _ = tm.set_second(Some(0));
}

if !ctx.func_ctx.enable_strict_datetime_parser {
if tm.day().is_none() {
let _ = tm.set_day(Some(1));
}
if tm.month().is_none() {
let _ = tm.set_month(Some(1));
}
}

let z = if tm.offset().is_none() {
ctx.func_ctx.tz.to_zoned(tm.to_datetime().map_err(|err| {
ErrorCode::BadArguments(format!("{timestamp} to datetime error {err}"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1109,9 +1109,9 @@ select to_date('2017-3-16 0:00:00')
2017-03-16

query T
select to_timestamp('2017-02-03 14:55:08 ');
select to_timestamp('2017-02-03 14:55:08 '), to_timestamp('2017_', '%Y_'), to_timestamp('2017_03', '%Y_%m');
----
2017-02-03 14:55:08.000000
2017-02-03 14:55:08.000000 2017-01-01 00:00:00.000000 2017-03-01 00:00:00.000000

statement error 1006
select to_timestamp('1684275059752');
Expand Down

0 comments on commit ac71ae1

Please sign in to comment.