| 163 | }; |
| 164 | |
| 165 | TEST_F(NestedLoopJoinTest, emptyBuildOrProbeWithoutFilter) { |
| 166 | auto empty = makeRowVector({"u0"}, {makeFlatVector<StringView>({})}); |
| 167 | auto nonEmpty = makeRowVector({"t0"}, {makeFlatVector<StringView>({"foo"})}); |
| 168 | auto expected = makeRowVector({makeFlatVector<StringView>({"foo", "foo"})}); |
| 169 | |
| 170 | auto testJoin = [&](const std::vector<RowVectorPtr>& leftVectors, |
| 171 | const std::vector<RowVectorPtr>& rightVectors, |
| 172 | core::JoinType joinType, |
| 173 | const std::vector<std::string>& outputLayout, |
| 174 | const VectorPtr& expected) { |
| 175 | auto planNodeIdGenerator = std::make_shared<core::PlanNodeIdGenerator>(); |
| 176 | auto plan = PlanBuilder(planNodeIdGenerator) |
| 177 | .values(leftVectors) |
| 178 | .localPartitionRoundRobinRow() |
| 179 | .nestedLoopJoin( |
| 180 | PlanBuilder(planNodeIdGenerator) |
| 181 | .values(rightVectors) |
| 182 | .localPartition({}) |
| 183 | .planNode(), |
| 184 | "", |
| 185 | outputLayout, |
| 186 | joinType) |
| 187 | .planNode(); |
| 188 | AssertQueryBuilder builder{plan}; |
| 189 | auto result = builder.copyResults(pool()); |
| 190 | bytedance::bolt::test::assertEqualVectors(expected, result); |
| 191 | }; |
| 192 | |
| 193 | testJoin({nonEmpty}, {empty}, core::JoinType::kLeft, {"t0"}, nonEmpty); |
| 194 | testJoin( |
| 195 | {nonEmpty, nonEmpty}, |
| 196 | {empty, empty}, |
| 197 | core::JoinType::kLeft, |
| 198 | {"t0"}, |
| 199 | expected); |
| 200 | testJoin({empty}, {nonEmpty}, core::JoinType::kLeft, {"u0"}, empty); |
| 201 | |
| 202 | testJoin({empty}, {nonEmpty}, core::JoinType::kRight, {"t0"}, nonEmpty); |
| 203 | testJoin( |
| 204 | {empty, empty}, |
| 205 | {nonEmpty, nonEmpty}, |
| 206 | core::JoinType::kRight, |
| 207 | {"t0"}, |
| 208 | expected); |
| 209 | testJoin({nonEmpty}, {empty}, core::JoinType::kRight, {"u0"}, empty); |
| 210 | |
| 211 | testJoin( |
| 212 | {nonEmpty, nonEmpty}, |
| 213 | {empty, empty}, |
| 214 | core::JoinType::kFull, |
| 215 | {"t0", "u0"}, |
| 216 | makeRowVector({ |
| 217 | makeFlatVector<StringView>({"foo", "foo"}), |
| 218 | makeNullableFlatVector<StringView>({std::nullopt, std::nullopt}), |
| 219 | })); |
| 220 | testJoin( |
| 221 | {empty, empty}, |
| 222 | {nonEmpty, nonEmpty}, |
nothing calls this directly
no test coverage detected