mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-21 01:00:48 +00:00
Address PR comments
This commit is contained in:
parent
08492ae0c5
commit
2fb7f980ef
@ -303,8 +303,8 @@ Chain buildPushingToViewsChain(
|
|||||||
auto & target_name = runtime_stats->target_name;
|
auto & target_name = runtime_stats->target_name;
|
||||||
auto * view_counter_ms = &runtime_stats->elapsed_ms;
|
auto * view_counter_ms = &runtime_stats->elapsed_ms;
|
||||||
|
|
||||||
auto insert_settings = insert_context->getSettings();
|
const auto & insert_settings = insert_context->getSettingsRef();
|
||||||
ContextMutablePtr new_insert_context = insert_context;
|
ContextMutablePtr view_insert_context = insert_context;
|
||||||
|
|
||||||
if (!disable_deduplication_for_children &&
|
if (!disable_deduplication_for_children &&
|
||||||
insert_settings.update_insert_deduplication_token_in_dependent_materialized_views &&
|
insert_settings.update_insert_deduplication_token_in_dependent_materialized_views &&
|
||||||
@ -321,6 +321,16 @@ Chain buildPushingToViewsChain(
|
|||||||
*
|
*
|
||||||
* Here we want to avoid deduplication for two different blocks generated from `mv_2_1` and `mv_2_2` that will
|
* Here we want to avoid deduplication for two different blocks generated from `mv_2_1` and `mv_2_2` that will
|
||||||
* be inserted into `ds_2_1`.
|
* be inserted into `ds_2_1`.
|
||||||
|
*
|
||||||
|
* We are forced to use view id instead of table id because there are some possible INSERT flows where no tables
|
||||||
|
* are involved.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* landing -┬--> mv_1_1 --┬-> ds_1_1
|
||||||
|
* | |
|
||||||
|
* └--> mv_1_2 --┘
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
auto insert_deduplication_token = insert_settings.insert_deduplication_token.value;
|
auto insert_deduplication_token = insert_settings.insert_deduplication_token.value;
|
||||||
|
|
||||||
@ -329,8 +339,8 @@ Chain buildPushingToViewsChain(
|
|||||||
else
|
else
|
||||||
insert_deduplication_token += "_" + view_id.getFullNameNotQuoted();
|
insert_deduplication_token += "_" + view_id.getFullNameNotQuoted();
|
||||||
|
|
||||||
new_insert_context = Context::createCopy(insert_context);
|
view_insert_context = Context::createCopy(insert_context);
|
||||||
new_insert_context->setSetting("insert_deduplication_token", insert_deduplication_token);
|
view_insert_context->setSetting("insert_deduplication_token", insert_deduplication_token);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto * materialized_view = dynamic_cast<StorageMaterializedView *>(view.get()))
|
if (auto * materialized_view = dynamic_cast<StorageMaterializedView *>(view.get()))
|
||||||
@ -400,7 +410,7 @@ Chain buildPushingToViewsChain(
|
|||||||
insert_columns.emplace_back(column.name);
|
insert_columns.emplace_back(column.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
InterpreterInsertQuery interpreter(nullptr, new_insert_context, false, false, false);
|
InterpreterInsertQuery interpreter(nullptr, view_insert_context, false, false, false);
|
||||||
out = interpreter.buildChain(inner_table, inner_metadata_snapshot, insert_columns, thread_status_holder, view_counter_ms);
|
out = interpreter.buildChain(inner_table, inner_metadata_snapshot, insert_columns, thread_status_holder, view_counter_ms);
|
||||||
out.addStorageHolder(view);
|
out.addStorageHolder(view);
|
||||||
out.addStorageHolder(inner_table);
|
out.addStorageHolder(inner_table);
|
||||||
@ -410,7 +420,7 @@ Chain buildPushingToViewsChain(
|
|||||||
runtime_stats->type = QueryViewsLogElement::ViewType::LIVE;
|
runtime_stats->type = QueryViewsLogElement::ViewType::LIVE;
|
||||||
query = live_view->getInnerQuery(); // Used only to log in system.query_views_log
|
query = live_view->getInnerQuery(); // Used only to log in system.query_views_log
|
||||||
out = buildPushingToViewsChain(
|
out = buildPushingToViewsChain(
|
||||||
view, view_metadata_snapshot, new_insert_context, ASTPtr(),
|
view, view_metadata_snapshot, view_insert_context, ASTPtr(),
|
||||||
/* no_destination= */ true,
|
/* no_destination= */ true,
|
||||||
thread_status_holder, running_group, view_counter_ms, async_insert, storage_header);
|
thread_status_holder, running_group, view_counter_ms, async_insert, storage_header);
|
||||||
}
|
}
|
||||||
@ -419,13 +429,13 @@ Chain buildPushingToViewsChain(
|
|||||||
runtime_stats->type = QueryViewsLogElement::ViewType::WINDOW;
|
runtime_stats->type = QueryViewsLogElement::ViewType::WINDOW;
|
||||||
query = window_view->getMergeableQuery(); // Used only to log in system.query_views_log
|
query = window_view->getMergeableQuery(); // Used only to log in system.query_views_log
|
||||||
out = buildPushingToViewsChain(
|
out = buildPushingToViewsChain(
|
||||||
view, view_metadata_snapshot, new_insert_context, ASTPtr(),
|
view, view_metadata_snapshot, view_insert_context, ASTPtr(),
|
||||||
/* no_destination= */ true,
|
/* no_destination= */ true,
|
||||||
thread_status_holder, running_group, view_counter_ms, async_insert);
|
thread_status_holder, running_group, view_counter_ms, async_insert);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
out = buildPushingToViewsChain(
|
out = buildPushingToViewsChain(
|
||||||
view, view_metadata_snapshot, new_insert_context, ASTPtr(),
|
view, view_metadata_snapshot, view_insert_context, ASTPtr(),
|
||||||
/* no_destination= */ false,
|
/* no_destination= */ false,
|
||||||
thread_status_holder, running_group, view_counter_ms, async_insert);
|
thread_status_holder, running_group, view_counter_ms, async_insert);
|
||||||
|
|
||||||
|
@ -151,4 +151,4 @@ DROP TABLE landing_fix;
|
|||||||
|
|
||||||
DROP TABLE ds_1_1_fix;
|
DROP TABLE ds_1_1_fix;
|
||||||
DROP VIEW mv_1_1;
|
DROP VIEW mv_1_1;
|
||||||
DROP VIEW mv_1_2;
|
DROP VIEW mv_1_2;
|
||||||
|
Loading…
Reference in New Issue
Block a user