Repository navigation
SQLite: Support IN with a table name or table-valued function - #2680
LucaCappelletti94 wants to merge 5 commits into
Conversation
d231a4c to
bd79005
Compare
bd79005 to
4cfa09d
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## in-expr-refactor #2680 +/- ##
====================================================
+ Coverage 81.33% 81.41% +0.08%
====================================================
Files 42 42
Lines 33957 34012 +55
Branches 33957 34012 +55
====================================================
+ Hits 27618 27692 +74
+ Misses 2775 2749 -26
- Partials 3564 3571 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
9ecae2c to
2e2304d
Compare
| InTarget::Unnest(Box::new(array_expr)) | ||
| } else if !global | ||
| && self.dialect.supports_in_table_expression() | ||
| && matches!(self.peek_token_ref().token, Token::Word(_)) |
There was a problem hiding this comment.
Any word is taken as the table name, so SELECT 1 IN FROM t parses and round-trips to SELECT 1 IN FROM AS t. Worth the same reserved-keyword check as the table factor position (is_table_factor, cf. #2633).
There was a problem hiding this comment.
is_table_factor with the shared list would still accept this one, since FROM is not in RESERVED_FOR_TABLE_FACTOR. I ran every keyword of the crate through SQLite 3.51.1 as SELECT 1 IN <kw>, and SQLite refuses 57 of them there, so now SQLiteDialect overrides is_table_factor with those, so SELECT 1 IN FROM t fails again.
Stacked on the
INrefactor PR.In SQLite "the right-hand side of an IN or NOT IN operator can be a table name or table-valued function name in which case the right-hand side is understood to be a subquery of the form
(SELECT * FROM name)" (https://www.sqlite.org/lang_expr.html#in_op). SQLite 3.51.1 runsSELECT 1 IN t,SELECT 1 NOT IN tandSELECT 1 IN main.t, but the SQLite dialect failed withExpected: (, found: t.InTargetgains aTable { name, args }variant, and a new dialect method,supports_in_table_expression, enables it for SQLite and the generic dialect. It does not apply to ClickHouse'sGLOBAL IN. Tests round-trip plain, qualified and function forms with and withoutNOT, check the parsed name and arguments, and check that parenthesized lists and subqueries still parse as before.