Skip to content

fix(query): to_yyyymmddhhmmss only support timestamp type #17422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions src/query/functions/src/scalars/timestamp/src/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1332,32 +1332,6 @@ fn register_to_number_functions(registry: &mut FunctionRegistry) {
}
}),
);
registry.register_passthrough_nullable_1_arg::<DateType, UInt64Type, _, _>(
"to_yyyymmddhh",
|_, _| FunctionDomain::Full,
vectorize_with_builder_1_arg::<DateType, UInt64Type>(|val, output, ctx| {
match ToNumberImpl::eval_date::<ToYYYYMMDDHH, _>(val, ctx.func_ctx.tz.clone()) {
Ok(t) => output.push(t),
Err(e) => {
ctx.set_error(output.len(), format!("cannot parse to type `Date`. {}", e));
output.push(0);
}
}
}),
);
registry.register_passthrough_nullable_1_arg::<DateType, UInt64Type, _, _>(
"to_yyyymmddhhmmss",
|_, _| FunctionDomain::Full,
vectorize_with_builder_1_arg::<DateType, UInt64Type>(|val, output, ctx| {
match ToNumberImpl::eval_date::<ToYYYYMMDDHHMMSS, _>(val, ctx.func_ctx.tz.clone()) {
Ok(t) => output.push(t),
Err(e) => {
ctx.set_error(output.len(), format!("cannot parse to type `Date`. {}", e));
output.push(0);
}
}
}),
);
registry.register_passthrough_nullable_1_arg::<DateType, UInt16Type, _, _>(
"to_year",
|_, _| FunctionDomain::Full,
Expand Down
4 changes: 2 additions & 2 deletions src/query/functions/tests/it/scalars/testdata/datetime.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2489,7 +2489,7 @@ output : 20210905

ast : to_yyyymmddhhmmss(to_date(18875))
raw expr : to_yyyymmddhhmmss(to_date(18875))
checked expr : to_yyyymmddhhmmss<Date>(to_date<Int64>(to_int64<UInt16>(18875_u16)))
checked expr : to_yyyymmddhhmmss<Timestamp>(to_timestamp<Date>(to_date<Int64>(to_int64<UInt16>(18875_u16))))
optimized expr : 20210905000000_u64
output type : UInt64
output domain : {20210905000000..=20210905000000}
Expand Down Expand Up @@ -2605,7 +2605,7 @@ evaluation (internal):

ast : to_yyyymmddhhmmss(a)
raw expr : to_yyyymmddhhmmss(a::Date)
checked expr : to_yyyymmddhhmmss<Date>(a)
checked expr : to_yyyymmddhhmmss<Timestamp>(to_timestamp<Date>(a))
evaluation:
+--------+--------------+----------------------------+
| | a | Output |
Expand Down
12 changes: 4 additions & 8 deletions src/query/functions/tests/it/scalars/testdata/function_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4092,14 +4092,10 @@ Functions overloads:
1 to_yyyymmdd(Date NULL) :: UInt32 NULL
2 to_yyyymmdd(Timestamp) :: UInt32
3 to_yyyymmdd(Timestamp NULL) :: UInt32 NULL
0 to_yyyymmddhh(Date) :: UInt64
1 to_yyyymmddhh(Date NULL) :: UInt64 NULL
2 to_yyyymmddhh(Timestamp) :: UInt64
3 to_yyyymmddhh(Timestamp NULL) :: UInt64 NULL
0 to_yyyymmddhhmmss(Date) :: UInt64
1 to_yyyymmddhhmmss(Date NULL) :: UInt64 NULL
2 to_yyyymmddhhmmss(Timestamp) :: UInt64
3 to_yyyymmddhhmmss(Timestamp NULL) :: UInt64 NULL
0 to_yyyymmddhh(Timestamp) :: UInt64
1 to_yyyymmddhh(Timestamp NULL) :: UInt64 NULL
0 to_yyyymmddhhmmss(Timestamp) :: UInt64
1 to_yyyymmddhhmmss(Timestamp NULL) :: UInt64 NULL
0 today() :: Date
0 tomorrow() :: Date
0 translate(String, String, String) :: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,11 @@ select to_yyyymmddhhmmss(to_date(18875))
----
20210905000000

query I
SELECT to_yyyymmddhhmmss('2023-11-12 09:38:18.165575')
----
20231112093818

query B
select to_yyyymmddhhmmss(to_datetime(1630833797000000)) = 20210905092317
----
Expand Down Expand Up @@ -447,6 +452,11 @@ select to_yyyymmddhh(to_date(18875)) = 2021090500
----
1

query I
SELECT to_yyyymmddhh('2023-11-12 09:38:18.165575')
----
2023111209

query I
select to_yyyymmdd(to_datetime(1630833797000000))
----
Expand Down