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

Variable is discarded silently with no type error #5158

Open
2 tasks done
nightpool opened this issue Feb 19, 2025 · 1 comment
Open
2 tasks done

Variable is discarded silently with no type error #5158

nightpool opened this issue Feb 19, 2025 · 1 comment
Labels
bug Invalid compiler output or panic

Comments

@nightpool
Copy link

nightpool commented Feb 19, 2025

What happened?

Variable is discarded when I expect it to be used. Ideally, the variable would just be used as defined. In the worst case, this should at least be a type error.

PRQL input

prql target:sql.postgres

let mod_id = (from users | filter login == "nightpool" | select id | take 1)

from events
filter actor_id == mod_id

sort (-event_occurred_at)
take 10

SQL output

SELECT
  *
FROM
  events
WHERE
  actor_id = mod_id
ORDER BY
  event_occurred_at DESC
LIMIT
  10

Expected SQL output

SELECT
  *
FROM
  events
WHERE
  actor_id = (select id from users where login = 'nightpool' limit 1)
ORDER BY
  event_occurred_at DESC
LIMIT
  10

MVCE confirmation

  • Minimal example
  • New issue

Anything else?

I can't get PRQL to generate a subquery at all in any format. Maybe there's something i'm missing? "into mod_id" also has the same issue.

@nightpool nightpool added the bug Invalid compiler output or panic label Feb 19, 2025
@max-sixty
Copy link
Member

Yes, agree, this looks like a bug. I'll try and take a look deeper, though it's likely a bug in the resolver which we're considering overhauling...

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

2 participants