Skip to content

Variable is discarded silently with no type error #5158

@nightpool

Description

@nightpool

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugInvalid compiler output or panic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions