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

Snowflake: Add implementation for CREATE TASK statement (#1597) #1603

Merged

Conversation

JoeHut
Copy link
Contributor

@JoeHut JoeHut commented Oct 12, 2021

Brief summary of the change made

Closes #1597

This PR adds an implementation for the CREATE TASK expression for the Snowflake dialect as described in the docs

CREATE [ OR REPLACE ] TASK [ IF NOT EXISTS ] <name>
  [ WAREHOUSE = <string> ]
  [ SCHEDULE = '{ <num> MINUTE | USING CRON <expr> <time_zone> }' ]
  [ ALLOW_OVERLAPPING_EXECUTION = TRUE | FALSE ]
  [ <session_parameter> = <value> [ , <session_parameter> = <value> ... ] ]
  [ USER_TASK_TIMEOUT_MS = <num> ]
  [ USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE = <string> ]
  [ COPY GRANTS ]
  [ COMMENT = '<string_literal>' ]
  [ AFTER <string> ]
[ WHEN <boolean_expr> ]
AS
  <sql>

Open questions/issues:

  • How to implement the WHEN clause?
  • SCHEDULE clause is implemented as literal string, not broken down further
  • Is the implementation of using a generic StatementSegment for the AS clause correct?

@JoeHut JoeHut force-pushed the feat/dialect/snowflake/create_task branch from 372abe7 to 8450623 Compare October 12, 2021 12:22
@JoeHut
Copy link
Contributor Author

JoeHut commented Oct 12, 2021

@tunetheweb, here is the PR. maybe you can help me out with the questions above.

Copy link
Member

@tunetheweb tunetheweb left a comment

Choose a reason for hiding this comment

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

Looks pretty good!

Feedback below:

src/sqlfluff/dialects/dialect_snowflake.py Outdated Show resolved Hide resolved
src/sqlfluff/dialects/dialect_snowflake.py Outdated Show resolved Hide resolved
src/sqlfluff/dialects/dialect_snowflake.py Show resolved Hide resolved
@tunetheweb
Copy link
Member

BTW run this to generate the YML file from the SQL fixtures:

python test/generate_parse_fixture_yml.py

@JoeHut JoeHut force-pushed the feat/dialect/snowflake/create_task branch 3 times, most recently from 3cdf37a to 66421a9 Compare October 12, 2021 14:39
@JoeHut JoeHut force-pushed the feat/dialect/snowflake/create_task branch from 66421a9 to cfbd222 Compare October 12, 2021 14:45
@codecov
Copy link

codecov bot commented Oct 12, 2021

Codecov Report

Merging #1603 (cfbd222) into main (c61003a) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main     #1603   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          131       131           
  Lines         9180      9184    +4     
=========================================
+ Hits          9180      9184    +4     
Impacted Files Coverage Δ
src/sqlfluff/dialects/dialect_snowflake.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c61003a...cfbd222. Read the comment docs.

Copy link
Member

@tunetheweb tunetheweb left a comment

Choose a reason for hiding this comment

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

LGTM!

This good to merge now or still working on it?

@JoeHut
Copy link
Contributor Author

JoeHut commented Oct 12, 2021

That would be good from my side. I still have some other failures, but those are unrelated so that will be a new PR in the next days probably

@tunetheweb tunetheweb merged commit 853ceef into sqlfluff:main Oct 12, 2021
@tunetheweb
Copy link
Member

Thank you! Hopefully this PR has encouraged you to (or at least hasn't discouraged you from!) adding more PRs

ttomasz pushed a commit to ttomasz/sqlfluff that referenced this pull request Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parsing "warehouse" and "schedule" in "create task" fails
2 participants