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

sql-parser: align SUBSCRIBE syntax with CREATE SINK/SELECT #29356

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

benesch
Copy link
Member

@benesch benesch commented Sep 3, 2024

The "output options" for SUBSCRIBE (i.e., the ENVELOPE and WITHIN TIMESTAMP ORDER BY clauses) were jammed in at the end of the statement, as in:

SUBSCRIBE t WITH (SNAPSHOT) AS OF 1 UP TO 2 ENVELOPE UPSERT KEY (a)

This was inconsistent with our other SQL statements. In particular, CREATE SOURCE and CREATE SINK always put the WITH options at the very end of the statement:

CREATE SINK ... WITH (SNAPSHOT)

And SELECT always puts the AS OF clause at the very end of the statement:

SELECT * FROM t WHERE ... AS OF 1

This commit restores the consistency that used to be present in SUBSCRIBE by moving the output options to before the AS OF, UP TO, and WITH options:

SUBSCRIBE t ENVELOPE UPSERT KEY (a) WITH (SNAPSHOT) AS OF 1 UP TO 2

The old syntax remains supported for backwards compatibility, but is softly deprecated. Only the new syntax will be mentioned in the docs going forward.

Motivation

Tips for reviewer

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.

The "output options" for `SUBSCRIBE` (i.e., the `ENVELOPE` and `WITHIN
TIMESTAMP ORDER BY` clauses) were jammed in at the end of the statement,
as in:

    SUBSCRIBE t WITH (SNAPSHOT) AS OF 1 UP TO 2 ENVELOPE UPSERT KEY (a)

This was inconsistent with our other SQL statements. In particular,
CREATE SOURCE and CREATE SINK always put the WITH options at the very
end of the statement:

    CREATE SINK ... WITH (SNAPSHOT)

And SELECT always puts the AS OF clause at the very end of the
statement:

    SELECT * FROM t WHERE ... AS OF 1

This commit restores the consistency that used to be present in
`SUBSCRIBE` by moving the output options to *before* the `AS OF`, `UP
TO`, and `WITH` options:

    SUBSCRIBE t ENVELOPE UPSERT KEY (a) WITH (SNAPSHOT) AS OF 1 UP TO 2

The old syntax remains supported for backwards compatibility, but is
softly deprecated. Only the new syntax will be mentioned in the docs
going forward.
@benesch benesch requested review from a team as code owners September 3, 2024 21:02
@benesch benesch enabled auto-merge September 4, 2024 02:30
@benesch benesch merged commit 44e7087 into MaterializeInc:main Sep 4, 2024
85 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Sep 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants