LucaCappelletti94 opened a new pull request, #2682: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2682
SQLite lets most keywords serve as names: its grammar declares a `%fallback ID` list (https://sqlite.org/src/file?name=src/parse.y) and its keyword page describes the fallback (https://www.sqlite.org/lang_keywords.html). So `SELECT a view FROM t` or `SELECT 1 offset` alias the column as `view` or `offset`, and SQLite 3.51.1 runs them. The SQLite dialect rejected 13 such keywords as implicit aliases: `ANALYZE`, `CLUSTER`, `DISTRIBUTE`, `EXCLUDE`, `EXPLAIN`, `FETCH`, `LATERAL`, `MINUS`, `OFFSET`, `SORT`, `TOP`, `VIEW` and `WITH`. In order to add support for these, `SQLiteDialect` now overrides `is_column_alias` and only refuses the keywords that start the next clause (`FROM`, `WHERE`, `GROUP`, `ORDER`, `LIMIT`, the set operators, `RETURNING`, `VALUES`, `INTO`, `SELECT`). SQLite also only reads `OVER` as a keyword when `(` or a name follows (`analyzeOverKeyword` in https://sqlite.org/src/file?name=src/tokenize.c), so `SELECT f() OVER` aliases the result as `OVER`. A new dialect method, `supports_over_keyword_as_column_alias`, enables that for SQLite. Run against every keyword in this crate, as `SELECT 1 <kw>` and `SELECT 1 <kw> FROM t`, the SQLite dialect now matches SQLite on 26 more forms and accepts nothing new that SQLite rejects. Two common tests that relied on `WITH` and `FETCH` ending a select list now skip SQLite. -- 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]
