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

using table.view() more than once produces the same alias in the SQL #20

Open
mikehinchey opened this issue Feb 12, 2021 · 0 comments
Open
Projects

Comments

@mikehinchey
Copy link
Contributor

This is correct:

t = con.table('omnisci_countries')

t0 = t
t1 = t.view()
x = t0.join(t1, (t0.abbrev == t1.abbrev))
x = x.select([t0.abbrev])
x.compile()

SELECT t0."abbrev"
FROM omnisci_countries t0
  JOIN omnisci_countries t1
    ON t0."abbrev" = t1."abbrev"

Here, the ON clause uses t0 for both sides:

t0 = t.view()
t1 = t.view()
x = t0.join(t1, (t0.abbrev == t1.abbrev))
x = x.select([t0.abbrev])
x.compile()

SELECT t0."abbrev"
FROM omnisci_countries t0
  JOIN (
    SELECT *
    FROM omnisci_countries
  ) t1
    ON t0."abbrev" = t0."abbrev"

Here, t2 is used twice with no t1:

t0 = t
t1 = t.view()
t2 = t.view()
x = t0.join(t1, (t0.abbrev == t1.abbrev))
x = x.join(t2, (t0.abbrev == t2.abbrev))
x = x.select([t0.abbrev])
x.compile()

SELECT t0."abbrev"
FROM omnisci_countries t0
  JOIN omnisci_countries t2
    ON t0."abbrev" = t2."abbrev"
  JOIN omnisci_countries t2
    ON t0."abbrev" = t2."abbrev"
@xmnlab xmnlab added this to To do in Release 1.0 Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant