Using `source` as a relation alias causes "Ambiguous name" error
What happened?
In #5055, I reported a query that generates an "Ambiguous name" error. I was flummoxed.
@lukapeschke found that substituting Source in the derive source = "SD" statements solved the problem - the query compiles and returns good results.
NB Changing the second instance (but not the first) to Source seems to compile/return results, and changing both to foodoes, too.
Why is usingsource treated specially? Many thanks.
PRQL input
# PRQL #5055
# Gives ambiguous name error if using "source"
# Works if changed to "Source"
let table1 = (
from ScrapedData
select { sd=SD_Land_Use_Code }
derive source="SD"
group { sd } (
take 1
)
sort { sd }
)
let table2 = (
from SpecialLand
select { sd = SL_Code }
derive source = "SL"
group { sd } (
take 1
)
sort { sd }
)
from table1
append table2
SQL output
N/A
Expected SQL output
N/A
MVCE confirmation
- [ ] Minimal example
- [ ] New issue
Anything else?
No response
I think it's related to the reference to source here:
https://github.com/PRQL/prql/blob/e6650494ceb50c1838cc8a291d2d9d31661dd9f1/prqlc/prqlc/src/semantic/std.prql#L70-L73
At least, when I tried changing source there to sourceby, and recompiled, the test case doesn't raise the error; when I then replaced source with sourceby in the test, the error recurred.
That's a pretty good proof. For clarity, when you replace source in the std.prql file then recompile, the test case above works. When you then replace source with sourceby in the test case, it fails with the same error.
Thanks!