Skip to content

Using source as a relation alias causes "Ambiguous name" error #5094

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

Open
2 tasks
richb-hanover opened this issue Jan 15, 2025 · 3 comments
Open
2 tasks

Using source as a relation alias causes "Ambiguous name" error #5094

richb-hanover opened this issue Jan 15, 2025 · 3 comments
Labels
bug Invalid compiler output or panic

Comments

@richb-hanover
Copy link
Contributor

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

@richb-hanover richb-hanover added the bug Invalid compiler output or panic label Jan 15, 2025
@kgutwin
Copy link
Collaborator

kgutwin commented Jan 18, 2025

I think it's related to the reference to source here:

## Relational transforms
let from = func
`default_db.source` <relation>
-> <relation> source

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.

@richb-hanover
Copy link
Contributor Author

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!

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