-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Conversation
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)") |
There was a problem hiding this comment.
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 Report
@@ Coverage Diff @@
## master #11324 +/- ##
=========================================
Coverage ? 81.69%
=========================================
Files ? 424
Lines ? 92294
Branches ? 0
=========================================
Hits ? 75395
Misses ? 11596
Partials ? 5303 |
Codecov Report
@@ 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 |
} | ||
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will not be changed.
Check https://github.com/pingcap/tidb/blob/master/planner/core/logical_plan_builder.go#L2119
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we can create a new ast.ColumnNameExpr
here?
https://github.com/pingcap/tidb/blob/master/planner/core/logical_plan_builder.go#L1889
There was a problem hiding this comment.
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.
/run-all-tests |
/run-common-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
cherry pick to release-2.1 failed |
cherry pick to release-3.0 in PR #11379 |
What problem does this PR solve?
fix #11313
Also, this will help us remove the
IsReferenced
field inexpression.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