From f642dd573cbf700b8591eeb9e1f6bf3ed8f98659 Mon Sep 17 00:00:00 2001 From: Ryan Schneider Date: Tue, 16 Sep 2025 11:25:24 -0700 Subject: [PATCH] DuckDB: Allow quoted date parts in EXTRACT (#2030) --- src/dialect/duckdb.rs | 5 +++++ tests/sqlparser_duckdb.rs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/dialect/duckdb.rs b/src/dialect/duckdb.rs index 37cf7d36..f08d827b 100644 --- a/src/dialect/duckdb.rs +++ b/src/dialect/duckdb.rs @@ -70,6 +70,11 @@ impl Dialect for DuckDbDialect { true } + /// Returns true if this dialect allows the `EXTRACT` function to use single quotes in the part being extracted. + fn allow_extract_single_quotes(&self) -> bool { + true + } + // DuckDB is compatible with PostgreSQL syntax for this statement, // although not all features may be implemented. fn supports_explain_with_utility_options(&self) -> bool { diff --git a/tests/sqlparser_duckdb.rs b/tests/sqlparser_duckdb.rs index 5bad7336..0f805195 100644 --- a/tests/sqlparser_duckdb.rs +++ b/tests/sqlparser_duckdb.rs @@ -869,3 +869,9 @@ fn test_duckdb_trim() { duckdb().parse_sql_statements(error_sql).unwrap_err() ); } + +#[test] +fn parse_extract_single_quotes() { + let sql = "SELECT EXTRACT('month' FROM my_timestamp) FROM my_table"; + duckdb().verified_stmt(sql); +}