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

SELECT: Update EBNF for partitioning #17985

Merged
merged 6 commits into from
Aug 28, 2024

Conversation

dveeden
Copy link
Contributor

@dveeden dveeden commented Jun 21, 2024

What is changed, added or deleted? (Required)

Update EBNF for:

  • Partition selection: SELECT * FROM t1 PARTITION (p0);
  • Joins

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.

  • master (the latest development version)
  • v8.2 (TiDB 8.2 versions)
  • v8.1 (TiDB 8.1 versions)
  • v8.0 (TiDB 8.0 versions)
  • v7.6 (TiDB 7.6 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)
  • v6.1 (TiDB 6.1 versions)
  • v5.4 (TiDB 5.4 versions)
  • v5.3 (TiDB 5.3 versions)
  • v5.2 (TiDB 5.2 versions)
  • v5.1 (TiDB 5.1 versions)

What is the related PR or file link(s)?

  • This PR is translated from:
  • Other reference link(s):

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

@ti-chi-bot ti-chi-bot bot added missing-translation-status This PR does not have translation status info. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 21, 2024
sql-statements/sql-statement-select.md Outdated Show resolved Hide resolved
Comment on lines 43 to 46
JoinTable ::=
( TableRef ( ("INNER" | "CROSS")? "JOIN" | "STRAIGHT_JOIN" ) TableFactor JoinClause?
| TableRef ( ("LEFT" | "RIGHT") "OUTER"? "JOIN" ) TableRef JoinClause
| TableRef "NATURAL" "INNER"? ("LEFT" | "RIGHT") "OUTER"? "JOIN" ) TableFactor
Copy link
Contributor

@kennytm kennytm Jun 21, 2024

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.

  1. 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.

  1. The RHS of all join operations are all TableRef, not TableFactor.
  2. TiDB does not support the syntax NATURAL INNER JOIN, again incompatible with MySQL. Your current production also permits the nonsense NATURAL INNER OUTER JOIN. If we follow MySQL's rule it should has been 'NATURAL' ('INNER' | ('LEFT' | 'RIGHT') 'OUTER'?)? 'JOIN'.

Copy link
Contributor Author

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

sql-statements/sql-statement-select.md Outdated Show resolved Hide resolved
sql-statements/sql-statement-select.md Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 21, 2024
Co-authored-by: kennytm <kennytm@gmail.com>
Copy link
Contributor

@mjonss mjonss left a 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

Copy link
Contributor

@mjonss mjonss Jul 2, 2024

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

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)?

Copy link

ti-chi-bot bot commented Jul 2, 2024

@mjonss: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

Approved with some requests and questions :)

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.

@qiancai qiancai self-assigned this Aug 5, 2024
@qiancai qiancai added the translation/doing This PR's assignee is translating this PR. label Aug 5, 2024
@ti-chi-bot ti-chi-bot bot removed the missing-translation-status This PR does not have translation status info. label Aug 5, 2024
@qiancai qiancai added area/sql-infra Indicates that the Issue or PR belongs to the area of sql-infra and sql-metadata. type/enhancement The issue or PR belongs to an enhancement. labels Aug 5, 2024
@qiancai
Copy link
Collaborator

qiancai commented Aug 23, 2024

hi @kennytm, would you please take a look at this PR again and approve it if no problem? Thanks.

@kennytm
Copy link
Contributor

kennytm commented Aug 23, 2024

@qiancai No the generated EBNF is still wrong.

image

@dveeden
Copy link
Contributor Author

dveeden commented Aug 26, 2024

@qiancai No the generated EBNF is still wrong.

image

Fixed in 05ff289:
image

@qiancai
Copy link
Collaborator

qiancai commented Aug 26, 2024

@qiancai No the generated EBNF is still wrong.
image

Fixed in 05ff289: image

@kennytm PTAL. Thanks.

Copy link

ti-chi-bot bot commented Aug 26, 2024

@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.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 28, 2024
Copy link

ti-chi-bot bot commented Aug 28, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-28 07:00:13.125494077 +0000 UTC m=+940008.259944198: ☑️ agreed by qiancai.

@qiancai
Copy link
Collaborator

qiancai commented Aug 28, 2024

/approve

@qiancai qiancai added the lgtm label Aug 28, 2024
Copy link

ti-chi-bot bot commented Aug 28, 2024

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Aug 28, 2024
@qiancai qiancai added translation/done This PR has been translated from English into Chinese and updated to pingcap/docs-cn in a PR. and removed translation/doing This PR's assignee is translating this PR. labels Aug 28, 2024
@ti-chi-bot ti-chi-bot bot merged commit 5237e1b into pingcap:master Aug 28, 2024
8 of 9 checks passed
@qiancai qiancai removed the request for review from Oreoxmt August 28, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/sql-infra Indicates that the Issue or PR belongs to the area of sql-infra and sql-metadata. lgtm needs-1-more-lgtm Indicates a PR needs 1 more LGTM. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. translation/done This PR has been translated from English into Chinese and updated to pingcap/docs-cn in a PR. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants