-
Notifications
You must be signed in to change notification settings - Fork 680
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
SELECT: Update EBNF for partitioning #17985
Conversation
JoinTable ::= | ||
( TableRef ( ("INNER" | "CROSS")? "JOIN" | "STRAIGHT_JOIN" ) TableFactor JoinClause? | ||
| TableRef ( ("LEFT" | "RIGHT") "OUTER"? "JOIN" ) TableRef JoinClause | ||
| TableRef "NATURAL" "INNER"? ("LEFT" | "RIGHT") "OUTER"? "JOIN" ) TableFactor |
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.
TiDB's parser.y is different from MySQL's grammar.
- it support the following combinations:
join type \ join clause | empty | ON expr | USING (columns) |
---|---|---|---|
('CROSS' | 'INNER')? 'JOIN' | ✓ | ✓ | ✓ |
('LEFT' | 'RIGHT') 'OUTER'? 'JOIN' | ✗ | ✓ | ✓ |
'NATURAL' (('LEFT' | 'RIGHT') 'OUTER'?)? 'JOIN' | ✓ | ✗ | ✗ |
'STRAIGHT_JOIN' | ✓ | ✓ | ❌ |
In particular t1 STRAIGHT_JOIN t2 USING (col)
is syntax error, incompatible with MySQL. This is probably a bug.
- The RHS of all join operations are all
TableRef
, notTableFactor
. - TiDB does not support the syntax
NATURAL INNER JOIN
, again incompatible with MySQL. Your current production also permits the nonsenseNATURAL INNER OUTER JOIN
. If we follow MySQL's rule it should has been'NATURAL' ('INNER' | ('LEFT' | 'RIGHT') 'OUTER'?)? 'JOIN'
.
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've filed pingcap/tidb#54162 for this
Co-authored-by: kennytm <kennytm@gmail.com>
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.
Approved with some requests and questions :)
@@ -31,7 +31,24 @@ SelectStmtOpts ::= | |||
SelectStmtStraightJoin | |||
|
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.
Please report an issue with:
SelectStmtBasic ::=
"SELECT" SelectStmtOpts Field ("," Field)* ( "HAVING" Expression)?
since SELECT * HAVING 1
does not parse.
Also in parser.y, SelectStmtBasic is the first part of SelectStmtFromTable...
But I assume this can all be addressed in a separate issue.
Most likely SelectStmtBasic should not have HavingClause, even in parser.y?
@@ -47,10 +64,19 @@ SelectLockOpt ::= | |||
TableList ::= | |||
TableName ( ',' TableName )* | |||
|
|||
WhereClause ::= | |||
"WHERE" Expression |
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.
Should the following 3 Expression
also include both names/aliases from fields and placement ids (column number)?
@mjonss: adding LGTM is restricted to approvers and reviewers in OWNERS files. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
hi @kennytm, would you please take a look at this PR again and approve it if no problem? Thanks. |
@qiancai No the generated EBNF is still wrong. |
@kennytm: adding LGTM is restricted to approvers and reviewers in OWNERS files. In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[LGTM Timeline notifier]Timeline:
|
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: qiancai The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What is changed, added or deleted? (Required)
Update EBNF for:
SELECT * FROM t1 PARTITION (p0);
Use https://kennytm.github.io/website-docs/dist/ for previewing the EBNF
Which TiDB version(s) do your changes apply to? (Required)
Tips for choosing the affected version(s):
By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.
For details, see tips for choosing the affected versions.
What is the related PR or file link(s)?
Do your changes match any of the following descriptions?