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

Support colllation for planner refactory test framework #5449

Merged
merged 10 commits into from
Jul 26, 2022

Conversation

xzhangxian1008
Copy link
Contributor

@xzhangxian1008 xzhangxian1008 commented Jul 22, 2022

What problem does this PR solve?

Issue Number: close #5432

Problem Summary:

Support colllation for planner refactory test framework

What is changed and how it works?

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 22, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • SeaRise
  • ywqzzy

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 22, 2022
@xzhangxian1008
Copy link
Contributor Author

/cc @ywqzzy /cc @SeaRise

@ti-chi-bot ti-chi-bot requested a review from ywqzzy July 22, 2022 05:02
@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 @SeaRise

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 SeaRise July 22, 2022 05:02
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

dbms/src/Flash/tests/gtest_collation.cpp Outdated Show resolved Hide resolved
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.

LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 22, 2022
Comment on lines +56 to +59
explicit DAGRequestBuilder(size_t & index, Int32 collator = TiDB::ITiDBCollator::UTF8MB4_BIN)
: executor_index(index)
{
properties.collator = -abs(collator);
Copy link
Contributor

@Willendless Willendless Jul 23, 2022

Choose a reason for hiding this comment

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

Why do we use -abs(collator) instead of just collator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why do we use -abs(collator) instead of just collator?

collator passed by tidb is negative, so we need to guarantee the collator < 0. See https://github.com/pingcap/tiflash/blob/master/dbms/src/Flash/Coprocessor/DAGUtils.cpp#L1357

@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 25, 2022
@SeaRise SeaRise self-requested a review July 25, 2022 08:13
@ti-chi-bot ti-chi-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 25, 2022
@@ -101,6 +103,9 @@ class DAGRequestBuilder
DAGRequestBuilder & sort(MockOrderByItem order_by, bool is_partial_sort, uint64_t fine_grained_shuffle_stream_count = 0);
DAGRequestBuilder & sort(MockOrderByItemVec order_by_vec, bool is_partial_sort, uint64_t fine_grained_shuffle_stream_count = 0);

void setCollation(Int32 collator_) { properties.collator = -abs(collator_); }
Copy link
Contributor

Choose a reason for hiding this comment

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

may be we can wrap a function for -abs(collator_)

/// add some comments
Int32 inline getXXXCollation(Int32 collator_)
{
    return -abs(collator_);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

may be we can wrap a function for -abs(collator_)

/// add some comments
Int32 inline getXXXCollation(Int32 collator_)
{
    return -abs(collator_);
}

ok

{
context.setCollation(collation);
auto request = context.scan(db_name, table_name).aggregation(MockAstVec{}, {col(col_name)}).project({col_name}).build(context);
std::cout << request->DebugString() << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

useless code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

useless code?

I will delete it

context.setCollation(collation);
auto request = context.scan(db_name, table_name).aggregation(MockAstVec{}, {col(col_name)}).project({col_name}).build(context);
std::cout << request->DebugString() << std::endl;
ASSERT_COLUMNS_EQ_UR(expect, executeStreams(request, 1));
Copy link
Contributor

Choose a reason for hiding this comment

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

seems executeStreams(reuqest) is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

seems executeStreams(reuqest) is enough.

ok

Comment on lines 124 to 126
std::queue<tipb::Executor *> executors;
tipb::Executor * executor = dag_request->mutable_root_executor();
executors.push(executor);
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

{
std::queue<tipb::Executor *> executors;
std::queue<const tipb::Expr *> exprs;
tipb::Executor * executor = dag_request->mutable_root_executor();
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@@ -117,8 +122,9 @@ class DAGRequestBuilder
class MockDAGRequestContext
{
public:
explicit MockDAGRequestContext(Context context_)
explicit MockDAGRequestContext(Context context_, Int32 collation_ = TiDB::ITiDBCollator::UTF8MB4_BIN)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the default parameter not no collation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is the default parameter not no collation?

Because tidb opens the collation by default recently, and sets it as UTF8MB4_BIN.

@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 26, 2022
@SeaRise SeaRise self-requested a review July 26, 2022 03:00
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.

LGTM

@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 26, 2022
@ywqzzy
Copy link
Contributor

ywqzzy commented Jul 26, 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: 9880766

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

sre-bot commented Jul 26, 2022

Coverage for changed files

Filename                            Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Debug/astToExecutor.cpp                 579               137    76.34%          53                 3    94.34%        1528               348    77.23%         572               186    67.48%
Debug/astToExecutor.h                    33                 9    72.73%          22                 4    81.82%          50                13    74.00%          10                 6    40.00%
Flash/tests/gtest_collation.cpp         280                82    70.71%          10                 0   100.00%         349                57    83.67%         124                48    61.29%
TestUtils/mockExecutor.cpp               76                 4    94.74%          43                 2    95.35%         280                27    90.36%          38                 2    94.74%
TestUtils/mockExecutor.h                 11                 4    63.64%          11                 4    63.64%          23                 6    73.91%           0                 0         -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                   979               236    75.89%         139                13    90.65%        2230               451    79.78%         744               242    67.47%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18826      9434             49.89%    214679  95365        55.58%

full coverage report (for internal network access only)

@ti-chi-bot ti-chi-bot merged commit 679eda6 into pingcap:master Jul 26, 2022
@xzhangxian1008 xzhangxian1008 deleted the add_cola branch July 26, 2022 05:07
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.

Support collation for planner refactory test framwork
6 participants