Skip to content

Commit 783f191

Browse files
authored
fix(executor): add sum column for test (#261)
1 parent b3037a1 commit 783f191

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/execution/executor_test.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,12 +563,13 @@ TEST_F(ExecutorTest, DISABLED_SimpleGroupByAggregation) {
563563
std::vector<const AbstractExpression *> aggregate_cols{col_a, col_c};
564564
std::vector<AggregationType> agg_types{AggregationType::CountAggregate, AggregationType::SumAggregate};
565565
const AbstractExpression *count_a = MakeAggregateValueExpression(false, 0);
566+
const AbstractExpression *sum_c = MakeAggregateValueExpression(false, 1);
566567
// Make having clause
567568
const AbstractExpression *having = MakeComparisonExpression(
568569
count_a, MakeConstantValueExpression(ValueFactory::GetIntegerValue(100)), ComparisonType::GreaterThan);
569570

570571
// Create plan
571-
agg_schema = MakeOutputSchema({{"countA", count_a}, {"colB", groupby_b}});
572+
agg_schema = MakeOutputSchema({{"countA", count_a}, {"colB", groupby_b}, {"sumC", sum_c}});
572573
agg_plan = std::make_unique<AggregationPlanNode>(agg_schema, scan_plan.get(), having, std::move(group_by_cols),
573574
std::move(aggregate_cols), std::move(agg_types));
574575
}
@@ -580,6 +581,9 @@ TEST_F(ExecutorTest, DISABLED_SimpleGroupByAggregation) {
580581
for (const auto &tuple : result_set) {
581582
// Should have count_a > 100
582583
ASSERT_GT(tuple.GetValue(agg_schema, agg_schema->GetColIdx("countA")).GetAs<int32_t>(), 100);
584+
// Should have sum_c >= 0. Data for test_1 table is randomly generated, where colC is uniformly distributed from
585+
// 0 to 9999. So we can only ensure sumC column exists by checking if it's >= 0 here.
586+
ASSERT_GE(tuple.GetValue(agg_schema, agg_schema->GetColIdx("sumC")).GetAs<int32_t>(), 0);
583587
// Should have unique col_bs.
584588
auto col_b = tuple.GetValue(agg_schema, agg_schema->GetColIdx("colB")).GetAs<int32_t>();
585589
ASSERT_EQ(encountered.count(col_b), 0);

0 commit comments

Comments
 (0)