mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #27648 from Algunenano/i27620
Disable arrayJoin on partition expressions
This commit is contained in:
commit
4a36366925
@ -3207,6 +3207,16 @@ Pipe MergeTreeData::alterPartition(
|
||||
return {};
|
||||
}
|
||||
|
||||
void checkPartitionExpressionFunction(const ASTPtr & ast)
|
||||
{
|
||||
if (const auto * func = ast->as<ASTFunction>())
|
||||
if (func->name == "arrayJoin")
|
||||
throw Exception("The partition expression cannot contain array joins", ErrorCodes::INVALID_PARTITION_VALUE);
|
||||
for (const auto & child : ast->children)
|
||||
checkPartitionExpressionFunction(child);
|
||||
}
|
||||
|
||||
|
||||
String MergeTreeData::getPartitionIDFromQuery(const ASTPtr & ast, ContextPtr local_context) const
|
||||
{
|
||||
const auto & partition_ast = ast->as<ASTPartition &>();
|
||||
@ -3217,6 +3227,9 @@ String MergeTreeData::getPartitionIDFromQuery(const ASTPtr & ast, ContextPtr loc
|
||||
return partition_ast.id;
|
||||
}
|
||||
|
||||
if (partition_ast.value->as<ASTFunction>())
|
||||
checkPartitionExpressionFunction(ast);
|
||||
|
||||
if (format_version < MERGE_TREE_DATA_MIN_FORMAT_VERSION_WITH_CUSTOM_PARTITIONING)
|
||||
{
|
||||
/// Month-partitioning specific - partition ID can be passed in the partition value.
|
||||
|
4
tests/queries/0_stateless/02009_array_join_partition.sql
Normal file
4
tests/queries/0_stateless/02009_array_join_partition.sql
Normal file
@ -0,0 +1,4 @@
|
||||
CREATE TABLE table_2009_part (`i` Int64, `d` Date, `s` String) ENGINE = MergeTree PARTITION BY toYYYYMM(d) ORDER BY i;
|
||||
|
||||
ALTER TABLE table_2009_part ATTACH PARTITION tuple(arrayJoin([0, 1])); -- {serverError 248}
|
||||
ALTER TABLE table_2009_part ATTACH PARTITION tuple(toYYYYMM(toDate([arrayJoin([arrayJoin([arrayJoin([arrayJoin([3, materialize(NULL), arrayJoin([1025, materialize(NULL), materialize(NULL)]), NULL])])]), materialize(NULL)])], NULL))); -- {serverError 248}
|
Loading…
Reference in New Issue
Block a user