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

multiple joins to the same table #25

Open
jbothma opened this issue Dec 6, 2016 · 0 comments
Open

multiple joins to the same table #25

jbothma opened this issue Dec 6, 2016 · 0 comments

Comments

@jbothma
Copy link

jbothma commented Dec 6, 2016

if you have two joins to the same table, it uses the same reference for that table so the join will only return rows where both fact table columns are equal and match some row in the dimension table.

It'd be nice to support cases where you need to join to the same table twice, but where the join columns don't all equal.

To support that we need to alias the dimension table differently for each join - perhaps according to the column being joined to.

sorry - don't have time to make an example model but this might suffice:

demarcation_changes

  • demensions
    • old_demarcation
      • attributes
        • demarcation.code
        • demarcation.label
      • join_column: code
    • new_demarcation
      • attributes
        • demarcation.code
        • demarcation.label
      • join_column: code

This generates a query including

FROM demarcation_changes, demarcation
WHERE demarcation_changes.old_code = demarcation.code AND demarcation_changes.new_code = demarcation.code

while we want

FROM demarcation_changes, demarcation as old_demarcation, demarcation as new_demarcation
WHERE demarcation_changes.old_code = old_demarcation.code 
AND demarcation_changes.new_code = new_demarcation.code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant