Skip to content

Commit ac71ae1

Browse files
authored
fix(query): fix time parser with enable_strict_datetime_parser = 0 (#17399)
1 parent 8dfab90 commit ac71ae1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/query/functions/src/scalars/timestamp/src/datetime.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,15 @@ fn string_to_format_timestamp(
374374
let _ = tm.set_second(Some(0));
375375
}
376376

377+
if !ctx.func_ctx.enable_strict_datetime_parser {
378+
if tm.day().is_none() {
379+
let _ = tm.set_day(Some(1));
380+
}
381+
if tm.month().is_none() {
382+
let _ = tm.set_month(Some(1));
383+
}
384+
}
385+
377386
let z = if tm.offset().is_none() {
378387
ctx.func_ctx.tz.to_zoned(tm.to_datetime().map_err(|err| {
379388
ErrorCode::BadArguments(format!("{timestamp} to datetime error {err}"))

tests/sqllogictests/suites/query/functions/02_0012_function_datetimes_tz.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,9 +1109,9 @@ select to_date('2017-3-16 0:00:00')
11091109
2017-03-16
11101110

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

11161116
statement error 1006
11171117
select to_timestamp('1684275059752');

0 commit comments

Comments
 (0)