Skip to content

Add REFRESH and MATERIALIZED keywords#836

Open
RamiNoodle733 wants to merge 2 commits intoandialbrecht:masterfrom
RamiNoodle733:fix-refresh-keyword-797
Open

Add REFRESH and MATERIALIZED keywords#836
RamiNoodle733 wants to merge 2 commits intoandialbrecht:masterfrom
RamiNoodle733:fix-refresh-keyword-797

Conversation

@RamiNoodle733
Copy link

Fixes #797

This PR adds support for the REFRESH keyword to enable proper detection of REFRESH MATERIALIZED VIEW queries.

Changes:

  • Add REFRESH as a DDL keyword so get_type() returns 'REFRESH' for REFRESH statements
  • Add MATERIALIZED keyword for complete support
  • Add test case for REFRESH query type detection

Example:

import sqlparse
query = 'REFRESH MATERIALIZED VIEW order_summary;'
parsed = sqlparse.parse(query)[0]
print(parsed.get_type())  # Now returns 'REFRESH' instead of 'UNKNOWN'

RamiR and others added 2 commits February 6, 2026 01:17
The installation instructions had 'tar cvfz' which creates an archive,
but it should be 'tar xvfz' to extract the downloaded archive.

- Changed 'cvfz' (create) to 'xvfz' (extract)
- Add REFRESH as a DDL keyword so get_type() returns 'REFRESH' for
  REFRESH MATERIALIZED VIEW queries
- Add MATERIALIZED keyword for complete support
- Add test case for REFRESH query type detection
Copilot AI review requested due to automatic review settings February 6, 2026 08:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for the REFRESH keyword to enable proper detection of REFRESH MATERIALIZED VIEW queries, addressing issue #797. The PR correctly identifies REFRESH as a DDL keyword and adds MATERIALIZED as a regular keyword. Additionally, it includes an unrelated documentation fix for a typo in the tar command.

Changes:

  • Added REFRESH as a DDL keyword in keywords.py for query type detection
  • Added MATERIALIZED keyword to support REFRESH MATERIALIZED VIEW syntax
  • Added test case to verify REFRESH query type returns correctly
  • Fixed typo in documentation (tar command from cvfz to xvfz)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
sqlparse/keywords.py Added REFRESH (DDL) and MATERIALIZED keywords, but both are placed incorrectly alphabetically
tests/test_grouping.py Added test case for REFRESH keyword detection following existing test patterns
docs/source/intro.rst Fixed tar command typo from create (cvfz) to extract (xvfz)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

'REPEATABLE': tokens.Keyword,
'RESET': tokens.Keyword,
'RESOURCE': tokens.Keyword,
'REFRESH': tokens.Keyword.DDL,
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The REFRESH keyword is placed incorrectly in the alphabetical order. It should come after REFERENCING (line 466) and before REINDEX (line 467), not after RESOURCE. Maintaining alphabetical order makes the dictionary easier to navigate and maintain.

Copilot uses AI. Check for mistakes.
'MAP': tokens.Keyword,
'MATCH': tokens.Keyword,
'MAXEXTENTS': tokens.Keyword,
'MATERIALIZED': tokens.Keyword,
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The MATERIALIZED keyword is placed incorrectly in the alphabetical order. It should come before MAXEXTENTS (line 362), not after it. The letter 'T' in MATERIALIZED comes before 'X' in MAXEXTENTS alphabetically. Maintaining alphabetical order makes the dictionary easier to navigate and maintain.

Copilot uses AI. Check for mistakes.
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.

Support detection of REFRESH queries

1 participant