LucaCappelletti94 opened a new pull request, #2586: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2586
Since #1793, `x IN ((SELECT a FROM u), 1)` fails with `Expected: ), found: ,`. `parse_in` takes any query it can read after `IN (` as the whole subquery, so a list whose first item is a parenthesized scalar subquery never reaches the list branch, but they are valid Postgres and SQLite syntax. The speculative subquery now only counts when `)` follows it, and otherwise the parser rewinds and reads a list, so `IN ((SELECT a FROM u))` and the `UNION` case from #1793 still produce `InSubquery`. Since this type of recursions sometimes scale horribly, I double checked to verify the scalability and seems rather clean, expecially when compared to the current main. ### Case accepted by current main | depth | SQL length (chars) | `main` | rewind | branch | |---:|---:|---:|---:|---:| | 4 | 108 | 0.10 ms | 0.13 ms | 0.08 ms | | 8 | 208 | 1.8 ms | 1.6 ms | 0.20 ms | | 12 | 308 | 24 ms | 23 ms | 0.52 ms | | 16 | 408 | 368 ms | 373 ms | 0.77 ms | | 20 | 508 | 6 114 ms | 5 930 ms | 1.0 ms | | 24 | 608 | > 60 s, killed | > 60 s, killed | 1.5 ms | | 32 | 808 | not run | not run | 2.8 ms | | 64 | 1 608 | not run | not run | 9.1 ms | | 128 | 3 208 | not run | not run | 32.6 ms | ### Case rejected by current main | depth | SQL length (chars) | `main` | rewind | branch | |---:|---:|---:|---:|---:| | 4 | 84 | 0.02 ms, rejected | 0.08 ms | 0.06 ms | | 8 | 160 | 0.07 ms, rejected | 1.3 ms | 0.14 ms | | 12 | 236 | 0.13 ms, rejected | 20 ms | 0.31 ms | | 16 | 312 | 0.19 ms, rejected | 298 ms | 0.53 ms | | 20 | 388 | 0.32 ms, rejected | 4 925 ms | 0.79 ms | | 24 | 464 | 0.41 ms, rejected | > 60 s, killed | 1.1 ms | | 32 | 616 | 0.70 ms, rejected | not run | 2.4 ms | | 64 | 1 224 | 2.6 ms, rejected | not run | 6.4 ms | | 128 | 2 440 | 10.3 ms, rejected | not run | 23.8 ms | -- 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]
