Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order of select columns is wrong in complex select clauses #5001

Open
2 tasks done
YuxiLing opened this issue Nov 5, 2024 · 0 comments
Open
2 tasks done

Order of select columns is wrong in complex select clauses #5001

YuxiLing opened this issue Nov 5, 2024 · 0 comments
Labels
bug Invalid compiler output or panic

Comments

@YuxiLing
Copy link

YuxiLing commented Nov 5, 2024

What happened?

I have an issue with multiple select clauses in a query. The output SQL query for the following PRQL input is not correct with the error message, "no such column: _expr_0". It does not always happen but exists in complex and redundant select clauses.

PRQL input

from tb_0
take  100
select {cc0 = c1,cc1 = c2,cc2 = c1}
select {ccc0 = cc1,ccc1 = 1}
select {cccc0 = 1,cccc1 = ccc0,cccc3 = 1,cccc4 = 0,cccc5 = 0,cccc6 = 0,cccc7 = 0}
derive {cccc8 = 0,cccc9 = 0,cccc10 = 0}

SQL output

WITH table_0 AS (
  SELECT
    _expr_0 AS cccc1,
    1 AS cccc3,
    0 AS cccc4,
    0 AS cccc5,
    0 AS cccc6,
    0 AS cccc7,
    c2 AS _expr_0
  FROM
    tb_0
  LIMIT
    100
)
SELECT
  1 AS cccc0,
  cccc1,
  cccc3,
  cccc4,
  cccc5,
  cccc6,
  cccc7,
  0 AS cccc8,
  0 AS cccc9,
  0 AS cccc10
FROM
  table_0

-- Generated by PRQL compiler version:0.13.2 (https://prql-lang.org)

Expected SQL output

WITH table_0 AS (
  SELECT
    c2 AS _expr_0,
    _expr_0 AS cccc1,
    1 AS cccc3,
    0 AS cccc4,
    0 AS cccc5,
    0 AS cccc6,
    0 AS cccc7
  FROM
    tb_0
  LIMIT
    100
)
SELECT
  1 AS cccc0,
  cccc1,
  cccc3,
  cccc4,
  cccc5,
  cccc6,
  cccc7,
  0 AS cccc8,
  0 AS cccc9,
  0 AS cccc10
FROM
  table_0

MVCE confirmation

  • Minimal example
  • New issue

Anything else?

No response

@YuxiLing YuxiLing added the bug Invalid compiler output or panic label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Invalid compiler output or panic
Projects
None yet
Development

No branches or pull requests

1 participant