[fix](timev2) fix Type not implemented in fold by be (#26478)

This commit is contained in:
Mryange
2023-11-07 17:25:20 +08:00
committed by GitHub
parent b0788652bd
commit ef95e962c7
3 changed files with 53 additions and 0 deletions

View File

@ -195,6 +195,11 @@ string FoldConstantExecutor::_get_result(void* src, size_t size, const TypeDescr
double val = *reinterpret_cast<double*>(src);
return fmt::format("{}", val);
}
case TYPE_TIMEV2: {
constexpr static auto ratio_to_time = (1000 * 1000);
double val = *reinterpret_cast<double*>(src);
return fmt::format("{}", val / ratio_to_time);
}
case TYPE_CHAR:
case TYPE_VARCHAR:
case TYPE_STRING:

View File

@ -0,0 +1,13 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select1 --
-07:00:00
-- !select2 --
-07:00:00
-- !select3 --
-07:00:00
-- !select4 --
-07:00:00

View File

@ -0,0 +1,35 @@
// 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_timev2_fold") {
sql """ set enable_nereids_planner=false,enable_fold_constant_by_be=false """
qt_select1 """
select timediff( convert_tz("2020-05-05 00:00:00", 'UTC', 'America/Los_Angeles'), "2020-05-05 00:00:00");
"""
sql """ set enable_nereids_planner=true,enable_fold_constant_by_be=false """
qt_select2 """
select timediff( convert_tz("2020-05-05 00:00:00", 'UTC', 'America/Los_Angeles'), "2020-05-05 00:00:00");
"""
sql """ set enable_nereids_planner=false,enable_fold_constant_by_be=true """
qt_select3 """
select timediff( convert_tz("2020-05-05 00:00:00", 'UTC', 'America/Los_Angeles'), "2020-05-05 00:00:00");
"""
sql """ set enable_nereids_planner=true,enable_fold_constant_by_be=true """
qt_select4 """
select timediff( convert_tz("2020-05-05 00:00:00", 'UTC', 'America/Los_Angeles'), "2020-05-05 00:00:00");
"""
}