Skip to content

MySQL caret binds below multiplication, changing a DataFusion query result #2692

Open

Description

@pbottine

Reproduction

With datafusion==55.0.0:

from datafusion import SessionConfig, SessionContext

config = SessionConfig().set("datafusion.sql_parser.dialect", "MySQL")
batches = SessionContext(config).sql("SELECT 2 ^ 3 * 4").collect()
print(batches[0].column(0).to_pylist())

Observed on 2026-10-19: [14]. MySQL's precedence table ranks bitwise ^ above *, so the expression groups as (2 ^ 3) * 4 and yields 4. The observed result corresponds to 2 ^ (3 * 4).

The generic precedence table gives Caret a lower value than MulDivModOp, and the MySQL dialect does not override caret precedence. The same relative tiers remain on the default branch as of 2026-10-19. This is a MySQL-dialect parser discrepancy with an observed downstream query-result difference in DataFusion.

Activity

  1. LucaCappelletti94 commented on Oct 21, 2026

    @LucaCappelletti94
    Contributor

    Is this a regression?

  2. pbottine commented on Oct 21, 2026

    @pbottine
    Author

    This looks like a longstanding issue rather than a regression: I reproduced it back to sqlparser-rs 0.5.1 and traced the grouping to the initial XOR-support commit in June 2020. Its parent does not support ^, so I haven’t found a previously correct version.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions