From 51c5683e04698e521895a1cbd9b01db1f34959ce Mon Sep 17 00:00:00 2001 From: Mryange <2319153948@qq.com> Date: Mon, 7 Aug 2023 11:41:48 +0800 Subject: [PATCH] update --- .../function_date_or_datetime_computation.h | 3 +- .../data/correctness/test_time_function.out | 13 ++++++ .../correctness/test_time_function.groovy | 42 +++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 regression-test/data/correctness/test_time_function.out create mode 100644 regression-test/suites/correctness/test_time_function.groovy diff --git a/be/src/vec/functions/function_date_or_datetime_computation.h b/be/src/vec/functions/function_date_or_datetime_computation.h index 042d3cecc15f56..ebf9a0cb497c3d 100644 --- a/be/src/vec/functions/function_date_or_datetime_computation.h +++ b/be/src/vec/functions/function_date_or_datetime_computation.h @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -1077,7 +1078,7 @@ struct TimeToSecImpl { auto& res_data = res_col->get_data(); for (int i = 0; i < input_rows_count; ++i) { - res_data[i] = static_cast(column_data.get_element(i)); + res_data[i] = static_cast(column_data.get_element(i)) / (1000 * 1000); } block.replace_by_position(result, std::move(res_col)); diff --git a/regression-test/data/correctness/test_time_function.out b/regression-test/data/correctness/test_time_function.out new file mode 100644 index 00000000000000..dcdc6da37a3af1 --- /dev/null +++ b/regression-test/data/correctness/test_time_function.out @@ -0,0 +1,13 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select1 -- +16:32:18 + +-- !select2 -- +16:32:18 + +-- !select3 -- +16:32:18 + +-- !select4 -- +16:32:18 + diff --git a/regression-test/suites/correctness/test_time_function.groovy b/regression-test/suites/correctness/test_time_function.groovy new file mode 100644 index 00000000000000..77a4f9be8ae74a --- /dev/null +++ b/regression-test/suites/correctness/test_time_function.groovy @@ -0,0 +1,42 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("test_time_function") { + sql """ + set enable_nereids_planner=true,enable_fold_constant_by_be = false + """ + qt_select1 """ + select sec_to_time(time_to_sec(cast('16:32:18' as time))); + """ + qt_select2 """ + select sec_to_time(59538); + """ + + sql """ + set enable_nereids_planner=false + """ + + qt_select3 """ + select sec_to_time(time_to_sec(cast('16:32:18' as time))); + """ + qt_select4 """ + select sec_to_time(59538); + """ + + + +} \ No newline at end of file