Skip to content

Commit

Permalink
TSQL: support for DROP EXTERNAL TABLE (#4919)
Browse files Browse the repository at this point in the history
  • Loading branch information
keen85 authored Jun 12, 2023
1 parent 09d8b69 commit bfbd9e8
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/sqlfluff/dialects/dialect_tsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ class StatementSegment(ansi.StatementSegment):
Ref("SqlcmdCommandSegment"),
Ref("CreateExternalFileFormat"),
Ref("CreateExternalTableStatementSegment"),
Ref("DropExternalTableStatementSegment"),
],
remove=[
Ref("CreateModelStatementSegment"),
Expand Down Expand Up @@ -5597,3 +5598,18 @@ class CreateRoleStatementSegment(ansi.CreateRoleStatementSegment):
optional=True,
),
)


class DropExternalTableStatementSegment(BaseSegment):
"""A `DROP EXTERNAL TABLE ...` statement.
https://learn.microsoft.com/en-us/sql/t-sql/statements/drop-external-table-transact-sql
"""

type = "drop_external_table_statement"
match_grammar = Sequence(
"DROP",
"EXTERNAL",
"TABLE",
Ref("TableReferenceSegment"),
)
7 changes: 7 additions & 0 deletions test/fixtures/dialects/tsql/drop_external_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
https://learn.microsoft.com/en-us/sql/t-sql/statements/drop-external-table-transact-sql?view=sql-server-ver16#examples
*/

DROP EXTERNAL TABLE SalesPerson;
DROP EXTERNAL TABLE dbo.SalesPerson;
DROP EXTERNAL TABLE EasternDivision.dbo.SalesPerson;
38 changes: 38 additions & 0 deletions test/fixtures/dialects/tsql/drop_external_table.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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: 7d546bbd3f07452542aa466df7d6a782e74f556f200487bafe3bf1a8c3af2dc3
file:
batch:
- statement:
drop_external_table_statement:
- keyword: DROP
- keyword: EXTERNAL
- keyword: TABLE
- table_reference:
naked_identifier: SalesPerson
- statement_terminator: ;
- statement:
drop_external_table_statement:
- keyword: DROP
- keyword: EXTERNAL
- keyword: TABLE
- table_reference:
- naked_identifier: dbo
- dot: .
- naked_identifier: SalesPerson
- statement_terminator: ;
- statement:
drop_external_table_statement:
- keyword: DROP
- keyword: EXTERNAL
- keyword: TABLE
- table_reference:
- naked_identifier: EasternDivision
- dot: .
- naked_identifier: dbo
- dot: .
- naked_identifier: SalesPerson
- statement_terminator: ;

0 comments on commit bfbd9e8

Please sign in to comment.