Skip to content

Commit

Permalink
Merge 7e31a66 into c5b87d9
Browse files Browse the repository at this point in the history
  • Loading branch information
benfdking authored Nov 23, 2024
2 parents c5b87d9 + 7e31a66 commit 5cfd613
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
79 changes: 79 additions & 0 deletions crates/lib-dialects/src/duckdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use sqruff_lib_core::parser::parsers::StringParser;
use sqruff_lib_core::parser::segments::meta::MetaSegment;
use sqruff_lib_core::vec_of_erased;

use crate::ansi;

pub fn dialect() -> Dialect {
raw_dialect().config(|dialect| dialect.expand())
}
Expand Down Expand Up @@ -60,6 +62,16 @@ pub fn raw_dialect() -> Dialect {
)
.into(),
),
(
"LoadStatement".into(),
Sequence::new(vec_of_erased![
Ref::keyword("LOAD"),
Ref::new("SingleIdentifierGrammar"),
Ref::new("SemicolonSegment")
])
.to_matchable()
.into(),
),
]);

duckdb_dialect.insert_lexer_matchers(
Expand Down Expand Up @@ -177,5 +189,72 @@ pub fn raw_dialect() -> Dialect {
.to_matchable(),
);

duckdb_dialect.replace_grammar(
"StatementSegment",
ansi::statement_segment().copy(
Some(vec_of_erased![
Ref::new("AlterDefaultPrivilegesStatementSegment"),
Ref::new("DropOwnedStatementSegment"),
Ref::new("ReassignOwnedStatementSegment"),
Ref::new("CommentOnStatementSegment"),
Ref::new("AnalyzeStatementSegment"),
Ref::new("CreateTableAsStatementSegment"),
Ref::new("AlterTriggerStatementSegment"),
Ref::new("SetStatementSegment"),
Ref::new("AlterPolicyStatementSegment"),
Ref::new("CreatePolicyStatementSegment"),
Ref::new("DropPolicyStatementSegment"),
Ref::new("CreateDomainStatementSegment"),
Ref::new("AlterDomainStatementSegment"),
Ref::new("DropDomainStatementSegment"),
Ref::new("CreateMaterializedViewStatementSegment"),
Ref::new("AlterMaterializedViewStatementSegment"),
Ref::new("DropMaterializedViewStatementSegment"),
Ref::new("RefreshMaterializedViewStatementSegment"),
Ref::new("AlterDatabaseStatementSegment"),
Ref::new("DropDatabaseStatementSegment"),
Ref::new("VacuumStatementSegment"),
Ref::new("AlterFunctionStatementSegment"),
Ref::new("CreateViewStatementSegment"),
Ref::new("AlterViewStatementSegment"),
Ref::new("ListenStatementSegment"),
Ref::new("NotifyStatementSegment"),
Ref::new("UnlistenStatementSegment"),
Ref::new("LoadStatementSegment"),
Ref::new("ResetStatementSegment"),
Ref::new("DiscardStatementSegment"),
Ref::new("AlterProcedureStatementSegment"),
Ref::new("CreateProcedureStatementSegment"),
Ref::new("DropProcedureStatementSegment"),
Ref::new("CopyStatementSegment"),
Ref::new("DoStatementSegment"),
Ref::new("AlterIndexStatementSegment"),
Ref::new("ReindexStatementSegment"),
Ref::new("AlterRoleStatementSegment"),
Ref::new("CreateExtensionStatementSegment"),
Ref::new("DropExtensionStatementSegment"),
Ref::new("CreatePublicationStatementSegment"),
Ref::new("AlterPublicationStatementSegment"),
Ref::new("DropPublicationStatementSegment"),
Ref::new("CreateTypeStatementSegment"),
Ref::new("AlterTypeStatementSegment"),
Ref::new("AlterSchemaStatementSegment"),
Ref::new("LockTableStatementSegment"),
Ref::new("ClusterStatementSegment"),
Ref::new("CreateCollationStatementSegment"),
Ref::new("CallStoredProcedureSegment"),
Ref::new("CreateServerStatementSegment"),
Ref::new("CreateUserMappingStatementSegment"),
Ref::new("ImportForeignSchemaStatementSegment"),
Ref::new("LoadStatement")
]),
None,
None,
None,
vec![],
false,
),
);

duckdb_dialect
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LOAD spatial;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
file:
- statement:
- keyword: LOAD
- naked_identifier: spatial
- statement_terminator: ;

0 comments on commit 5cfd613

Please sign in to comment.