-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat(static): initial syntax for static queries #3300
feat(static): initial syntax for static queries #3300
Conversation
The change contains only the syntax changes to allow queries to have one of the following: * EMIT CHANGES - marking it as continuous, outputting intermediate results * EMIT FINAL - marking it as continuous, outputting final results * WITH CHANGES - marking it as static, outputting intermediate results * WITH FINAL - marking it as static, outputting final results Persistent queries, (CSAS, CTAS + INSERT INTO), default to `EMIT CHANGES`. Bare queries, (SELECT * FROM X;), default to `WITH FINAL`. Presence of any of these is a no-op at the moment.
# Conflicts: # ksql-parser/src/main/java/io/confluent/ksql/parser/tree/Query.java # ksql-parser/src/test/java/io/confluent/ksql/parser/tree/QueryTest.java
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.
First pass - I think it mostly looks good. Don't love WITH
but I guess that's a comment for the KLIP. I'll take another pass after this sinks in.
ksql-parser/src/main/antlr4/io/confluent/ksql/parser/SqlBase.g4
Outdated
Show resolved
Hide resolved
High level question. We are going to wait on merging this until pending issues on the KLIP are resolved? |
Yes, we're going to merge - I've a tight deadline I need to meet. Change keywords later is a relatively small change, but I need some language constructs to start building test cases around. However, on reflection, I've reduced the syntax changes to the bare minimum required. |
As long as we are open to changing the syntax with a follow-on, it may be ok.. We still have not also resolved the concerns around breaking/non-breaking changes that @apurvam raised on the KLIP. |
I'm not aware of anything outstanding... |
# Conflicts: # ksql-engine/src/test/java/io/confluent/ksql/codegen/CodeGenRunnerTest.java
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.
LGTM! Thanks @big-andy-coates
Description
NOTE: this may not be the final syntax we go with, but it's good enough for now.
NOTE: Changed to have reduced scope to only the minimum required.
This PR contains the changes needed to add support for the new
EMIT CHANGES
clause. (Discussion on syntax in #3242).The
EMIT
is used to indicate the query is continuous, as opposed to the proposedYIELD
which will indicate its static. (NoteYIELD
is not included in this PR.)The
CHANGES
is used to indicate the query outputs intermediate results, as opposed to the proposedFINAL
which would output materialized results, or other extensions to express other ways of materializing. (Note:FINAL
is not included in this PR).Persistent queries, (CSAS, CTAS + INSERT INTO), default to
EMIT CHANGES
.Bare queries, (SELECT * FROM X;), default to
YIELD FINAL
.Presence of any of these is a no-op at the moment. A follow up PR will wire up functionality.
Some example queries this syntax supports, (note: this doesn't mean we're implementing them initially!):
Backwards compatibility:
With this change:
SELECT * FROM X;
are not backwards compatible. You'll need to addEMIT STREAM
on the end to get the same behaviour. However, such queries are not persisted in the command topic, so this is not so much of an issueEMIT CHANGES
a requirement as part of our next major version bump.Commit history:
I would strongly advise reviewing by-commit
SqlFormatter
to supportEMIT
andWITH
syntax.WITH
to use ofYIELD
.EMIT CHANGES
.Testing done
Added suitable tests to
AstBuilderTest
.Reviewer checklist