[fix](planner)the common type of date and decimal should be double (#24956)

This commit is contained in:
starocean999
2023-10-07 11:27:19 +08:00
committed by GitHub
parent 0631ed61b0
commit f1e948e5f4
3 changed files with 33 additions and 18 deletions

View File

@ -1066,24 +1066,9 @@ public class ScalarType extends Type {
return createVarcharType(Math.max(t1.len, t2.len));
}
if (t1.isDecimalV2() && t2.isDate()
|| t1.isDate() && t2.isDecimalV2()) {
return INVALID;
}
if ((t1.isDecimalV2() && t2.isDateV2())
|| (t1.isDateV2() && t2.isDecimalV2())) {
return INVALID;
}
if ((t1.isDecimalV3() && t2.isDate())
|| (t1.isDate() && t2.isDecimalV3())) {
return INVALID;
}
if ((t1.isDecimalV3() && t2.isDateV2())
|| (t1.isDateV2() && t2.isDecimalV3())) {
return INVALID;
if (((t1.isDecimalV3() || t1.isDecimalV2()) && (t2.isDateV2() || t2.isDate()))
|| ((t2.isDecimalV3() || t2.isDecimalV2()) && (t1.isDateV2() || t1.isDate()))) {
return Type.DOUBLE;
}
if (t1.isDecimalV2() && t2.isDecimalV2()) {

View File

@ -0,0 +1,4 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
true

View File

@ -0,0 +1,26 @@
// 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_cast_date_decimal") {
sql """
set enable_nereids_planner=false;
"""
qt_sql """
select cast('2020-02-02' as date ) between cast('2020-02-02' as date ) and cast('2020-02-02' as date ) + 1.0;
"""
}