@@ -557,10 +557,11 @@ Chain buildPushingToViewsChain(
557557 }
558558 }
559559
560+ const Settings & settings = context->getSettingsRef ();
561+
560562 if (views_data && !views_data->views .empty ())
561563 {
562564 size_t num_views = views_data->views .size ();
563- const Settings & settings = context->getSettingsRef ();
564565 if (settings[Setting::parallel_view_processing])
565566 views_data->max_threads = settings[Setting::max_threads] ? std::min (static_cast <size_t >(settings[Setting::max_threads]), num_views) : num_views;
566567
@@ -602,15 +603,17 @@ Chain buildPushingToViewsChain(
602603 sink->setRuntimeData (thread_status, elapsed_counter_ms);
603604 result_chain.addSource (std::move (sink));
604605
605- result_chain.addSource (std::make_shared<DeduplicationToken::DefineSourceWithChunkHashTransform>(result_chain.getInputHeader ()));
606+ if (settings[Setting::deduplicate_blocks_in_dependent_materialized_views])
607+ result_chain.addSource (std::make_shared<DeduplicationToken::DefineSourceWithChunkHashTransform>(result_chain.getInputHeader ()));
606608 }
607609 else if (auto * window_view = dynamic_cast <StorageWindowView *>(storage.get ()))
608610 {
609611 auto sink = std::make_shared<PushingToWindowViewSink>(window_view->getInputHeader (), *window_view, storage, context);
610612 sink->setRuntimeData (thread_status, elapsed_counter_ms);
611613 result_chain.addSource (std::move (sink));
612614
613- result_chain.addSource (std::make_shared<DeduplicationToken::DefineSourceWithChunkHashTransform>(result_chain.getInputHeader ()));
615+ if (settings[Setting::deduplicate_blocks_in_dependent_materialized_views])
616+ result_chain.addSource (std::make_shared<DeduplicationToken::DefineSourceWithChunkHashTransform>(result_chain.getInputHeader ()));
614617 }
615618 else if (dynamic_cast <StorageMaterializedView *>(storage.get ()))
616619 {
@@ -619,7 +622,8 @@ Chain buildPushingToViewsChain(
619622 sink->setRuntimeData (thread_status, elapsed_counter_ms);
620623 result_chain.addSource (std::move (sink));
621624
622- result_chain.addSource (std::make_shared<DeduplicationToken::DefineSourceWithChunkHashTransform>(result_chain.getInputHeader ()));
625+ if (settings[Setting::deduplicate_blocks_in_dependent_materialized_views])
626+ result_chain.addSource (std::make_shared<DeduplicationToken::DefineSourceWithChunkHashTransform>(result_chain.getInputHeader ()));
623627 }
624628 // / Do not push to destination table if the flag is set
625629 else if (!no_destination)
@@ -628,13 +632,15 @@ Chain buildPushingToViewsChain(
628632 metadata_snapshot->check (sink->getHeader ().getColumnsWithTypeAndName ());
629633 sink->setRuntimeData (thread_status, elapsed_counter_ms);
630634
631- result_chain.addSource (std::make_shared<DeduplicationToken::DefineSourceWithChunkHashTransform>(sink->getHeader ()));
635+ if (settings[Setting::deduplicate_blocks_in_dependent_materialized_views])
636+ result_chain.addSource (std::make_shared<DeduplicationToken::DefineSourceWithChunkHashTransform>(sink->getHeader ()));
632637
633638 result_chain.addSource (std::move (sink));
634639 }
635640 else
636641 {
637- result_chain.addSource (std::make_shared<DeduplicationToken::DefineSourceWithChunkHashTransform>(storage_header));
642+ if (settings[Setting::deduplicate_blocks_in_dependent_materialized_views])
643+ result_chain.addSource (std::make_shared<DeduplicationToken::DefineSourceWithChunkHashTransform>(storage_header));
638644 }
639645
640646 if (result_chain.empty ())
0 commit comments