LucaCappelletti94 opened a new pull request, #2238: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2238
This PR fixes a PostgreSQL dialect parsing bug where `INTERVAL` was always treated as a reserved identifier keyword, causing valid queries such as: ```sql SELECT MAX(interval) FROM tbl ``` to fail with `Expected: an expression, found: )`. ## Problem In PostgreSQL, interval can be used as an unquoted identifier in unambiguous expression positions (for example function arguments). Our parser attempted INTERVAL-literal parsing first, and on failure it only fell back to identifier parsing when the keyword is not reserved. Because INTERVAL was reserved for `PostgreSqlDialect`, fallback was blocked. ## Fix - Added a PostgreSQL-specific override of `is_reserved_for_identifier` so `Keyword::INTERVAL` is not treated as reserved in this dialect. - Kept default reserved behavior for all other keywords unchanged. ## Tests Added regression test in PostgreSQL-specific suite: - `SELECT MAX(interval) FROM tbl` now parses successfully in PostgreSqlDialect. - `INTERVAL '1 day'` still parses as an interval expression (guarding against regressions). ## Impact - Improves compatibility with real-world PostgreSQL schemas where columns/args may be named interval. - No public API changes. - No cross-dialect behavior changes intended beyond PostgreSQL’s INTERVAL identifier handling. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
