[fix](time) fix error in time_to_sec
This commit is contained in:
@ -22,6 +22,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
@ -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<int>(column_data.get_element(i));
|
||||
res_data[i] = static_cast<int64_t>(column_data.get_element(i)) / (1000 * 1000);
|
||||
}
|
||||
block.replace_by_position(result, std::move(res_col));
|
||||
|
||||
|
||||
13
regression-test/data/correctness/test_time_function.out
Normal file
13
regression-test/data/correctness/test_time_function.out
Normal file
@ -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
|
||||
|
||||
42
regression-test/suites/correctness/test_time_function.groovy
Normal file
42
regression-test/suites/correctness/test_time_function.groovy
Normal file
@ -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);
|
||||
"""
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user