pbottine opened a new issue, #26511:
URL: https://github.com/apache/datafusion/issues/26511

   ## Summary
   
   With `datafusion.sql_parser.dialect=SQLite`, DataFusion 55.0.0 returns no 
rows for a bitwise filter that SQLite 3.50.4 evaluates to one row.
   
   ## Reproduction
   
   ```python
   import sqlite3
   from datafusion import SessionConfig, SessionContext
   
   sql = "WITH t(id,bits) AS (VALUES (1,1),(2,4)) SELECT id FROM t WHERE bits | 
2 & 4 = 0"
   print(sqlite3.connect(":memory:").execute(sql).fetchall())
   config = SessionConfig().set("datafusion.sql_parser.dialect", "SQLite")
   batches = SessionContext(config).sql(sql).collect()
   print([x for batch in batches for x in batch.column(0).to_pylist()])
   ```
   
   Observed again on 2026-10-19 with `datafusion==55.0.0`: SQLite returns 
`[(1,)]`; DataFusion returns `[]`. For the scalar `SELECT 1 | 2 & 4`, SQLite 
returns `0` and DataFusion returns `1`.
   
   SQLite places `|` and `&` in a single left-associative tier, so the filter 
groups as `(bits | 2) & 4 = 0`. The generic sqlparser-rs table instead puts `&` 
above `|`. See the [SQLite precedence 
table](https://www.sqlite.org/lang_expr.html#operators_and_parse_affecting_attributes),
 [parser 
source](https://github.com/apache/datafusion-sqlparser-rs/blob/f1854e47e463bbe8cd2f7c08fb008b7ced268598/src/dialect/mod.rs#L862-L992),
 and [DataFusion parser-dialect 
setting](https://datafusion.apache.org/user-guide/configs.html).
   
   The upstream parser has [PR 
#2683](https://github.com/apache/datafusion-sqlparser-rs/pull/2683) open for 
the SQLite bitwise precedence. This issue records the observed query-result 
effect in DataFusion's configurable SQLite dialect.
   


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