Aliasing Left Side of Join Breaks Derivation

Abierto
#4,299 5 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
rust, sql

Línea de trabajo

Start with the PRQL input and expected-versus-actual BigQuery SQL in the issue; trace how an aliased derived relation is represented through join compilation, then find the related tests. Reproduce the missing profit derivation and use the expected SQL as the completion criterion. The issue names no source files or tests, so locating the relevant compiler path will take project familiarity.

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

Descripción

bug
What happened?

Aliasing the left side of a join magically erases any derivations in that left side.

Without alias (seems to work):

prql target:sql.bigquery
from sales
derive {profit = sell_price - buy_price}
join side:left details (this.item_id == that.item_id)
select !{details.item_id}

With alias (doesn't work):

prql target:sql.bigquery
sales_with_profit = (
    from sales
    derive {profit = sell_price - buy_price}
)
join side:left details (this.item_id == that.item_id)
select !{details.item_id}

With the aliasing, the "profit" derivation completely disappears. That should not happen.

PRQL input
prql target:sql.bigquery
sales_with_profit = (
    from sales
    derive {profit = sell_price - buy_price}
)
join side:left details (this.item_id == that.item_id)
select !{details.item_id}
SQL output
WITH table_0 AS (
  SELECT
    *
  FROM
    sales
)
SELECT
  table_0.*,
  details.*
EXCEPT
  (item_id)
FROM
  table_0
  LEFT JOIN details ON table_0.item_id = details.item_id

-- Generated by PRQL compiler version:0.11.2 (https://prql-lang.org/)
Expected SQL output
WITH table_0 AS (
  SELECT
    *,
    sell_price - buy_price AS profit
  FROM
    sales
)
SELECT
  table_0.*
EXCEPT
  (profit),
  details.*
EXCEPT
  (item_id),
  table_0.profit
FROM
  table_0
  LEFT JOIN details ON table_0.item_id = details.item_id
MVCE confirmation
  • Minimal example
  • New issue
Anything else?

No response

Lenguaje dominante
Rust
Estrellas
10.9k
Forks
261
Merge medio
3 d 21 h
PR fusionados (30 d)
84

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.