Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
Signed-off-by: xufei <[email protected]>
  • Loading branch information
windtalker committed Apr 13, 2023
1 parent a7dcd7f commit 2b70eaf
Showing 1 changed file with 38 additions and 20 deletions.
58 changes: 38 additions & 20 deletions dbms/src/Flash/tests/gtest_join_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,11 +806,6 @@ try
context.addMockTable("split_test", "t1", {{"a", TiDB::TP::TypeLong}, {"b", TiDB::TP::TypeLong}}, {toVec<Int32>("a", {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}), toVec<Int32>("b", {2, 2, 2, 2, 2, 2, 2, 2, 2, 2})});
context.addMockTable("split_test", "t2", {{"a", TiDB::TP::TypeLong}, {"c", TiDB::TP::TypeLong}}, {toVec<Int32>("a", {1, 1, 1, 1, 1}), toVec<Int32>("c", {1, 2, 3, 4, 5})});

auto request = context
.scan("split_test", "t1")
.join(context.scan("split_test", "t2"), tipb::JoinType::TypeInnerJoin, {col("a")}, {}, {}, {gt(col("b"), col("c"))}, {})
.build(context);

std::vector<size_t> block_sizes{
1,
2,
Expand All @@ -820,23 +815,46 @@ try
50,
51,
DEFAULT_BLOCK_SIZE};
std::vector<std::vector<size_t>> expect{
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{4, 3, 2, 1},
{5, 5},
{9, 1},
{10},
{10},
{10}};
for (size_t i = 0; i < block_sizes.size(); ++i)
auto join_types = {tipb::JoinType::TypeInnerJoin, tipb::JoinType::TypeSemiJoin};
std::vector<std::vector<std::vector<size_t>>> expects{
{
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{4, 3, 2, 1},
{5, 5},
{9, 1},
{10},
{10},
{10},
},
{
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{2, 2, 2, 2, 2},
{7, 3},
{10},
{10},
{10},
{10},
{10},
},
};
for (size_t index = 0; index < join_types.size(); index++)
{
context.context->setSetting("max_block_size", Field(static_cast<UInt64>(block_sizes[i])));
auto blocks = getExecuteStreamsReturnBlocks(request);
ASSERT_EQ(expect[i].size(), blocks.size());
for (size_t j = 0; j < blocks.size(); ++j)
auto request = context
.scan("split_test", "t1")
.join(context.scan("split_test", "t2"), *(join_types.begin() + index), {col("a")}, {}, {}, {gt(col("b"), col("c"))}, {})
.build(context);
auto & expect = expects[index];

for (size_t i = 0; i < block_sizes.size(); ++i)
{
ASSERT_EQ(expect[i][j], blocks[j].rows());
context.context->setSetting("max_block_size", Field(static_cast<UInt64>(block_sizes[i])));
auto blocks = getExecuteStreamsReturnBlocks(request);
ASSERT_EQ(expect[i].size(), blocks.size());
for (size_t j = 0; j < blocks.size(); ++j)
{
ASSERT_EQ(expect[i][j], blocks[j].rows());
}
}
}
}
Expand Down

0 comments on commit 2b70eaf

Please sign in to comment.