MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / addPipe

Method addPipe

src/Processors/QueryPlan/ReadFromRemote.cpp:725–860  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

723}
724
725void ReadFromRemote::addPipe(
726 Pipes & pipes, const ClusterProxy::SelectStreamFactory::Shard & shard, const SharedHeader & out_header, size_t parallel_marshalling_threads)
727{
728 bool add_agg_info = stage == QueryProcessingStage::WithMergeableState;
729 bool add_totals = false;
730 bool add_extremes = false;
731 bool async_read = context->getSettingsRef()[Setting::async_socket_for_remote];
732 bool async_query_sending = context->getSettingsRef()[Setting::async_query_sending_for_remote];
733 bool parallel_replicas_disabled = context->getSettingsRef()[Setting::allow_experimental_parallel_reading_from_replicas] == 0;
734 if (stage == QueryProcessingStage::Complete)
735 {
736 if (const auto * ast_select = shard.query->as<ASTSelectQuery>())
737 add_totals = ast_select->group_by_with_totals;
738 add_extremes = context->getSettingsRef()[Setting::extremes];
739 }
740
741 scalars["_shard_num"]
742 = Block{{DataTypeUInt32().createColumnConst(1, shard.shard_info.shard_num), std::make_shared<DataTypeUInt32>(), "_shard_num"}};
743
744 if (context->canUseTaskBasedParallelReplicas())
745 {
746 if (context->getSettingsRef()[Setting::cluster_for_parallel_replicas].changed)
747 {
748 const String cluster_for_parallel_replicas = context->getSettingsRef()[Setting::cluster_for_parallel_replicas];
749 if (cluster_for_parallel_replicas != cluster_name)
750 LOG_INFO(
751 log,
752 "cluster_for_parallel_replicas has been set for the query but has no effect: {}. Distributed table cluster is "
753 "used: {}",
754 cluster_for_parallel_replicas,
755 cluster_name);
756 }
757
758 LOG_TRACE(log, "Setting `cluster_for_parallel_replicas` to {}", cluster_name);
759 context->setSetting("cluster_for_parallel_replicas", cluster_name);
760 }
761
762 bool enable_analyzer = context->getSettingsRef()[Setting::allow_experimental_analyzer];
763
764 /// parallel replicas custom key case
765 if (shard.shard_filter_generator)
766 {
767 for (size_t i = 0; i < shard.shard_info.per_replica_pools.size(); ++i)
768 {
769 auto query = shard.query->clone();
770 auto & select_query = getSelectQuery(query);
771 auto shard_filter = shard.shard_filter_generator(i + 1);
772 if (shard_filter)
773 {
774 auto where_expression = select_query.where();
775 if (where_expression)
776 shard_filter = makeASTFunction("and", where_expression, shard_filter);
777
778 select_query.setExpression(ASTSelectQuery::Expression::WHERE, std::move(shard_filter));
779 }
780
781 const String query_string = formattedAST(query, enable_analyzer);
782

Callers

nothing calls this directly

Calls 15

randomSeedFunction · 0.85
createRemoteSourcePipeFunction · 0.85
addFiltersFunction · 0.85
getPriorityFuncMethod · 0.80
setPoolModeMethod · 0.80
setMainTableMethod · 0.80
formattedASTFunction · 0.70
addConvertingActionsFunction · 0.70
makeASTFunctionFunction · 0.50

Tested by

no test coverage detected