Enable comparison betwwen Decimal and Float

add tests

update test
This commit is contained in:
feng lv 2021-11-30 03:12:12 +00:00
parent 2d7ff774fd
commit f27699ccda
4 changed files with 29 additions and 2 deletions

View File

@ -487,7 +487,7 @@ inline bool isNotCreatable(const T & data_type)
inline bool isNotDecimalButComparableToDecimal(const DataTypePtr & data_type)
{
WhichDataType which(data_type);
return which.isInt() || which.isUInt();
return which.isInt() || which.isUInt() || which.isFloat();
}
inline bool isCompilableType(const DataTypePtr & data_type)

View File

@ -687,7 +687,7 @@ private:
return (res = DecimalComparison<LeftDataType, RightDataType, Op, false>::apply(col_left, col_right)) != nullptr;
};
if (!callOnBasicTypes<true, false, true, true>(left_number, right_number, call))
if (!callOnBasicTypes<true, true, true, true>(left_number, right_number, call))
throw Exception("Wrong call for " + getName() + " with " + col_left.type->getName() + " and " + col_right.type->getName(),
ErrorCodes::LOGICAL_ERROR);

View File

@ -0,0 +1,13 @@
0
1
0
1
0
0
0
1
0
1
0
0
1

View File

@ -0,0 +1,14 @@
select CAST(1.0, 'Decimal(15,2)') > CAST(1, 'Float64');
select CAST(1.0, 'Decimal(15,2)') = CAST(1, 'Float64');
select CAST(1.0, 'Decimal(15,2)') < CAST(1, 'Float64');
select CAST(1.0, 'Decimal(15,2)') > CAST(-1, 'Float64');
select CAST(1.0, 'Decimal(15,2)') = CAST(-1, 'Float64');
select CAST(1.0, 'Decimal(15,2)') < CAST(-1, 'Float64');
select CAST(1.0, 'Decimal(15,2)') > CAST(1, 'Float32');
select CAST(1.0, 'Decimal(15,2)') = CAST(1, 'Float32');
select CAST(1.0, 'Decimal(15,2)') < CAST(1, 'Float32');
select CAST(1.0, 'Decimal(15,2)') > CAST(-1, 'Float32');
select CAST(1.0, 'Decimal(15,2)') = CAST(-1, 'Float32');
select CAST(1.0, 'Decimal(15,2)') < CAST(-1, 'Float32');
SELECT toDecimal32('11.00', 2) > 1.;