DuckDB: `f(a == b)` is displayed as `f(a = b)`, which reparses as a named argument

Offen
#2,808 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
45/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
rust, sql
Bereich
databases

Rechercherichtung

Start with how BinaryOperator::Eq is displayed, and with the DuckDB dialect's supports_named_fn_args_with_eq_operator flag (#1182) that makes a = b inside a call a named argument. Reproduce SELECT coalesce(a == b) FROM t as a round trip and compare the AST before and after. Before changing anything, check with maintainers whether this counts as accepted normalisation, since the thread has no answer yet. Done means the round trip keeps Unnamed(BinaryOp { a Eq b }), or the maintainers have documented why it does not.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

DuckDB Prolific Author

== is parsed as BinaryOperator::Eq and displayed as =. Inside a function call with DuckDbDialect, a = b is a named argument (supports_named_fn_args_with_eq_operator, #1182), so the output means something else:

SELECT coalesce(a == b) FROM t
  -> AST arg: Unnamed(BinaryOp { a Eq b })
  -> displays as: SELECT coalesce(a = b) FROM t
  -> reparse arg: Named { name: a, arg: b, operator: Equals }
SELECT a == b FROM t
  -> displays as SELECT a = b FROM t, same AST (fine)

DuckDB documents = and == as equal (https://duckdb.org/docs/stable/sql/expressions/comparison_operators) and evaluates coalesce(a == b) as a comparison. This may count as accepted normalisation; the only effect is the AST change inside call arguments.

Tested on main ce12f1f6 (also 0.63.0 and 0.58.0).

Found with a property-based fuzzer (round trip check); I used AI assistance for triage and verified every case above.

Vorherrschende Sprache
Rust
Sterne
3.5k
Forks
805
Ø Merge
2 T. 3 Std.
Gemergte PRs (30 T.)
116

Entwicklungsumgebung

  • Kein Dockerfile und keine Docker-Compose-Datei
  • Hat eine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus apache/datafusion-sqlparser-rs

Alle Issues in apache/datafusion-sqlparser-rs

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.