mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 07:01:59 +00:00
Merge pull request #72167 from ClickHouse/backport/24.9/71761
Backport #71761 to 24.9: Forbid Dynamic/Variant types in min/max functions to avoid confusion
This commit is contained in:
commit
ef046d2839
@ -79,6 +79,14 @@ public:
|
||||
"Illegal type {} of second argument of aggregate function {} because the values of that data type are not comparable",
|
||||
type_val->getName(),
|
||||
getName());
|
||||
|
||||
if (isDynamic(this->type_val) || isVariant(this->type_val))
|
||||
throw Exception(
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
|
||||
"Illegal type {} of argument of aggregate function {} because the column of that type can contain values with different "
|
||||
"data types. Consider using typed subcolumns or cast column to a specific data type",
|
||||
this->type_val->getName(),
|
||||
getName());
|
||||
}
|
||||
|
||||
void create(AggregateDataPtr __restrict place) const override /// NOLINT
|
||||
|
@ -35,6 +35,14 @@ public:
|
||||
"Illegal type {} of argument of aggregate function {} because the values of that data type are not comparable",
|
||||
this->result_type->getName(),
|
||||
getName());
|
||||
|
||||
if (isDynamic(this->result_type) || isVariant(this->result_type))
|
||||
throw Exception(
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
|
||||
"Illegal type {} of argument of aggregate function {} because the column of that type can contain values with different "
|
||||
"data types. Consider using typed subcolumns or cast column to a specific data type",
|
||||
this->result_type->getName(),
|
||||
getName());
|
||||
}
|
||||
|
||||
String getName() const override
|
||||
|
@ -63,6 +63,14 @@ public:
|
||||
"Illegal type {} for combinator {} because the values of that data type are not comparable",
|
||||
arguments[key_col]->getName(),
|
||||
getName());
|
||||
|
||||
if (isDynamic(arguments[key_col]) || isVariant(arguments[key_col]))
|
||||
throw Exception(
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
|
||||
"Illegal type {} of argument of aggregate function {} because the column of that type can contain values with different "
|
||||
"data types. Consider using typed subcolumns or cast column to a specific data type",
|
||||
arguments[key_col]->getName(),
|
||||
getName());
|
||||
}
|
||||
|
||||
String getName() const override
|
||||
|
@ -231,6 +231,14 @@ void minmaxIndexValidator(const IndexDescription & index, bool attach)
|
||||
"Data type of argument for minmax index must be comparable, got {} type for column {} instead",
|
||||
column.type->getName(), column.name);
|
||||
}
|
||||
|
||||
if (isDynamic(column.type) || isVariant(column.type))
|
||||
{
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS,
|
||||
"{} data type of column {} is not allowed in minmax index because the column of that type can contain values with different data "
|
||||
"types. Consider using typed subcolumns or cast column to a specific data type",
|
||||
column.type->getName(), column.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
set allow_experimental_dynamic_type=1;
|
||||
select max(number::Dynamic) from numbers(10); -- {serverError ILLEGAL_TYPE_OF_ARGUMENT}
|
||||
select min(number::Dynamic) from numbers(10); -- {serverError ILLEGAL_TYPE_OF_ARGUMENT}
|
||||
select argMax(number, number::Dynamic) from numbers(10); -- {serverError ILLEGAL_TYPE_OF_ARGUMENT}
|
||||
select argMin(number, number::Dynamic) from numbers(10); -- {serverError ILLEGAL_TYPE_OF_ARGUMENT}
|
||||
select anyArgMax(number, number::Dynamic) from numbers(10); -- {serverError ILLEGAL_TYPE_OF_ARGUMENT}
|
||||
select anyArgMin(number, number::Dynamic) from numbers(10); -- {serverError ILLEGAL_TYPE_OF_ARGUMENT}
|
||||
create table test (d Dynamic, index idx d type minmax); -- {serverError BAD_ARGUMENTS}
|
||||
|
||||
set allow_experimental_variant_type=1;
|
||||
select max(number::Variant(UInt64)) from numbers(10); -- {serverError ILLEGAL_TYPE_OF_ARGUMENT}
|
||||
select min(number::Variant(UInt64)) from numbers(10); -- {serverError ILLEGAL_TYPE_OF_ARGUMENT}
|
||||
select argMax(number, number::Variant(UInt64)) from numbers(10); -- {serverError ILLEGAL_TYPE_OF_ARGUMENT}
|
||||
select argMin(number, number::Variant(UInt64)) from numbers(10); -- {serverError ILLEGAL_TYPE_OF_ARGUMENT}
|
||||
select anyArgMax(number, number::Variant(UInt64)) from numbers(10); -- {serverError ILLEGAL_TYPE_OF_ARGUMENT}
|
||||
select anyArgMin(number, number::Variant(UInt64)) from numbers(10); -- {serverError ILLEGAL_TYPE_OF_ARGUMENT}
|
||||
create table test (d Variant(UInt64), index idx d type minmax); -- {serverError BAD_ARGUMENTS}
|
||||
|
Loading…
Reference in New Issue
Block a user