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

Grammar: Add LOAD statement to Postgres dialect #2183

Merged
merged 2 commits into from Dec 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/sqlfluff/dialects/dialect_postgres.py
Expand Up @@ -2764,6 +2764,7 @@ class StatementSegment(BaseSegment):
Ref("DropDatabaseStatementSegment"),
Ref("AlterFunctionStatementSegment"),
Ref("AlterViewStatementSegment"),
Ref("LoadStatementSegment"),
],
)

Expand Down Expand Up @@ -3054,3 +3055,17 @@ class DropPolicyStatementSegment(BaseSegment):
Ref("TableReferenceSegment"),
OneOf("CASCADE", "RESTRICT", optional=True),
)


@postgres_dialect.segment()
class LoadStatementSegment(BaseSegment):
"""A `LOAD` statement.

As Specified in https://www.postgresql.org/docs/14/sql-load.html
"""

type = "load_statement"
match_grammar = Sequence(
"LOAD",
Ref("QuotedLiteralSegment"),
)
2 changes: 2 additions & 0 deletions test/fixtures/dialects/postgres/postgres_load.sql
@@ -0,0 +1,2 @@
LOAD 'funzioniGDB.so';
LOAD '/some/path/funzioniGDB.so';
17 changes: 17 additions & 0 deletions test/fixtures/dialects/postgres/postgres_load.yml
@@ -0,0 +1,17 @@
# YML test files are auto-generated from SQL files and should not be edited by
# hand. To help enforce this, the "hash" field in the file must match a hash
# computed by SQLFluff when running the tests. Please run
# `python test/generate_parse_fixture_yml.py` to generate them after adding or
# altering SQL files.
_hash: 552fd1d751752cf3ff213ac044fe72154b22be3497ddf49eef5ac1ef06c1c598
file:
- statement:
load_statement:
keyword: LOAD
literal: "'funzioniGDB.so'"
- statement_terminator: ;
- statement:
load_statement:
keyword: LOAD
literal: "'/some/path/funzioniGDB.so'"
- statement_terminator: ;