Skip to content

Commit

Permalink
chore: move agg null test to aggregation executor file
Browse files Browse the repository at this point in the history
  • Loading branch information
Willendless committed Jul 20, 2022
1 parent e2d0489 commit c20e757
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
29 changes: 29 additions & 0 deletions dbms/src/Flash/tests/gtest_aggregation_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ class ExecutorAggTestRunner : public DB::tests::ExecutorTest
toNullableVec<String>(col_name[1], col_gender),
toNullableVec<String>(col_name[2], col_country),
toNullableVec<Float64>(col_name[3], col_salary)});

context.addMockTable({"aggnull_test", "t1"},
{{"s1", TiDB::TP::TypeString}, {"s2", TiDB::TP::TypeString}},
{toNullableVec<String>("s1", {"banana", {}, "banana"}),
toNullableVec<String>("s2", {"apple", {}, "banana"})});
}

std::shared_ptr<tipb::DAGRequest> buildDAGRequest(std::pair<String, String> src, MockAstVec agg_funcs, MockAstVec group_by_exprs, MockColumnNameVec proj)
Expand Down Expand Up @@ -303,6 +308,30 @@ try
}
CATCH

TEST_F(ExecutorAggTestRunner, AggNull)
try
{
auto request = context
.scan("aggnull_test", "t1")
.aggregation({Max(col("s1"))}, {})
.build(context);
{
ASSERT_COLUMNS_EQ_R(executeStreams(request),
createColumns({toNullableVec<String>({"banana"})}));
}

request = context
.scan("aggnull_test", "t1")
.aggregation({}, {col("s1")})
.build(context);
{
ASSERT_COLUMNS_EQ_R(executeStreams(request),
createColumns({toNullableVec<String>("s1", {{}, "banana"})}));
}
}
CATCH


// TODO support more type of min, max, count.
// support more aggregation functions: sum, forst_row, group_concat

Expand Down
24 changes: 0 additions & 24 deletions dbms/src/Flash/tests/gtest_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,5 @@ try
}
CATCH

// todo: move this test to gtest_aggregation_executor.cpp
TEST_F(ExecutorTestRunner, AggNull)
try
{
auto request = context
.scan("test_db", "test_table")
.aggregation({Max(col("s1"))}, {})
.build(context);
{
ASSERT_COLUMNS_EQ_R(executeStreams(request),
createColumns({toNullableVec<String>({"banana"})}));
}

request = context
.scan("test_db", "test_table")
.aggregation({}, {col("s1")})
.build(context);
{
ASSERT_COLUMNS_EQ_R(executeStreams(request),
createColumns({toNullableVec<String>("s1", {{}, "banana"})}));
}
}
CATCH

} // namespace tests
} // namespace DB

0 comments on commit c20e757

Please sign in to comment.