Skip to content

Commit

Permalink
Grammar: Add LOAD statement to Postgres dialect (#2183)
Browse files Browse the repository at this point in the history
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
  • Loading branch information
jpy-git and tunetheweb committed Dec 26, 2021
1 parent b900e9d commit 9d29af8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
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"),
Ref("ResetStatementSegment"),
Ref("DiscardStatementSegment"),
],
Expand Down Expand Up @@ -3058,6 +3059,20 @@ class DropPolicyStatementSegment(BaseSegment):
)


@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"),
)


@postgres_dialect.segment()
class ResetStatementSegment(BaseSegment):
"""A `RESET` statement.
Expand Down
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: ;

0 comments on commit 9d29af8

Please sign in to comment.