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

planner: correct the generation of the field name #11324

Merged
merged 4 commits into from
Jul 23, 2019

Conversation

winoros
Copy link
Member

@winoros winoros commented Jul 18, 2019

What problem does this PR solve?

fix #11313

Also, this will help us remove the IsReferenced field in expression.Column.

What is changed and how it works?

*expression.Column may be generated from a simplified expression.
But one ast.ColumnNameExpr must refer to a column, though it may be a correlated column.
So check the ast instead of the expr.

Check List

Tests

  • Unit test

fields = rs.Fields()
c.Assert(fields[0].Column.Name.L, Equals, "if(1,c,c)")
// It's a compatibility issue. Should be empty instead.
c.Assert(fields[0].ColumnAsName.L, Equals, "if(1,c,c)")
Copy link
Member Author

Choose a reason for hiding this comment

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

This comptibility issue is separated work. #11323

@codecov
Copy link

codecov bot commented Jul 18, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@d47b655). Click here to learn what that means.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master   #11324   +/-   ##
=========================================
  Coverage          ?   81.69%           
=========================================
  Files             ?      424           
  Lines             ?    92294           
  Branches          ?        0           
=========================================
  Hits              ?    75395           
  Misses            ?    11596           
  Partials          ?     5303

@codecov
Copy link

codecov bot commented Jul 18, 2019

Codecov Report

Merging #11324 into master will decrease coverage by 0.1732%.
The diff coverage is 100%.

@@              Coverage Diff               @@
##           master     #11324        +/-   ##
==============================================
- Coverage   81.45%   81.2767%   -0.1733%     
==============================================
  Files         423        423                
  Lines       90771      90102       -669     
==============================================
- Hits        73933      73232       -701     
- Misses      11561      11573        +12     
- Partials     5277       5297        +20

@zz-jason zz-jason added sig/planner SIG: Planner type/bugfix This PR fixes a bug. needs-cherry-pick-2.1 labels Jul 18, 2019
}
if field.AsName.L != "" {
colName = field.AsName
func (b *PlanBuilder) buildProjectionFieldNameFromColumns(origField *ast.SelectField, colNameField *ast.ColumnNameExpr, c *expression.Column) (colName, origColName, tblName, origTblName, dbName model.CIStr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we set Schema and Table for ColumnNameExpr when building expression.Column from it? Thus we can remove c here which will make the code clearer.

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer not to change the ast's content 😂

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
Member Author

Choose a reason for hiding this comment

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

No, if there's no wild star. It's the original content.

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
Member Author

Choose a reason for hiding this comment

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

I think we don't need to change it for now. The logic of creating the field names will be rewritten in the following PRs.

@winoros winoros requested a review from XuHuaiyu July 19, 2019 05:42
@foreyes
Copy link
Contributor

foreyes commented Jul 19, 2019

/run-all-tests

@zz-jason
Copy link
Member

/run-common-test
/run-integration-common-test

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

@zz-jason zz-jason added status/all tests passed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 23, 2019
Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

LGTM

@winoros winoros merged commit c1a5e79 into pingcap:master Jul 23, 2019
@winoros winoros deleted the fix-column-name branch July 23, 2019 06:17
@sre-bot
Copy link
Contributor

sre-bot commented Jul 23, 2019

cherry pick to release-2.1 failed

@sre-bot
Copy link
Contributor

sre-bot commented Jul 23, 2019

cherry pick to release-3.0 in PR #11379

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner status/LGT1 Indicates that a PR has LGTM 1. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Outputing column name missing
5 participants