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

*: remove FromID from expression.Column #7157

Merged
merged 6 commits into from
Jul 30, 2018
Merged

Conversation

winoros
Copy link
Member

@winoros winoros commented Jul 25, 2018

What have you changed? (mandatory)

Remove the FromID from expression.Column.

What is the type of the changes? (mandatory)

  • Refactor

How has this PR been tested? (mandatory)

existing test.

@winoros
Copy link
Member Author

winoros commented Jul 25, 2018

/run-all-tests

@winoros
Copy link
Member Author

winoros commented Jul 25, 2018

/run-integration-ddl-test

@winoros
Copy link
Member Author

winoros commented Jul 25, 2018

/run-sqllogic-test

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.

Could you also update the comment for Position?

@@ -169,14 +169,13 @@ func (a *aggregationOptimizer) checkValidJoin(join *LogicalJoin) bool {

// decompose splits an aggregate function to two parts: a final mode function and a partial mode function. Currently
// there are no differences between partial mode and complete mode, so we can confuse them.
func (a *aggregationOptimizer) decompose(aggFunc *aggregation.AggFuncDesc, schema *expression.Schema, id int) ([]*aggregation.AggFuncDesc, *expression.Schema) {
func (a *aggregationOptimizer) decompose(ctx sessionctx.Context, aggFunc *aggregation.AggFuncDesc, schema *expression.Schema, id int) ([]*aggregation.AggFuncDesc, *expression.Schema) {
Copy link
Contributor

Choose a reason for hiding this comment

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

id is not used?

return s.colID
}

// generateSchema will generate a schema for test. Used only in this file.
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, it is only used in schema_test.go.

@@ -337,6 +337,14 @@ func (ds *DataSource) convertToIndexScan(prop *requiredProp, path *accessPath) (
}
rowCount := path.countAfterAccess
cop := &copTask{indexPlan: is}
names1 := make([]string, 0, len(is.Columns))
names2 := make([]string, 0, len(is.Index.Columns))
Copy link
Contributor

Choose a reason for hiding this comment

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

What's their usage?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh it's for debugging.

@winoros
Copy link
Member Author

winoros commented Jul 26, 2018

/run-sqllogic-test

@winoros
Copy link
Member Author

winoros commented Jul 26, 2018

/run-all-tests

@zz-jason
Copy link
Member

@winoros please address the comments.

// Position means the position of this column that appears in the select fields.
// e.g. SELECT name as id , 1 - id as id , 1 + name as id, name as id from src having id = 1;
// There are four ids in the same schema, so you can't identify the column through the FromID and ColName.
// Position is the unique id of this column.
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need to comment for the difference between ID and Position.

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 will be done is the future, not this pr.

// FindColumnByName finds a column by its name.
func (s *Schema) FindColumnByName(name string) *Column {
for _, col := range s.Columns {
if col.ColName.L == name {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we take the DBName and TableName into consideration?

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, this is only used for datasource which only have one table.

// Position means the position of this column that appears in the select fields.
// e.g. SELECT name as id , 1 - id as id , 1 + name as id, name as id from src having id = 1;
// There are four ids in the same schema, so you can't identify the column through the FromID and ColName.
// Position is the unique id of this column.
Position int
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'll rename it to UniqueID or something after this pr.
I'll examine whether the ID of Column can be removed.

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
Copy link
Member

@XuHuaiyu @lamxTyler PTAL

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

@alivxxx alivxxx added the status/LGT2 Indicates that a PR has LGTM 2. label Jul 30, 2018
@alivxxx alivxxx merged commit f4f1692 into pingcap:master Jul 30, 2018
@winoros winoros deleted the remove-from-id branch August 8, 2018 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression sig/planner SIG: Planner status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants