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

util/testkit: make the msg of failed check more readable #7386

Merged
merged 7 commits into from
Aug 15, 2018

Conversation

winoros
Copy link
Member

@winoros winoros commented Aug 14, 2018

What problem does this PR solve?

Currently the error msg when one explain checked failed is as following:

    res.c.Assert(got, check.Equals, need, res.comment)
... obtained string = "[[Projection_11 10.00 root 9_aux_0] [└─Apply_13 10.00 root left outer semi join, inner:StreamAgg_20, equal:[eq(test.t.c, count(*))]] [  ├─TableReader_15 10.00 root data:TableScan_14] [  │ └─TableScan_14 10.00 cop table:t, range:[-inf,+inf], keep order:false] [  └─StreamAgg_20 1.00 root funcs:count(1)] [    └─HashRightJoin_22 1.00 root inner join, inner:TableReader_25, equal:[eq(s.a, t1.a)]] [      ├─TableReader_25 1.00 root data:Selection_24] [      │ └─Selection_24 1.00 cop eq(s.a, test.t.a)] [      │   └─TableScan_23 10.00 cop table:s, range:[-inf,+inf], keep order:false] [      └─TableReader_27 10.00 root data:TableScan_26] [        └─TableScan_26 10.00 cop table:t1, range:[-inf,+inf], keep order:false]]"
... expected string = "[[Projection_11 10.00 root 9_aux_0] [└─Apply_12 10.00 root left outer semi join, inner:StreamAgg_20, equal:[eq(test.t.c, count(*))]] [  ├─TableReader_15 10.00 root data:TableScan_14] [  │ └─TableScan_14 10.00 cop table:t, range:[-inf,+inf], keep order:false] [  └─StreamAgg_20 1.00 root funcs:count(1)] [    └─HashRightJoin_22 1.00 root inner join, inner:TableReader_25, equal:[eq(s.a, t1.a)]] [      ├─TableReader_25 1.00 root data:Selection_24] [      │ └─Selection_24 1.00 cop eq(s.a, test.t.a)] [      │   └─TableScan_23 10.00 cop table:s, range:[-inf,+inf], keep order:false] [      └─TableReader_27 10.00 root data:TableScan_26] [        └─TableScan_26 10.00 cop table:t1, range:[-inf,+inf], keep order:false]]"
... sql:explain select t.c in (select count(*) from t s , t t1 where s.a = t.a and s.a = t1.a) from t;, args:[]

It's not easy to see where is wrong.

What is changed and how it works?

Make the error msg line by line.

    res.c.Assert(resBuff.String(), check.Equals, needBuff.String(), res.comment)
... obtained string = "" +
...     "[Projection_11 10.00 root 9_aux_0]\n" +
...     "[└─Apply_13 10.00 root left outer semi join, inner:StreamAgg_20, equal:[eq(test.t.c, count(*))]]\n" +
...     "[  ├─TableReader_15 10.00 root data:TableScan_14]\n" +
...     "[  │ └─TableScan_14 10.00 cop table:t, range:[-inf,+inf], keep order:false]\n" +
...     "[  └─StreamAgg_20 1.00 root funcs:count(1)]\n" +
...     "[    └─HashRightJoin_22 1.00 root inner join, inner:TableReader_25, equal:[eq(s.a, t1.a)]]\n" +
...     "[      ├─TableReader_25 1.00 root data:Selection_24]\n" +
...     "[      │ └─Selection_24 1.00 cop eq(s.a, test.t.a)]\n" +
...     "[      │   └─TableScan_23 10.00 cop table:s, range:[-inf,+inf], keep order:false]\n" +
...     "[      └─TableReader_27 10.00 root data:TableScan_26]\n" +
...     "[        └─TableScan_26 10.00 cop table:t1, range:[-inf,+inf], keep order:false]\n"
... expected string = "" +
...     "[Projection_11 10.00 root 9_aux_0]\n" +
...     "[└─Apply_12 10.00 root left outer semi join, inner:StreamAgg_20, equal:[eq(test.t.c, count(*))]]\n" +
...     "[  ├─TableReader_15 10.00 root data:TableScan_14]\n" +
...     "[  │ └─TableScan_14 10.00 cop table:t, range:[-inf,+inf], keep order:false]\n" +
...     "[  └─StreamAgg_20 1.00 root funcs:count(1)]\n" +
...     "[    └─HashRightJoin_22 1.00 root inner join, inner:TableReader_25, equal:[eq(s.a, t1.a)]]\n" +
...     "[      ├─TableReader_25 1.00 root data:Selection_24]\n" +
...     "[      │ └─Selection_24 1.00 cop eq(s.a, test.t.a)]\n" +
...     "[      │   └─TableScan_23 10.00 cop table:s, range:[-inf,+inf], keep order:false]\n" +
...     "[      └─TableReader_27 10.00 root data:TableScan_26]\n" +
...     "[        └─TableScan_26 10.00 cop table:t1, range:[-inf,+inf], keep order:false]\n"
... sql:explain select t.c in (select count(*) from t s , t t1 where s.a = t.a and s.a = t1.a) from t;, args:[]

Check List

Tests

  • Existing tests.

Code changes

  • Has exported function/method change

Copy link
Contributor

@alivxxx alivxxx left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@zhexuany zhexuany left a comment

Choose a reason for hiding this comment

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

LGTM

@zhexuany zhexuany merged commit f18176f into pingcap:master Aug 15, 2018
@winoros winoros deleted the testkit branch September 5, 2018 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants