mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Fix KeyCondition with no common types
This commit is contained in:
parent
3e6c94929b
commit
e62f4e50a6
@ -530,4 +530,16 @@ DataTypePtr getLeastSupertype(const DataTypes & types)
|
|||||||
throw Exception(getExceptionMessagePrefix(types), ErrorCodes::NO_COMMON_TYPE);
|
throw Exception(getExceptionMessagePrefix(types), ErrorCodes::NO_COMMON_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DataTypePtr tryGetLeastSupertype(const DataTypes & types)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return getLeastSupertype(types);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,4 +14,7 @@ namespace DB
|
|||||||
*/
|
*/
|
||||||
DataTypePtr getLeastSupertype(const DataTypes & types);
|
DataTypePtr getLeastSupertype(const DataTypes & types);
|
||||||
|
|
||||||
|
/// Same as above but return nullptr instead of throwing exception.
|
||||||
|
DataTypePtr tryGetLeastSupertype(const DataTypes & types);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1306,7 +1306,10 @@ bool KeyCondition::tryParseAtomFromAST(const ASTPtr & node, ContextPtr context,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DataTypePtr common_type = getLeastSupertype({key_expr_type_not_null, const_type});
|
DataTypePtr common_type = tryGetLeastSupertype({key_expr_type_not_null, const_type});
|
||||||
|
if (!common_type)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!const_type->equals(*common_type))
|
if (!const_type->equals(*common_type))
|
||||||
{
|
{
|
||||||
castValueToType(common_type, const_value, const_type, node);
|
castValueToType(common_type, const_value, const_type, node);
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
0.9
|
@ -0,0 +1,9 @@
|
|||||||
|
drop table if exists t;
|
||||||
|
|
||||||
|
create table t (c Decimal32(9)) engine MergeTree order by c;
|
||||||
|
|
||||||
|
insert into t values (0.9);
|
||||||
|
|
||||||
|
select * from t where c < 1.2;
|
||||||
|
|
||||||
|
drop table t;
|
Loading…
Reference in New Issue
Block a user