"Leaking" of `_expr_*` columns into result relations

Aperta
#4,719 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust, sql
Ambito
backend, databases

Direzione di ricerca

Start by reading the compiler behavior behind the minimal PRQL example and the related discussion in issues #4633 and #3130. The issue does not identify a file, test, or settled implementation approach, so first trace how intermediate _expr_* columns enter the generated SQL. Done means the output relation excludes those internal columns without changing the expected user-visible result across supported backends.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
What happened?

prqlc produces SQL which uses _expr_* columns internally for internal intermediate calculation results. These should never end up in the resulting output relation.

The current situation is understandable since not all SQL dialects support the SELECT EXCLUDE _expr_* syntax and without schema information about the input relations, the compiler cannot explicitly enumerate the output columns.

However if we think about PRQL from first principles as "a language for Relational Algebra" then I hazard the guess that we all agree that such internal implementation details should not form part of the output.

As pointed out in https://github.com/PRQL/prql/issues/4633#issuecomment-2220485438, such extraneous columns can also cause errors in downstream calcuations.

One of my personal ambitions for PRQL is to extend it beyond the current SQL backends to also include other "relational" languages and query engines such as Pandas, Polars, (Power Query) M Language, etc... to name just a few. In those cases the _expr_* columns should also not show up and ideally PRQL should produce consistent results between different backends.

PRQL input
from [{a=1}]
derive a=2
SQL output
WITH table_0 AS (
  SELECT
    1 AS a
)
SELECT
  a AS _expr_0,
  2 AS a
FROM
  table_0

-- Generated by PRQL compiler version:0.12.2 (https://prql-lang.org)
Expected SQL output
WITH table_0 AS (
  SELECT
    1 AS a
)
SELECT
  2 AS a
FROM
  table_0
MVCE confirmation
  • Minimal example
  • New issue
Anything else?

I'm not sure what the solution would be so just raising this as a tracking issue and discussion point.

There are some more examples in https://github.com/PRQL/prql/issues/3130#issuecomment-2222335851.

Lingua principale
Rust
Stelle
10.9k
Fork
261
Merge medio
3g 21h
PR unite (30g)
84

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PRQL/prql

Tutte le issue di PRQL/prql

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.