Skip to content

Commit

Permalink
fix: describe statements in duckdb
Browse files Browse the repository at this point in the history
  • Loading branch information
benfdking committed Nov 25, 2024
1 parent 1c53f6b commit 1bc2292
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
17 changes: 15 additions & 2 deletions crates/lib-dialects/src/duckdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn raw_dialect() -> Dialect {
.into(),
),
(
"SummarizeStatemenSegment".into(),
"SummarizeStatementSegment".into(),
Sequence::new(vec_of_erased![
Ref::keyword("SUMMARIZE"),
one_of(vec_of_erased![
Expand All @@ -85,6 +85,18 @@ pub fn raw_dialect() -> Dialect {
.to_matchable()
.into(),
),
(
"DescribeStatementSegment".into(),
Sequence::new(vec_of_erased![
Ref::keyword("DESCRIBE"),
one_of(vec_of_erased![
Ref::new("SingleIdentifierGrammar"),
Ref::new("SelectStatementSegment")
])
])
.to_matchable()
.into(),
),
]);

duckdb_dialect.insert_lexer_matchers(
Expand Down Expand Up @@ -207,7 +219,8 @@ pub fn raw_dialect() -> Dialect {
postgres::statement_segment().copy(
Some(vec_of_erased![
Ref::new("LoadStatementSegment"),
Ref::new("SummarizeStatemenSegment")
Ref::new("SummarizeStatementSegment"),
Ref::new("DescribeStatementSegment")
]),
None,
None,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DESCRIBE tbl;

DESCRIBE SELECT * FROM tbl;
22 changes: 22 additions & 0 deletions crates/lib-dialects/test/fixtures/dialects/duckdb/describe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
file:
- statement:
- keyword: DESCRIBE
- naked_identifier: tbl
- statement_terminator: ;
- statement:
- keyword: DESCRIBE
- select_statement:
- select_clause:
- keyword: SELECT
- select_clause_element:
- wildcard_expression:
- wildcard_identifier:
- star: '*'
- from_clause:
- keyword: FROM
- from_expression:
- from_expression_element:
- table_expression:
- table_reference:
- naked_identifier: tbl
- statement_terminator: ;

0 comments on commit 1bc2292

Please sign in to comment.