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

Method sendQuery

src/Client/HedgedConnections.cpp:162–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162void HedgedConnections::sendQuery(
163 const ConnectionTimeouts & timeouts,
164 const String & query,
165 const String & query_id,
166 UInt64 stage,
167 ClientInfo & client_info,
168 bool with_pending_data,
169 const std::vector<String> & external_roles)
170{
171 std::lock_guard lock(cancel_mutex);
172
173 if (sent_query)
174 throw Exception(ErrorCodes::LOGICAL_ERROR, "Query already sent.");
175
176 for (auto & offset_state : offset_states)
177 {
178 for (auto & replica : offset_state.replicas)
179 {
180 if (replica.connection->getServerRevision(timeouts) < DBMS_MIN_REVISION_WITH_CURRENT_AGGREGATION_VARIANT_SELECTION_METHOD)
181 {
182 disable_two_level_aggregation = true;
183 break;
184 }
185 }
186 if (disable_two_level_aggregation)
187 break;
188 }
189
190 if (!disable_two_level_aggregation)
191 {
192 /// Tell hedged_connections_factory to skip replicas that doesn't support two-level aggregation.
193 hedged_connections_factory.skipReplicasWithTwoLevelAggregationIncompatibility();
194 }
195
196 auto send_query = [this, timeouts, query, query_id, stage, client_info, with_pending_data, external_roles](ReplicaState & replica)
197 {
198 Settings modified_settings = settings;
199
200 /// Queries in foreign languages are transformed to ClickHouse-SQL. Ensure the setting before sending.
201 modified_settings[Setting::dialect] = Dialect::clickhouse;
202 modified_settings[Setting::dialect].changed = false;
203
204 modified_settings[Setting::interactive_delay] = scaleInteractiveDelayByFanout(
205 modified_settings[Setting::interactive_delay],
206 distributed_fanout * offset_states.size());
207
208 if (disable_two_level_aggregation)
209 {
210 /// Disable two-level aggregation due to version incompatibility.
211 modified_settings[Setting::group_by_two_level_threshold] = 0;
212 modified_settings[Setting::group_by_two_level_threshold_bytes] = 0;
213 }
214
215 const bool enable_offset_parallel_processing = context->canUseOffsetParallelReplicas();
216
217 if (offset_states.size() > 1 && enable_offset_parallel_processing)
218 {
219 modified_settings[Setting::parallel_replicas_count] = offset_states.size();

Callers

nothing calls this directly

Calls 12

setRelativeMethod · 0.80
ExceptionClass · 0.70
send_queryFunction · 0.50
getServerRevisionMethod · 0.45
sizeMethod · 0.45
getFileDescriptorMethod · 0.45
setMethod · 0.45
setTimeoutMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected