mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Refactor arrayJoin check on partition expressions
This commit is contained in:
parent
c4a14ffca2
commit
34099bc196
@ -3207,16 +3207,6 @@ 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 &>();
|
||||
@ -3227,9 +3217,6 @@ 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.
|
||||
@ -3252,6 +3239,16 @@ String MergeTreeData::getPartitionIDFromQuery(const ASTPtr & ast, ContextPtr loc
|
||||
", must be: " + toString(fields_count),
|
||||
ErrorCodes::INVALID_PARTITION_VALUE);
|
||||
|
||||
if (partition_ast.value->as<ASTFunction>())
|
||||
{
|
||||
ASTPtr query = partition_ast.value->clone();
|
||||
auto syntax_analyzer_result = TreeRewriter(local_context)
|
||||
.analyze(query, metadata_snapshot->getPartitionKey().sample_block.getNamesAndTypesList(), {}, {}, false, false);
|
||||
auto actions = ExpressionAnalyzer(query, syntax_analyzer_result, local_context).getActions(true);
|
||||
if (actions->hasArrayJoin())
|
||||
throw Exception("The partition expression cannot contain array joins", ErrorCodes::INVALID_PARTITION_VALUE);
|
||||
}
|
||||
|
||||
const FormatSettings format_settings;
|
||||
Row partition_row(fields_count);
|
||||
|
||||
|
@ -160,6 +160,7 @@
|
||||
"01781_merge_tree_deduplication",
|
||||
"00980_zookeeper_merge_tree_alter_settings",
|
||||
"00980_merge_alter_settings",
|
||||
"02009_array_join_partition",
|
||||
/// Old syntax is not allowed
|
||||
"01062_alter_on_mutataion_zookeeper",
|
||||
"00925_zookeeper_empty_replicated_merge_tree_optimize_final",
|
||||
|
Loading…
Reference in New Issue
Block a user