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

Abierto
#4,719 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 5 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
rust, sql

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
10.9k
Forks
261
Merge medio
4 d 7 h
PR fusionados (30 d)
77

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PRQL/prql

Todos los issues de PRQL/prql

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.