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

Method joinBlock

src/Interpreters/HashJoin/HashJoin.cpp:1264–1323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1262}
1263
1264JoinResultPtr HashJoin::joinBlock(Block block)
1265{
1266 if (!data)
1267 throw Exception(ErrorCodes::LOGICAL_ERROR, "Cannot join after data has been released");
1268
1269 for (const auto & onexpr : table_join->getClauses())
1270 {
1271 auto cond_column_name = onexpr.condColumnNames();
1272 JoinCommon::checkTypesOfKeys(
1273 block, onexpr.key_names_left, cond_column_name.first, right_sample_block, onexpr.key_names_right, cond_column_name.second);
1274 }
1275
1276 if (kind == JoinKind::Cross || kind == JoinKind::Comma)
1277 return joinBlockImplCross(std::move(block));
1278
1279 materializeColumnsFromLeftBlock(block);
1280
1281 const bool prefer_use_maps_all = preferUseMapsAll();
1282 {
1283 std::vector<const std::decay_t<decltype(data->maps[0])> *> maps_vector;
1284 maps_vector.reserve(table_join->getClauses().size());
1285 for (size_t i = 0; i < table_join->getClauses().size(); ++i)
1286 maps_vector.push_back(&data->maps[i]);
1287
1288 JoinResultPtr res;
1289 if (joinDispatch(
1290 kind,
1291 strictness,
1292 maps_vector,
1293 prefer_use_maps_all,
1294 [&](auto kind_, auto strictness_, auto & maps_vector_)
1295 {
1296 if constexpr (std::is_same_v<std::decay_t<decltype(maps_vector_)>, std::vector<const MapsAll *>>)
1297 {
1298 res = HashJoinMethods<kind_, strictness_, MapsAll>::joinBlockImpl(
1299 *this, std::move(block), sample_block_with_columns_to_add, maps_vector_);
1300 }
1301 else if constexpr (std::is_same_v<std::decay_t<decltype(maps_vector_)>, std::vector<const MapsOne *>>)
1302 {
1303 res = HashJoinMethods<kind_, strictness_, MapsOne>::joinBlockImpl(
1304 *this, std::move(block), sample_block_with_columns_to_add, maps_vector_);
1305 }
1306 else if constexpr (std::is_same_v<std::decay_t<decltype(maps_vector_)>, std::vector<const MapsAsof *>>)
1307 {
1308 res = HashJoinMethods<kind_, strictness_, MapsAsof>::joinBlockImpl(
1309 *this, std::move(block), sample_block_with_columns_to_add, maps_vector_);
1310 }
1311 else
1312 {
1313 throw Exception(ErrorCodes::LOGICAL_ERROR, "Unknown maps type");
1314 }
1315 }))
1316 {
1317 /// Joined
1318 return res;
1319 }
1320 else
1321 throw Exception(ErrorCodes::LOGICAL_ERROR, "Wrong JOIN combination: {} {}", strictness, kind);

Callers

nothing calls this directly

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