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

Postgres: Views and named notations #4073

Merged
merged 3 commits into from Nov 17, 2022
Merged

Conversation

davetapley
Copy link
Contributor

@davetapley davetapley commented Nov 16, 2022

Brief summary of the change made

Add support for conventions used by https://github.com/timescale/timescaledb:

Fixes #4072
Fixes #4074

Since I was in there anyway:

Fixes #4069

Are there any other side effects of this change that we should be aware of?

Pull Request checklist

  • Please confirm you have completed any of the necessary steps below.

  • Included test cases to demonstrate any code changes, which may be one or more of the following:

    • .yml rule test cases in test/fixtures/rules/std_rule_cases.
    • .sql/.yml parser test cases in test/fixtures/dialects (note YML files can be auto generated with tox -e generate-fixture-yml).
    • Full autofix test cases in test/fixtures/linter/autofix.
    • Other.
  • Added appropriate documentation for the change.

  • Created GitHub issues for any relevant followup/future enhancements if appropriate.

@davetapley davetapley changed the title Two fixes for CREATE MATERIALIZED VIEW Three fixes for CREATE MATERIALIZED VIEW Nov 16, 2022
@davetapley davetapley changed the title Three fixes for CREATE MATERIALIZED VIEW Three fixes for Postgres Nov 16, 2022
@greg-finley
Copy link
Contributor

@davetapley could you allow edits from maintainers on your next PR? We need to keep the branch up to date before we can merge.

@greg-finley
Copy link
Contributor

@codecov
Copy link

codecov bot commented Nov 17, 2022

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (2bb9b60) compared to base (fe77193).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #4073   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          191       191           
  Lines        14718     14722    +4     
=========================================
+ Hits         14718     14722    +4     
Impacted Files Coverage Δ
src/sqlfluff/dialects/dialect_postgres.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jonatas
Copy link

jonatas commented Nov 17, 2022

Maybe it worth to mention that it supports the Timescaledb in the dialects supported session?

@davetapley
Copy link
Contributor Author

Maybe it worth to mention that it supports the Timescaledb in the dialects supported session?

@jonatas I'm not sure, since Timescaledb is really just a Postgres extension. Unless it has any of its own syntax?

@greg-finley
Copy link
Contributor

Also, most people will just merge in main or push further commits based on feedback, instead of force-pushing. It's a bit easier to review that way.

@davetapley
Copy link
Contributor Author

@greg-finley whoops, sorry about that. Linters run and rebased.

Copy link
Contributor

@greg-finley greg-finley left a comment

Choose a reason for hiding this comment

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

Good start! Just a few minor things.

@@ -2029,6 +2043,7 @@ class CreateMaterializedViewStatementSegment(BaseSegment):

match_grammar = Sequence(
"CREATE",
Sequence("OR", "REPLACE", optional=True),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Sequence("OR", "REPLACE", optional=True),
Ref("OrReplaceGrammar", optional=True),


CREATE OR REPLACE MATERIALIZED VIEW my_mat_view AS
SELECT a
FROM my_table;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add newlines at end of files. Your IDE probably has a setting.

@greg-finley greg-finley changed the title Three fixes for Postgres Postgres: Views and named notations Nov 17, 2022
Copy link
Contributor

@greg-finley greg-finley left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution and for working through the feedback! 🎉

@greg-finley greg-finley merged commit 7f04ace into sqlfluff:main Nov 17, 2022
@jonatas
Copy link

jonatas commented Nov 18, 2022

You're right @davetapley ! yeah, Timescaledb doesn't offers any dialect change.

I was thinking more on creating specific linters to Timescaledb functions, like when you create a refresh policy with interval smaller than the time_bucket, it would be great to just warn about it, but it would be necessary to have access to the time_bucket used in the view, so, probably worth to make it like a warning inside the function itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants