-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
update field name #354
update field name #354
Conversation
@@ -144,12 +144,12 @@ func (*testResultFieldSuite) TestMain(c *C) { | |||
|
|||
// For GetFieldIndex | |||
f1 := &field.Field{ | |||
Expr: &expression.Ident{CIStr: model.NewCIStr("c1")}, | |||
Name: "a", | |||
Expr: &expression.Ident{CIStr: model.NewCIStr("c1")}, |
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.
Why use '&' herer but does not use '&' in the above test file?
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 don't see any other place not using "&" for expression.Ident.
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.
Value is kind of weird, Maybe we should change its function to use pointer.
Expr: expression.Value{Val: "c1+1"},
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.
+1, all expressions use pointer is better.
LGTM |
name = expr.String() | ||
} | ||
$$ = &field.Field{Expr: expr, Name: name} | ||
$$ = &field.Field{Expr: expr, AsName: name} |
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.
How about
$$ = &field.Field{
Expr: expression.Expr($1),
AsName: $2.(string)
}
seems needless to define variables.
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.
Em, seems no big different. :-)
LGTM |
Co-authored-by: kennytm <[email protected]>
…gcap#536) * fix tiflash rules constraints by introducing `TiFlashConstraints` in config (pingcap#354) Signed-off-by: iosmanthus <[email protected]> * introduce tiflash replica min count (pingcap#371) Co-authored-by: zzm <[email protected]> Signed-off-by: iosmanthus <[email protected]> * auto fix missing tiflash placment rules (pingcap#364) Signed-off-by: iosmanthus <[email protected]> * fix noop for setting tiflash replicas to 0 Signed-off-by: iosmanthus <[email protected]> --------- Signed-off-by: iosmanthus <[email protected]> Co-authored-by: zzm <[email protected]>
Use as name explicitly. Old code uses as name for field name, if has not, uses origin expression string instead. e,g,
select 1 as a
, we will use "a" as the field name,select 1
, we will use "1" as the field name.This mechanism is not proper for later field name handing in group by, order by or other clauses. e.g,
select t.c as "t.c" from t
, using the old way we cannot know "t.c" is an alia name or just expression representation. So now theGetField*
function in field package is complex and confused.I think we will use AsName in field struct explicitly, we will check AsName to see whether a field has an alias name or not, if no alias name, we can try to use expression representation then.