adriangb commented on PR #24479:
URL: https://github.com/apache/datafusion/pull/24479#issuecomment-5337787942

   Closing this in favour of fixing the root cause upstream.
   
   The mis-parse originates in `sqlparser`, which parses the right operand of 
`IS [NOT] DISTINCT FROM` with `parse_expr()` — the lowest precedence — so 
everything after the operator is swallowed into it. The one-line fix is to use 
`parse_subexpr(precedence)` instead, and it is already proposed upstream:
   
   - apache/datafusion-sqlparser-rs#2436 — includes the fix plus a related 
correction to the default `Precedence::PgOther` placement
   - apache/datafusion-sqlparser-rs#2443 — the same parser change
   
   Fixing it there removes the need for the 271-line planner-side rewrite in 
this PR, which would become dead code as soon as DataFusion picks up the 
release containing it.
   
   I verified the upstream fix end-to-end against this branch's base (`main` @ 
9a96f6715f) by applying it to `sqlparser` v0.62.0 via `[patch.crates-io]`:
   
   - every case from #23692 that previously failed with `Cannot infer common 
argument type for logical boolean operation Int64 AND Boolean` now plans and 
returns the correct result, including the multi-column `LEFT ANTI JOIN`
   - on the `AND`/`OR` and `NOT` cases where an incorrect grouping changes the 
*result* rather than raising an error, DataFusion now agrees with PostgreSQL 17
   - no regressions: `datafusion-sql` 88 + 572 + 12 passed; sqllogictest 
**502/502 files**; `datafusion-optimizer` + `datafusion-expr` 248 + 760 + 26 + 
55 + 5 passed
   
   #23692 should stay open until DataFusion bumps its `sqlparser` dependency 
past the release carrying the fix. The `.slt` and planner tests added here are 
still worth having and can be re-proposed alongside that bump.


-- 
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]

Reply via email to