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

Method joinScatteredBlock

src/Interpreters/HashJoin/HashJoin.cpp:1325–1381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1323}
1324
1325JoinResultPtr HashJoin::joinScatteredBlock(ScatteredBlock block)
1326{
1327 if (!data)
1328 throw Exception(ErrorCodes::LOGICAL_ERROR, "Cannot join after data has been released");
1329
1330 chassert(kind == JoinKind::Left || kind == JoinKind::Inner || kind == JoinKind::Right || kind == JoinKind::Full);
1331 for (const auto & onexpr : table_join->getClauses())
1332 {
1333 auto cond_column_name = onexpr.condColumnNames();
1334 JoinCommon::checkTypesOfKeys(
1335 block.getSourceBlock(),
1336 onexpr.key_names_left,
1337 cond_column_name.first,
1338 right_sample_block,
1339 onexpr.key_names_right,
1340 cond_column_name.second);
1341 }
1342
1343 std::vector<const std::decay_t<decltype(data->maps[0])> *> maps_vector;
1344 maps_vector.reserve(table_join->getClauses().size());
1345
1346 for (size_t i = 0; i < table_join->getClauses().size(); ++i)
1347 maps_vector.push_back(&data->maps[i]);
1348
1349 const bool prefer_use_maps_all = preferUseMapsAll();
1350 JoinResultPtr res;
1351 [[maybe_unused]] const bool joined = joinDispatch(
1352 kind,
1353 strictness,
1354 maps_vector,
1355 prefer_use_maps_all,
1356 [&](auto kind_, auto strictness_, auto & maps_vector_)
1357 {
1358 if constexpr (std::is_same_v<std::decay_t<decltype(maps_vector_)>, std::vector<const MapsAll *>>)
1359 {
1360 res = HashJoinMethods<kind_, strictness_, MapsAll>::joinBlockImpl(
1361 *this, std::move(block), sample_block_with_columns_to_add, maps_vector_);
1362 }
1363 else if constexpr (std::is_same_v<std::decay_t<decltype(maps_vector_)>, std::vector<const MapsOne *>>)
1364 {
1365 res = HashJoinMethods<kind_, strictness_, MapsOne>::joinBlockImpl(
1366 *this, std::move(block), sample_block_with_columns_to_add, maps_vector_);
1367 }
1368 else if constexpr (std::is_same_v<std::decay_t<decltype(maps_vector_)>, std::vector<const MapsAsof *>>)
1369 {
1370 res = HashJoinMethods<kind_, strictness_, MapsAsof>::joinBlockImpl(
1371 *this, std::move(block), sample_block_with_columns_to_add, maps_vector_);
1372 }
1373 else
1374 {
1375 throw Exception(ErrorCodes::LOGICAL_ERROR, "Unknown maps type");
1376 }
1377 });
1378
1379 chassert(joined);
1380 return res;
1381}
1382

Callers 1

nextMethod · 0.80

Calls 7

checkTypesOfKeysFunction · 0.85
joinDispatchFunction · 0.85
condColumnNamesMethod · 0.80
ExceptionClass · 0.50
reserveMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected