Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test aggregation functions #5364

Merged
merged 23 commits into from
Jul 19, 2022
Merged

Test aggregation functions #5364

merged 23 commits into from
Jul 19, 2022

Conversation

xzhangxian1008
Copy link
Contributor

@xzhangxian1008 xzhangxian1008 commented Jul 13, 2022

What problem does this PR solve?

Issue Number: ref #5347

Problem Summary:

What is changed and how it works?

Add some tests with different types to guarantee the correctness of group by.

Add some tests for the following aggregation functions:

  • Max
  • Min
  • Count

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jul 13, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Lloyd-Pottiger
  • SeaRise

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 13, 2022
@xzhangxian1008
Copy link
Contributor Author

/cc @ywqzzy /cc @Willendless

@ti-chi-bot ti-chi-bot requested a review from ywqzzy July 13, 2022 08:28
@ti-chi-bot
Copy link
Member

@xzhangxian1008: GitHub didn't allow me to request PR reviews from the following users: /cc.

Note that only pingcap members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @ywqzzy /cc @Willendless

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot requested a review from Willendless July 13, 2022 08:28

void executeWithConcurrency(const std::shared_ptr<tipb::DAGRequest> & request, const ColumnsWithTypeAndName & expect_columns)
{
for (size_t i = 1; i < max_concurrency; i += step)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (size_t i = 1; i < max_concurrency; i += step)
for (size_t i = 1; i <= max_concurrency; i += step)

{
/// We can filter the group by column with project operator.
/// topN is applied to get stable results in concurrency environment.
return context.scan(db_name, table_name).aggregation(agg_funcs, group_by_exprs).topN(order_by_items, 100).project(proj).build(context);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe explain why we need a projection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe explain why we need a projection?

Done

@Willendless
Copy link
Contributor

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented Jul 13, 2022

Coverage for changed files

Filename                                       Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Flash/tests/gtest_aggregation_executor.cpp          87                41    52.87%           5                 0   100.00%          79                 0   100.00%          22                11    50.00%
Flash/tests/gtest_topn_executor.cpp                219                63    71.23%           5                 0   100.00%         132                 2    98.48%          70                32    54.29%
TestUtils/mockExecutor.h                             6                 1    83.33%           6                 1    83.33%          15                 3    80.00%           0                 0         -
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                              312               105    66.35%          16                 1    93.75%         226                 5    97.79%          92                43    53.26%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18514      9445             48.98%    208791  95404        54.31%

full coverage report (for internal network access only)

{
ExecutorTest::initializeContext();

context.addMockTable({db_name, table_name},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about add /* parameter_name = */ {db_name, table_name} in this case, otherwise it is confusing.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 15, 2022
@ti-chi-bot ti-chi-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 19, 2022
Copy link
Contributor

@ywqzzy ywqzzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Others LGTM

const String table_name{"clerk"};
const std::vector<String> col_name{"age", "gender", "country", "salary"};
ColumnWithNullableInt32 col_age{30, {}, 27, 32, 25, 36, {}, 22, 34};
ColumnWithNullableString col_gender{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in one line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in one line?

It's clang-tidy who forces me to write like this.

std::shared_ptr<tipb::DAGRequest> buildDAGRequest(std::pair<String, String> src, MockAstVec agg_funcs, MockAstVec group_by_exprs, MockColumnNameVec proj)
{
/// We can filter the group by column with project operator.
/// project is applied to get single column for comparison
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More comments of why use project, like “partial agg output group by columns"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More comments of why use project, like “partial agg output group by columns"

Done

Comment on lines 118 to 119
size_t max_concurrency = 10;
size_t step = 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use static const?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use static const?

Get

@xzhangxian1008
Copy link
Contributor Author

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented Jul 19, 2022

Coverage for changed files

Filename                                       Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Flash/tests/gtest_aggregation_executor.cpp         230                72    68.70%           6                 0   100.00%         155                 1    99.35%          54                26    51.85%
Flash/tests/gtest_topn_executor.cpp                219                63    71.23%           5                 0   100.00%         132                 2    98.48%          70                32    54.29%
TestUtils/mockExecutor.h                             6                 1    83.33%           6                 1    83.33%          15                 3    80.00%           0                 0         -
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                              455               136    70.11%          17                 1    94.12%         302                 6    98.01%         124                58    53.23%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18623      9392             49.57%    212305  94876        55.31%

full coverage report (for internal network access only)

@SeaRise SeaRise self-requested a review July 19, 2022 08:45
Copy link
Contributor

@SeaRise SeaRise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other LGTM

dbms/src/Flash/tests/gtest_aggregation_executor.cpp Outdated Show resolved Hide resolved
}
CATCH

// TODO more aggregation functions...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and add TODO more data types...?

}
CATCH

TEST_F(ExecutorAggTestRunner, AggregationMaxAndMin)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment like TODO: support more type of min, max, count

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment like TODO: support more type of min, max, count

okk

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 19, 2022
@ywqzzy
Copy link
Contributor

ywqzzy commented Jul 19, 2022

/merge

@ti-chi-bot
Copy link
Member

@ywqzzy: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: c1a18c8

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 19, 2022
@sre-bot
Copy link
Collaborator

sre-bot commented Jul 19, 2022

Coverage for changed files

Filename                                       Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Flash/tests/gtest_aggregation_executor.cpp         230                72    68.70%           6                 0   100.00%         155                 1    99.35%          54                26    51.85%
Flash/tests/gtest_topn_executor.cpp                219                63    71.23%           5                 0   100.00%         132                 2    98.48%          70                32    54.29%
TestUtils/mockExecutor.h                             6                 1    83.33%           6                 1    83.33%          15                 3    80.00%           0                 0         -
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                              455               136    70.11%          17                 1    94.12%         302                 6    98.01%         124                58    53.23%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18625      9394             49.56%    212345  94924        55.30%

full coverage report (for internal network access only)

@SeaRise
Copy link
Contributor

SeaRise commented Jul 19, 2022

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented Jul 19, 2022

Coverage for changed files

Filename                                       Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Flash/tests/gtest_aggregation_executor.cpp         230                72    68.70%           6                 0   100.00%         155                 1    99.35%          54                26    51.85%
Flash/tests/gtest_topn_executor.cpp                219                63    71.23%           5                 0   100.00%         132                 2    98.48%          70                32    54.29%
TestUtils/mockExecutor.h                             6                 1    83.33%           6                 1    83.33%          15                 3    80.00%           0                 0         -
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                              455               136    70.11%          17                 1    94.12%         302                 6    98.01%         124                58    53.23%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18625      9393             49.57%    212345  94871        55.32%

full coverage report (for internal network access only)

@sre-bot
Copy link
Collaborator

sre-bot commented Jul 19, 2022

Coverage for changed files

Filename                                       Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Flash/tests/gtest_aggregation_executor.cpp         230                72    68.70%           6                 0   100.00%         155                 1    99.35%          54                26    51.85%
Flash/tests/gtest_topn_executor.cpp                219                63    71.23%           5                 0   100.00%         132                 2    98.48%          70                32    54.29%
TestUtils/mockExecutor.h                             6                 1    83.33%           6                 1    83.33%          15                 3    80.00%           0                 0         -
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                              455               136    70.11%          17                 1    94.12%         302                 6    98.01%         124                58    53.23%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18625      9393             49.57%    212349  94925        55.30%

full coverage report (for internal network access only)

@ti-chi-bot
Copy link
Member

@xzhangxian1008: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@sre-bot
Copy link
Collaborator

sre-bot commented Jul 19, 2022

Coverage for changed files

Filename                                       Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Flash/tests/gtest_aggregation_executor.cpp         230                72    68.70%           6                 0   100.00%         155                 1    99.35%          54                26    51.85%
Flash/tests/gtest_topn_executor.cpp                219                63    71.23%           5                 0   100.00%         132                 2    98.48%          70                32    54.29%
TestUtils/mockExecutor.h                             6                 1    83.33%           6                 1    83.33%          15                 3    80.00%           0                 0         -
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                              455               136    70.11%          17                 1    94.12%         302                 6    98.01%         124                58    53.23%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18625      9393             49.57%    212350  94869        55.32%

full coverage report (for internal network access only)

@ti-chi-bot ti-chi-bot merged commit 29330a2 into pingcap:master Jul 19, 2022
@xzhangxian1008 xzhangxian1008 deleted the agg_test branch July 20, 2022 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants