This is an automated email from the ASF dual-hosted git repository. github-bot pushed a commit to branch gh-readonly-queue/main/pr-2238-d9b53a0cdb369124d9b6ce6237959e66bad859af in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
commit 982068ec51cbd60cb8489fb50286c344ba339e0c Author: Luca Cappelletti <[email protected]> AuthorDate: Wed Feb 25 15:01:39 2026 +0100 Add support for INTERVAL keyword as unquoted identifier in PostgreSQL (#2238) --- src/dialect/postgresql.rs | 10 ++++++++++ tests/sqlparser_postgres.rs | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/src/dialect/postgresql.rs b/src/dialect/postgresql.rs index 13bd82bf..0b7ed2a7 100644 --- a/src/dialect/postgresql.rs +++ b/src/dialect/postgresql.rs @@ -33,6 +33,8 @@ use crate::keywords::Keyword; use crate::parser::{Parser, ParserError}; use crate::tokenizer::Token; +use super::keywords::RESERVED_FOR_IDENTIFIER; + /// A [`Dialect`] for [PostgreSQL](https://www.postgresql.org/) #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] @@ -81,6 +83,14 @@ impl Dialect for PostgreSqlDialect { true } + fn is_reserved_for_identifier(&self, kw: Keyword) -> bool { + if matches!(kw, Keyword::INTERVAL) { + false + } else { + RESERVED_FOR_IDENTIFIER.contains(&kw) + } + } + /// See <https://www.postgresql.org/docs/current/sql-createoperator.html> fn is_custom_operator_part(&self, ch: char) -> bool { matches!( diff --git a/tests/sqlparser_postgres.rs b/tests/sqlparser_postgres.rs index 510f6ccc..7c19f51e 100644 --- a/tests/sqlparser_postgres.rs +++ b/tests/sqlparser_postgres.rs @@ -5777,6 +5777,12 @@ fn parse_interval_data_type() { } } +#[test] +fn parse_interval_keyword_as_unquoted_identifier() { + pg().verified_stmt("SELECT MAX(interval) FROM tbl"); + pg().verified_expr("INTERVAL '1 day'"); +} + #[test] fn parse_create_table_with_options() { let sql = "CREATE TABLE t (c INT) WITH (foo = 'bar', a = 123)"; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
