VOID 001
10/21/2025, 1:02 PMMalcolm Greaves
10/21/2025, 6:16 PMMalcolm Greaves
10/21/2025, 6:19 PMtable. I'm not actually sure off the top of my head. But, if you're pushing a PR for this fix, then it would be good to have unit tests added that check various FROM xyz forms to make sure that it works for more than just the FROM table case.VOID 001
10/22/2025, 2:43 AMVOID 001
10/22/2025, 3:17 AMtable = daft.read_json("/path/to/json")
result = daft.sql("SELECT * FROM table")
will result in an error message
daft.exceptions.InvalidSQLException: failed to parse sql: sql parser error: Expected: (, found: EOF
After a little bit investigation it shows that the problem is inside /src/daft-sql/src/planner.rs, Which failed inside the `sqlparser:parser:Parser.parse_statements`(its a third party library)
So I think ideally the SELECT FROM xyz case should behave:
1. If the expression cannot pass the Parser, and it contains FROM KEYWORD, throw an error message "KEYWORD is a SQL keyword, not a valid table name"
2. If the expression can pass the Parser, and the table is not exist, just throw "Table not found table_name"
Now (2) is already implemented and acted correctly. I think we only need to fix the (1) case.
So I will fix (1) and add FROM xyz unit tests for the patch. LMK if I have anything wrong.Malcolm Greaves
10/22/2025, 8:43 PMVOID 001
10/23/2025, 12:27 PMSELECT * FROM data which DATA is also a keyword in sql. (image attached)
Previously the test can pass , but after the fix since "data" is also a keyword token, it will fail the test
Then I tried all "SELECT * FROM keyword" combination with the original version of daft sql. I found that there are a lot of keywords that will return "table not found" which means it passed the parser
For example : "SELECT FROM SELECT" will result in
sql: SELECT * FROM SELECT error: Table not found: SELECT
A full list can be found here: https://pastebin.com/5rMv3Twq
Also I note that this is different with PGSQL or MySQL.
So I will only check if it match the following case, then throw the error message
sql: SELECT * FROM END_EXEC = "END-EXEC" error: failed to parse sql: sql parser error: Expected: end of statement, found: =
sql: SELECT * FROM LATERAL error: failed to parse sql: sql parser error: Expected: identifier, found: EOF
sql: SELECT * FROM TABLE error: failed to parse sql: sql parser error: Expected: (, found: EOF
sql: SELECT * FROM UNNEST error: failed to parse sql: sql parser error: Expected: (, found: EOF
I will submit the PR recentlyVOID 001
10/23/2025, 3:10 PM