-
Notifications
You must be signed in to change notification settings - Fork 721
Add REFRESH keyword to KEYWORDS dictionary #834
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
Add REFRESH keyword to KEYWORDS dictionary #834
Conversation
Adds REFRESH to the KEYWORDS dictionary to enable proper recognition of REFRESH MATERIALIZED VIEW statements. Fixes #797
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.
Pull request overview
This PR attempts to add support for the REFRESH keyword to enable proper recognition of SQL statements like REFRESH MATERIALIZED VIEW, addressing issue #797 where such queries were being detected as 'UNKNOWN' type.
Changes:
- Adds 'REFRESH': tokens.Keyword to the KEYWORDS dictionary in sqlparse/keywords.py
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'REPEATABLE': tokens.Keyword, | ||
| 'REFRESH': tokens.Keyword, |
Copilot
AI
Feb 6, 2026
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.
The REFRESH keyword is placed after REPEATABLE, but alphabetically REFRESH should come before REPEATABLE. The keyword should be inserted between RENAME and REPEATABLE to maintain alphabetical order in the KEYWORDS dictionary.
| 'REPEATABLE': tokens.Keyword, | |
| 'REFRESH': tokens.Keyword, | |
| 'REFRESH': tokens.Keyword, | |
| 'REPEATABLE': tokens.Keyword, |
| 'RELATIVE': tokens.Keyword, | ||
| 'RENAME': tokens.Keyword, | ||
| 'REPEATABLE': tokens.Keyword, | ||
| 'REFRESH': tokens.Keyword, |
Copilot
AI
Feb 6, 2026
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.
The REFRESH keyword is being added to the wrong dictionary with the wrong token type. REFRESH MATERIALIZED VIEW is a Data Definition Language (DDL) operation similar to CREATE, ALTER, DROP, and TRUNCATE. It should be added to the KEYWORDS_COMMON dictionary (around line 684-687) as 'REFRESH': tokens.Keyword.DDL instead of being added to the main KEYWORDS dictionary. With the current implementation, the get_type() method will return 'UNKNOWN' for REFRESH statements, which doesn't address the issue described in #797 where the user expects the query type to be properly detected.
| 'REFRESH': tokens.Keyword, | |
| 'REFRESH': tokens.Keyword.DDL, |
| 'RELATIVE': tokens.Keyword, | ||
| 'RENAME': tokens.Keyword, | ||
| 'REPEATABLE': tokens.Keyword, | ||
| 'REFRESH': tokens.Keyword, |
Copilot
AI
Feb 6, 2026
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.
This PR adds a new keyword but does not include test coverage. Based on the test patterns in the codebase (e.g., tests/test_grouping.py:411-419 for get_type(), tests/test_regressions.py:345-356 for keyword verification), a test should be added to verify that REFRESH is properly recognized as a DDL keyword and that statements like 'REFRESH MATERIALIZED VIEW my_view' have get_type() return 'REFRESH' instead of 'UNKNOWN'.
Summary
Adds the REFRESH keyword to the KEYWORDS dictionary to enable proper recognition of SQL statements like
REFRESH MATERIALIZED VIEW.Changes
Testing
Fixes #797