Skip to content

Conversation

mpatou
Copy link
Contributor

@mpatou mpatou commented Apr 2, 2024

Summary

On the columns that are part of the clause for a join, remove the schema
prefix by creating an alias based on the table and setting the table
attribute of the columns in the join clause to be alias and not the
table.
The name of the alias is picked to be the name of the table as well as
it works in plain SQL.

We only do that if:

  1. there is a schema prefix on the table (ie. commons or production)
  2. the "table" is not actually already an alias
  3. the "table" is not actually a subquery

Testing

I created unit tests for the visit_join function they are all passing.
I also created a wheel package and uploaded it in superset, I used to
have issues with queries when superset wanted to do a self join to limit
the number of series returned in a query.
It was complaining:

Relation name `commons` not found. If you are trying to access a nested
field within an object

With the fix the query is working fine.

Summary

On the columns that are part of the clause for a join, remove the schema
prefix by creating an alias based on the table and setting the `table`
attribute of the columns in the join clause to be alias and not the
table.
The name of the alias is picked to be the name of the table as well as
it works in plain SQL.

We only do that if:

1. there is a schema prefix on the table (ie. `commons` or `production`)
2. the "table" is not actually already an alias
3. the "table" is not actually a subquery

Testing

I created unit tests for the visit_join function they are all passing.
I also created a wheel package and uploaded it in `superset`, I used to
have issues with queries when superset wanted to do a self join to limit
the number of series returned in a query.
It was complaining:
```
Relation name `commons` not found. If you are trying to access a nested
field within an object
```
With the fix the query is working fine.
@mpatou
Copy link
Contributor Author

mpatou commented Apr 2, 2024

This is a dup of #10 that was wrongly merged in a dev branch.

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

Successfully merging this pull request may close these issues.

1 participant