Aliasing Left Side of Join Breaks Derivation

Đang mở
#4,299 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rust, sql
Lĩnh vực
backend, compilers

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Rust
Star
10.9k
Fork
261
Merge trung bình
3 ngày 21 giờ
Pull request đã merge (30 ngày)
84

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PRQL/prql

Tất cả issue của PRQL/prql

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.