diff --git a/src/Functions/FunctionsComparison.h b/src/Functions/FunctionsComparison.h index 3f5146935cb..dcdbb3738f8 100644 --- a/src/Functions/FunctionsComparison.h +++ b/src/Functions/FunctionsComparison.h @@ -687,7 +687,7 @@ private: return (res = DecimalComparison::apply(col_left, col_right)) != nullptr; }; - if (!callOnBasicTypes(left_number, right_number, call)) + if (!callOnBasicTypes(left_number, right_number, call)) throw Exception("Wrong call for " + getName() + " with " + col_left.type->getName() + " and " + col_right.type->getName(), ErrorCodes::LOGICAL_ERROR); @@ -1175,8 +1175,11 @@ public: const bool left_is_num = col_left_untyped->isNumeric(); const bool right_is_num = col_right_untyped->isNumeric(); - const bool left_is_string = isStringOrFixedString(which_left); - const bool right_is_string = isStringOrFixedString(which_right); + const bool left_is_float = which_left.isFloat(); + const bool right_is_float = which_right.isFloat(); + + const bool left_is_string = which_left.isStringOrFixedString(); + const bool right_is_string = which_right.isStringOrFixedString(); bool date_and_datetime = (which_left.idx != which_right.idx) && (which_left.isDate() || which_left.isDate32() || which_left.isDateTime() || which_left.isDateTime64()) && (which_right.isDate() || which_right.isDate32() || which_right.isDateTime() || which_right.isDateTime64()); @@ -1237,6 +1240,16 @@ public: throw Exception( "No operation " + getName() + " between " + left_type->getName() + " and " + right_type->getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + if (left_is_float) + { + ColumnPtr left_converted = castColumn(col_with_type_and_name_left, right_type); + return executeDecimal({left_converted, right_type, "left"}, col_with_type_and_name_right); + } + if (right_is_float) + { + ColumnPtr right_converted = castColumn(col_with_type_and_name_right, left_type); + return executeDecimal(col_with_type_and_name_left, {right_converted, left_type, "right"}); + } return executeDecimal(col_with_type_and_name_left, col_with_type_and_name_right); }