Skip to content

Commit

Permalink
[fix](planner)the common type of date and decimal should be double (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
starocean999 authored Oct 7, 2023
1 parent 0631ed6 commit f1e948e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1066,24 +1066,9 @@ public static ScalarType getAssignmentCompatibleType(
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()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
true

Original file line number Diff line number Diff line change
@@ -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;
"""
}

0 comments on commit f1e948e

Please sign in to comment.