#6065·prql

this.<name>` resolves to the source relation instead of a same-named colum

Author: lukapeschkeCreated Jul 7, 2026Updated Jul 7, 2026
Labelsbug

What happened?

Related to #6020 . When a column has the same name as a relation, referencing it resolves to the source table instead of the columns.

In a sort, this causes the compilation to fail. In a select, it results in a wildcard select

PRQL input

elm
# Sort case
from status | sort {this.status}

# Select case
from status | select {this.status}

SQL output

sql
# Sort case
from `status` | sort {this.`status`}
                      ──────┬──────
                            ╰──────── table instance cannot be referenced directly

# Select case
SELECT
  *
FROM
  status

Expected SQL output

sql
# Sort case
SELECT * FROM status ORDER BY status.status

# Select case
SELECT status FROM status

MVCE confirmation

  • Minimal example
  • New issue

Anything else?

No response