Little fix

This commit is contained in:
JackyWoo 2024-08-07 11:40:01 +08:00
parent aafe498b7f
commit cfaa852af9
2 changed files with 8 additions and 4 deletions

View File

@ -40,10 +40,11 @@ std::optional<Float64> StatisticsUtils::tryConvertToFloat64(const Field & value,
/// For case val_int32 < 10.5 or val_int32 < '10.5' we should convert 10.5 to Float64.
if (isInteger(value_data_type) && (value.getType() == Field::Types::Float64 || value.getType() == Field::Types::String))
val_converted = convertFieldToType(value, *DataTypeFactory::instance().get("Float64"));
else
/// We should convert value to the real column data type and then translate it to Float64.
/// For example for expression col_date > '2024-08-07', if we directly convert '2024-08-07' to Float64, we will get null.
val_converted = convertFieldToType(value, *value_data_type);
/// We should convert value to the real column data type and then translate it to Float64.
/// For example for expression col_date > '2024-08-07', if we directly convert '2024-08-07' to Float64, we will get null.
val_converted = convertFieldToType(value, *value_data_type);
if (val_converted.isNull())
return {};
return applyVisitor(FieldVisitorConvertToNumber<Float64>(), val_converted);

View File

@ -25,4 +25,7 @@ Test statistics multi-types:
Test statistics implicitly type conversion:
Prewhere info
Prewhere filter
Prewhere filter column: and(equals(a, \'1\'), equals(d, \'2024-08-06 09:58:09\'), equals(c, \'0\'), greater(b, 0)) (removed)
Prewhere filter column: and(equals(d, \'2024-08-06 09:58:09\'), equals(c, \'0\')) (removed)
Prewhere info
Prewhere filter
Prewhere filter column: and(equals(d, \'2024-08-06 09:58:09\'), greater(b, 50.1_Float64)) (removed)