Run query on 1 replica if no custom_key

This commit is contained in:
Antonio Andelic 2023-01-24 13:58:42 +00:00
parent 7df545fbe3
commit ffa3d1d603

View File

@ -511,7 +511,7 @@ InterpreterSelectQuery::InterpreterSelectQuery(
settings.additional_table_filters, joined_tables.tablesWithColumns().front().table, *context);
ASTPtr parallel_replicas_custom_filter_ast = nullptr;
if (settings.parallel_replicas_count > 1 && settings.parallel_replicas_mode == ParallelReplicasMode::CUSTOM_KEY)
if (settings.parallel_replicas_count > 1 && settings.parallel_replicas_mode == ParallelReplicasMode::CUSTOM_KEY && !joined_tables.tablesWithColumns().empty())
{
if (auto custom_key_ast = parseCustomKeyForTable(settings.parallel_replicas_custom_key, joined_tables.tablesWithColumns().front().table, *context))
{
@ -527,6 +527,14 @@ InterpreterSelectQuery::InterpreterSelectQuery(
*storage,
context);
}
else if (settings.parallel_replica_offset > 0)
{
LOG_DEBUG(
log,
"Will use no data on this replica because parallel replicas processing with custom_key has been requested"
" (setting 'max_parallel_replicas') but the table does not have custom_key defined for it (settings `parallel_replicas_custom_key`)");
parallel_replicas_custom_filter_ast = std::make_shared<ASTLiteral>(false);
}
}
auto analyze = [&](bool try_move_to_prewhere)