Skip to content

Commit

Permalink
Replace initializer_list with vector for planner test framework (ping…
Browse files Browse the repository at this point in the history
  • Loading branch information
xzhangxian1008 authored and Lloyd-Pottiger committed Jul 19, 2022
1 parent 06dadf4 commit 22fef8e
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 161 deletions.
2 changes: 1 addition & 1 deletion dbms/src/Flash/tests/bench_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class WindowFunctionBench : public ExchangeBench
// build tipb::Window and tipb::Sort.
// select row_number() over w1 from t1 window w1 as (partition by c1, c2, c3 order by c1, c2, c3);
ExchangeBench::SetUp(state);
MockColumnInfos columns{
MockColumnInfoVec columns{
{"c1", TiDB::TP::TypeLongLong},
{"c2", TiDB::TP::TypeString},
{"c3", TiDB::TP::TypeLongLong},
Expand Down
6 changes: 3 additions & 3 deletions dbms/src/Flash/tests/gtest_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ try
auto request = context.scan("test_db", "test_table_1")
.project({"s1", "s2", "s3"})
.project({"s1", "s2"})
.project("s1")
.project({"s1"})
.build(context);
{
String expected = R"(
Expand Down Expand Up @@ -256,7 +256,7 @@ CreatingSets
request = context.receive("sender_1")
.project({"s1", "s2", "s3"})
.project({"s1", "s2"})
.project("s1")
.project({"s1"})
.build(context);
{
String expected = R"(
Expand All @@ -278,7 +278,7 @@ Union: <for test>
request = context.receive("sender_1")
.project({"s1", "s2", "s3"})
.project({"s1", "s2"})
.project("s1")
.project({"s1"})
.exchangeSender(tipb::Broadcast)
.build(context);
{
Expand Down
36 changes: 18 additions & 18 deletions dbms/src/Flash/tests/gtest_projection_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,26 @@ TEST_F(ExecutorProjectionTestRunner, Projection)
try
{
/// Check single column
auto request = buildDAGRequest<MockColumnNames>({col_names[4]});
auto request = buildDAGRequest<MockColumnNameVec>({col_names[4]});
executeWithConcurrency(request, {toNullableVec<Int32>(col_names[4], col4_sorted_asc)});

/// Check multi columns
request = buildDAGRequest<MockColumnNames>({col_names[0], col_names[4]});
request = buildDAGRequest<MockColumnNameVec>({col_names[0], col_names[4]});
executeWithConcurrency(request,
{
toNullableVec<String>(col_names[0], col0_sorted_asc),
toNullableVec<Int32>(col_names[4], col4_sorted_asc),
});

/// Check multi columns
request = buildDAGRequest<MockColumnNames>({col_names[0], col_names[1], col_names[4]});
request = buildDAGRequest<MockColumnNameVec>({col_names[0], col_names[1], col_names[4]});
executeWithConcurrency(request,
{toNullableVec<String>(col_names[0], col0_sorted_asc),
toNullableVec<String>(col_names[1], col1_sorted_asc),
toNullableVec<Int32>(col_names[4], col4_sorted_asc)});

/// Check duplicate columns
request = buildDAGRequest<MockColumnNames>({col_names[4], col_names[4], col_names[4]});
request = buildDAGRequest<MockColumnNameVec>({col_names[4], col_names[4], col_names[4]});
executeWithConcurrency(request,
{toNullableVec<Int32>(col_names[4], col4_sorted_asc),
toNullableVec<Int32>(col_names[4], col4_sorted_asc),
Expand All @@ -114,7 +114,7 @@ try
{
/// Check large number of columns
const size_t col_num = 100;
MockColumnNamesVec projection_input;
MockColumnNameVec projection_input;
ColumnsWithTypeAndName columns;
auto expect_column = toNullableVec<Int32>(col_names[4], col4_sorted_asc);

Expand All @@ -124,7 +124,7 @@ try
columns.push_back(expect_column);
}

request = buildDAGRequest<MockColumnNamesVec>(projection_input);
request = buildDAGRequest<MockColumnNameVec>(projection_input);
executeWithConcurrency(request, columns);
}
}
Expand All @@ -138,18 +138,18 @@ try
/// Test "equal" function

/// Data type: TypeString
request = buildDAGRequest<MockAsts>({eq(col(col_names[0]), col(col_names[0])), col(col_names[4])});
request = buildDAGRequest<MockAstVec>({eq(col(col_names[0]), col(col_names[0])), col(col_names[4])});
executeWithConcurrency(request,
{toNullableVec<UInt64>({{}, 1, 1, 1, 1, 1, 1}),
toNullableVec<Int32>(col_names[4], col4_sorted_asc)});

request = buildDAGRequest<MockAsts>({eq(col(col_names[0]), col(col_names[1])), col(col_names[4])});
request = buildDAGRequest<MockAstVec>({eq(col(col_names[0]), col(col_names[1])), col(col_names[4])});
executeWithConcurrency(request,
{toNullableVec<UInt64>({{}, 0, 1, 0, {}, 0, 0}),
toNullableVec<Int32>(col_names[4], col4_sorted_asc)});

/// Data type: TypeLong
request = buildDAGRequest<MockAsts>({eq(col(col_names[3]), col(col_names[4])), col(col_names[4])});
request = buildDAGRequest<MockAstVec>({eq(col(col_names[3]), col(col_names[4])), col(col_names[4])});
executeWithConcurrency(request,
{toNullableVec<UInt64>({{}, 0, 0, 0, {}, 1, 0}),
toNullableVec<Int32>(col_names[4], col4_sorted_asc)});
Expand All @@ -158,23 +158,23 @@ try
/// Test "greater" function

/// Data type: TypeString
request = buildDAGRequest<MockAsts>({gt(col(col_names[0]), col(col_names[1])), col(col_names[4])});
request = buildDAGRequest<MockAstVec>({gt(col(col_names[0]), col(col_names[1])), col(col_names[4])});
executeWithConcurrency(request,
{toNullableVec<UInt64>({{}, 0, 0, 0, {}, 0, 0}),
toNullableVec<Int32>(col_names[4], col4_sorted_asc)});

request = buildDAGRequest<MockAsts>({gt(col(col_names[1]), col(col_names[0])), col(col_names[4])});
request = buildDAGRequest<MockAstVec>({gt(col(col_names[1]), col(col_names[0])), col(col_names[4])});
executeWithConcurrency(request,
{toNullableVec<UInt64>({{}, 1, 0, 1, {}, 1, 1}),
toNullableVec<Int32>(col_names[4], col4_sorted_asc)});

/// Data type: TypeLong
request = buildDAGRequest<MockAsts>({gt(col(col_names[3]), col(col_names[4])), col(col_names[4])});
request = buildDAGRequest<MockAstVec>({gt(col(col_names[3]), col(col_names[4])), col(col_names[4])});
executeWithConcurrency(request,
{toNullableVec<UInt64>({{}, 0, 1, 1, {}, 0, 0}),
toNullableVec<Int32>(col_names[4], col4_sorted_asc)});

request = buildDAGRequest<MockAsts>({gt(col(col_names[4]), col(col_names[3])), col(col_names[4])});
request = buildDAGRequest<MockAstVec>({gt(col(col_names[4]), col(col_names[3])), col(col_names[4])});
executeWithConcurrency(request,
{toNullableVec<UInt64>({{}, 1, 0, 0, {}, 0, 1}),
toNullableVec<Int32>(col_names[4], col4_sorted_asc)});
Expand All @@ -183,34 +183,34 @@ try
/// Test "and" function

/// Data type: TypeString
request = buildDAGRequest<MockAsts>({And(col(col_names[0]), col(col_names[0])), col(col_names[4])});
request = buildDAGRequest<MockAstVec>({And(col(col_names[0]), col(col_names[0])), col(col_names[4])});
executeWithConcurrency(request,
{toNullableVec<UInt64>({{}, 0, 0, 0, 0, 0, 0}),
toNullableVec<Int32>(col_names[4], col4_sorted_asc)});

request = buildDAGRequest<MockAsts>({And(col(col_names[0]), col(col_names[1])), col(col_names[4])});
request = buildDAGRequest<MockAstVec>({And(col(col_names[0]), col(col_names[1])), col(col_names[4])});
executeWithConcurrency(request,
{toNullableVec<UInt64>({0, 0, 0, 0, 0, 0, 0}),
toNullableVec<Int32>(col_names[4], col4_sorted_asc)});

/// Data type: TypeLong
request = buildDAGRequest<MockAsts>({And(col(col_names[3]), col(col_names[4])), col(col_names[4])});
request = buildDAGRequest<MockAstVec>({And(col(col_names[3]), col(col_names[4])), col(col_names[4])});
executeWithConcurrency(request,
{toNullableVec<UInt64>({{}, 1, 0, 0, {}, 1, 0}),
toNullableVec<Int32>(col_names[4], col4_sorted_asc)});

/// Test "not" function

/// Data type: TypeString
request = buildDAGRequest<MockAsts>({NOT(col(col_names[0])), NOT(col(col_names[1])), NOT(col(col_names[2])), col(col_names[4])});
request = buildDAGRequest<MockAstVec>({NOT(col(col_names[0])), NOT(col(col_names[1])), NOT(col(col_names[2])), col(col_names[4])});
executeWithConcurrency(request,
{toNullableVec<UInt64>({{}, 1, 1, 1, 1, 1, 1}),
toNullableVec<UInt64>({1, 1, 1, 1, {}, 1, 1}),
toNullableVec<UInt64>({1, {}, 1, 1, 1, 1, {}}),
toNullableVec<Int32>(col_names[4], col4_sorted_asc)});

/// Data type: TypeLong
request = buildDAGRequest<MockAsts>({NOT(col(col_names[3])), NOT(col(col_names[4])), col(col_names[4])});
request = buildDAGRequest<MockAstVec>({NOT(col(col_names[3])), NOT(col(col_names[4])), col(col_names[4])});
executeWithConcurrency(request,
{toNullableVec<UInt64>({{}, 0, 1, 0, {}, 0, 1}),
toNullableVec<UInt64>({{}, 0, 0, 1, 0, 0, 0}),
Expand Down
10 changes: 5 additions & 5 deletions dbms/src/Flash/tests/gtest_topn_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ExecutorTopNTestRunner : public DB::tests::ExecutorTest
return context.scan(db_name, table_name).topN(col_name, is_desc, limit_num).build(context);
}

std::shared_ptr<tipb::DAGRequest> buildDAGRequest(const String & table_name, MockOrderByItems order_by_items, int limit, MockAsts func_proj_ast = {}, MockColumnNames out_proj_ast = {})
std::shared_ptr<tipb::DAGRequest> buildDAGRequest(const String & table_name, MockOrderByItemVec order_by_items, int limit, MockAstVec func_proj_ast = {}, MockColumnNameVec out_proj_ast = {})
{
if (func_proj_ast.size() == 0)
return context.scan(db_name, table_name).topN(order_by_items, limit).build(context);
Expand Down Expand Up @@ -126,7 +126,7 @@ try
toNullableVec<String>(col_name[2], ColumnWithString{"china", "china", "usa", "china", "korea", "usa"}),
toNullableVec<Int32>(col_name[3], ColumnWithInt32{-300, {}, {}, 900, 1300, 0})}};

std::vector<MockOrderByItems> order_by_items{
std::vector<MockOrderByItemVec> order_by_items{
/// select * from clerk order by age DESC, gender DESC;
{MockOrderByItem(col_name[0], true), MockOrderByItem(col_name[1], true)},
/// select * from clerk order by gender DESC, salary ASC;
Expand All @@ -150,9 +150,9 @@ try
{
std::shared_ptr<tipb::DAGRequest> request;
std::vector<ColumnsWithTypeAndName> expect_cols;
MockColumnNames output_projection{col_name[0], col_name[1], col_name[2], col_name[3]};
MockAsts func_projection; // Do function operation for topn
MockOrderByItems order_by_items;
MockColumnNameVec output_projection{col_name[0], col_name[1], col_name[2], col_name[3]};
MockAstVec func_projection; // Do function operation for topn
MockOrderByItemVec order_by_items;
ASTPtr col0_ast = col(col_name[0]);
ASTPtr col1_ast = col(col_name[1]);
ASTPtr col2_ast = col(col_name[2]);
Expand Down
Loading

0 comments on commit 22fef8e

Please sign in to comment.