Skip to content

SQLite parser dialect returns different rows for bitwise filter than SQLite #26511

Open

Description

@pbottine

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

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, parser source, and DataFusion parser-dialect setting.

The upstream parser has PR #2683 open for the SQLite bitwise precedence. This issue records the observed query-result effect in DataFusion's configurable SQLite dialect.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions