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

parser: implement Restore for SelectStmt #153

Merged
merged 11 commits into from
Jan 13, 2019
Merged

parser: implement Restore for SelectStmt #153

merged 11 commits into from
Jan 13, 2019

Conversation

AndrewDi
Copy link
Contributor

@AndrewDi AndrewDi commented Jan 5, 2019

implement Restore for SelectStmt
implement Restore for UnionSelectList
implement Restore for SubqueryExpr
implement Restore for CompareSubqueryExpr
implement Restore for TableOptimizerHint

Add SelectStmt test case, the rest would be add soon, too many test case.

Issue: pingcap/tidb#8532

@kennytm
Copy link
Contributor

kennytm commented Jan 5, 2019

Thanks for the contribution! As TableOptimizerHint is already handled by @exialin in #151, could one of you back out the change?

@AndrewDi
Copy link
Contributor Author

AndrewDi commented Jan 5, 2019

@kennytm You can free to choose one, I implement it only because SelectStmt contains it.

@exialin
Copy link
Contributor

exialin commented Jan 5, 2019

@AndrewDi Since you've resolved the problem, it is better to include TableOptimizerHint in this PR. #151 can be closed later.

ast/dml.go Outdated Show resolved Hide resolved
@AndrewDi
Copy link
Contributor Author

AndrewDi commented Jan 6, 2019

@kennytm @leoppro Almost all the SELECT statement test case I have found in Parser_test has been added, But it still have one restore problem here:

parser/parser_test.go

Lines 1430 to 1447 in d8e164f

{`select .78+123`, true, ""},
{`select .78+.21`, true, ""},
{`select .78-123`, true, ""},
{`select .78-.21`, true, ""},
{`select .78--123`, true, ""},
{`select .78*123`, true, ""},
{`select .78*.21`, true, ""},
{`select .78/123`, true, ""},
{`select .78/.21`, true, ""},
{`select .78,123`, true, ""},
{`select .78,.21`, true, ""},
{`select .78 , 123`, true, ""},
{`select .78.123`, false, ""},
{`select .78#123`, true, ""}, // select .78
{`insert float_test values(.67, 'string');`, true, ""},
{`select .78'123'`, true, ""}, // select .78 as '123'
{"select .78`123`", true, ""}, // select .78 as `123`
{`select .78"123"`, true, ""}, // select .78 as "123"

If we restore a statement like SELECT .78, output would become SELECT 0.78, so the MyDeciaml's digitsInt will change from 0 to 1, DeepEquals will fail.

Besides SELECT WITH Exists Clause test case should add after #126 merged.

@zier-one
Copy link
Contributor

zier-one commented Jan 7, 2019

@kennytm @leoppro Almost all the SELECT statement test case I have found in Parser_test has been added, But it still have one restore problem here:
parser/parser_test.go

Lines 1430 to 1447 in d8e164f

{select .78+123, true, ""},
{select .78+.21, true, ""},
{select .78-123, true, ""},
{select .78-.21, true, ""},
{select .78--123, true, ""},
{select .78*123, true, ""},
{select .78*.21, true, ""},
{select .78/123, true, ""},
{select .78/.21, true, ""},
{select .78,123, true, ""},
{select .78,.21, true, ""},
{select .78 , 123, true, ""},
{select .78.123, false, ""},
{select .78#123, true, ""}, // select .78
{insert float_test values(.67, 'string');, true, ""},
{select .78'123', true, ""}, // select .78 as '123'
{"select .78123", true, ""}, // select .78 as 123
{select .78"123", true, ""}, // select .78 as "123"

If we restore a statement like SELECT .78, output would become SELECT 0.78, so the MyDeciaml's digitsInt will change from 0 to 1, DeepEquals will fail.
Besides SELECT WITH Exists Clause test case should add after #126 merged.

could you handle this by updating CleanNodeText

@AndrewDi
Copy link
Contributor Author

AndrewDi commented Jan 7, 2019

this attr could not update now ...

@AndrewDi
Copy link
Contributor Author

@leoppro PTAL, use another way to deal with Decimal type.

@zier-one zier-one removed the WIP label Jan 12, 2019
ast/dml.go Outdated Show resolved Hide resolved
ast/dml.go Outdated Show resolved Hide resolved
ast/dml.go Outdated Show resolved Hide resolved
ast/dml.go Show resolved Hide resolved
ast/functions.go Outdated Show resolved Hide resolved
ast/functions.go Outdated Show resolved Hide resolved
ast/functions.go Outdated Show resolved Hide resolved
Copy link
Contributor

@zier-one zier-one left a comment

Choose a reason for hiding this comment

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

LGTM

@zier-one zier-one added the status/LGT1 LGT1 label Jan 13, 2019
@zier-one
Copy link
Contributor

@kennytm PTAL

ast/expressions.go Outdated Show resolved Hide resolved
ast/misc.go Outdated Show resolved Hide resolved
@AndrewDi
Copy link
Contributor Author

@kennytm Comment handled

Copy link
Contributor

@kennytm kennytm left a comment

Choose a reason for hiding this comment

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

Lgtm

@zier-one zier-one added status/LGT2 LGT2 and removed status/LGT1 LGT1 labels Jan 13, 2019
@zier-one zier-one merged commit 4e3eff2 into pingcap:master Jan 13, 2019
@AndrewDi AndrewDi deleted the ast2sql/selectstmt branch January 14, 2019 12:04
tiancaiamao pushed a commit to tiancaiamao/parser that referenced this pull request Apr 27, 2021
lyonzhi pushed a commit to lyonzhi/parser that referenced this pull request Apr 25, 2024
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