| 227 | } |
| 228 | |
| 229 | void NestedLoopJoin::joinImpl( |
| 230 | const ExpressionActionsPtr & actions, |
| 231 | const String & filter_name, |
| 232 | Block & left_block) |
| 233 | { |
| 234 | Block new_block; |
| 235 | std::unordered_set<std::string> left_column_names(left_block.columns()); |
| 236 | for (size_t i = 0; i < left_block.columns(); i++) |
| 237 | { |
| 238 | left_column_names.emplace(left_block.getByPosition(i).name); |
| 239 | } |
| 240 | |
| 241 | for (size_t left_row_index = 0; left_row_index < left_block.rows(); left_row_index++) |
| 242 | { |
| 243 | if (right_blocks.empty()) |
| 244 | break; |
| 245 | |
| 246 | auto index = 0; |
| 247 | BlockFilterDescriptions block_filter_descriptions; |
| 248 | for (Block right_block : right_blocks) |
| 249 | { |
| 250 | paddingRightBlockWithConstColumn(left_block, left_row_index, right_block); |
| 251 | actions->execute(right_block, false); |
| 252 | auto filter_column = right_block.getByName(filter_name).column->convertToFullColumnIfConst(); |
| 253 | auto filter_and_holder = std::make_shared<FilterDescription>(*filter_column); |
| 254 | auto filtered_size = countBytesInFilter(*filter_and_holder->data); |
| 255 | block_filter_descriptions.add(index, right_block, filter_and_holder, filtered_size); |
| 256 | index++; |
| 257 | } |
| 258 | |
| 259 | auto total_filtered_size = block_filter_descriptions.getTotalFilteredSize(); |
| 260 | |
| 261 | if (is_left && total_filtered_size == 0) |
| 262 | { |
| 263 | if (new_block.columns() == 0) |
| 264 | { |
| 265 | auto filter_and_holder = block_filter_descriptions.getHolderByIndex(0); |
| 266 | auto right_block = block_filter_descriptions.getBlockByIndex(0); |
| 267 | for (size_t i = 0; i < right_block.columns(); ++i) |
| 268 | { |
| 269 | auto & right_col = right_block.getByPosition(i); |
| 270 | if (isConstFromLeftTable(right_col, left_column_names)) |
| 271 | { |
| 272 | auto & left_col = left_block.getByName(right_col.name); |
| 273 | auto new_column = left_col.type->createColumn(); |
| 274 | new_column->insertFrom(*left_col.column, left_row_index); |
| 275 | new_block.insert({std::move(new_column), left_col.type, left_col.name}); |
| 276 | } |
| 277 | else |
| 278 | { |
| 279 | auto new_column = right_col.type->createColumn(); |
| 280 | new_column->insertDefault(); |
| 281 | new_block.insert({std::move(new_column), right_col.type, right_col.name}); |
| 282 | } |
| 283 | } |
| 284 | continue; |
| 285 | } |
| 286 | else |
nothing calls this directly
no test coverage detected