You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the design policy, GenericDialect is intended to parse any SQL that other dialects can handle, but it currently fails to parse multi-table DELETE statements and DELETE statements without a FROM clause.
I think the expected behavior is that the following tests should also pass with GenericDialect.
let sql = "DELETE schema1.table1, schema2.table2 FROM schema1.table1 JOIN schema2.table2 ON schema2.table2.col1 = schema1.table1.col1 WHERE schema2.table2.col2 = 1";
let dialects = all_dialects_except(|d| d.is::<BigQueryDialect>() || d.is::<GenericDialect>());
It looks like #1120 is where this changed. BigQueryDialect got the ability to parse DELETE statements without the FROM keyword. GenericDialect got treated the same way as BigQueryDialect, but that broke its ability to parse some statements from dialects other than BigQueryDialect.
The most permissive thing would be for GenericDialect to be able to support both of these DELETE formats:
DELETE [FROM] table [alias] WHERE condition (like BigQuery)
DELETE tables FROM table WHERE condition (like all the other dialects)
The challenge is that just making FROM optional doesn't work, because these two statements become a reduce-reduce conflict:
DELETE table_list [FROM] table WHERE condition
DELETE [FROM] table alias WHERE condition
So I think the best approach is to split parse_delete into two functions: one in the BigQueryDialect style and one in the all-others style, and let GenericDialect try both.
Supporting the union of many grammars is hard and sometimes undefined, but I think that 👆 is what makes the most sense for DELETE.
According to the design policy,
GenericDialect
is intended to parse any SQL that other dialects can handle, but it currently fails to parse multi-table DELETE statements and DELETE statements without a FROM clause.I think the expected behavior is that the following tests should also pass with
GenericDialect
.datafusion-sqlparser-rs/tests/sqlparser_common.rs
Lines 688 to 735 in 2182f7e
The text was updated successfully, but these errors were encountered: