Skip to content

Executor test framework failed to support aggregation without groupby expr #5418

@Willendless

Description

@Willendless

Bug Report

Current test framework will throw exception when an aggregation query does not have groupby expression. e.g. select Max(a) from t1.

And the problem lies in DAGRequestBuilder::aggregation(ASTPtr agg_func, ASTPtr group_by_expr)

DAGRequestBuilder & DAGRequestBuilder::aggregation(ASTPtr agg_func, ASTPtr group_by_expr)
{
    auto agg_funcs = std::make_shared<ASTExpressionList>();
    auto group_by_exprs = std::make_shared<ASTExpressionList>();
    agg_funcs->children.push_back(agg_func);
    group_by_exprs->children.push_back(group_by_expr);
    return buildAggregation(agg_funcs, group_by_exprs);
}

When agg_func or group_by_expr is nullptr, the nullptr will be pushed back into ASTExpressionList.

1. Minimal reproduce step (Required)

By writing a simple agg test like following

TEST_F(JoinExecutorTestRunner, agg)
try
{
    context.addMockTable("join_agg", "t1", {{"a", TiDB::TP::TypeLong}, {"b", TiDB::TP::TypeLong}}, {toVec<Int32>("a", {1, 1, 3, 4}), toVec<Int32>("b", {1, 1, 4, 1})});
    auto request = context.scan("join_agg", "t1")
        .aggregation({Max(col("a"))}, {})
        .build(context);
    
    {
        ASSERT_COLUMNS_EQ_UR(createColumns({toNullableVec<Int32>({4})}), executeStreams(request));
    }
}
CATCH

2. What did you expect to see? (Required)

test passed

3. What did you see instead (Required)

unknown file: Failure
C++ exception with description "std::bad_typeid" thrown in the test body.

4. What is your TiFlash version? (Required)

master

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions