machow / siuba

Python library for using dplyr like syntax with pandas and SQL
https://siuba.org
MIT License
1.14k stars 48 forks source link

using query with single sql_raw column drops FROM clause #416

Open machow opened 2 years ago

machow commented 2 years ago

SqlAlchemy uses the tables that columns are associated to, to decide what to include in the FROM clause. Because sql_raw does not have a table associated with it--having it as the sole column causes the FROM clause to be omitted.

We could pretty easily, associate the current table/subquery to the clause, but I wonder if we should also add an argument to sql_raw to optionally disable this behavior.

Note also that sql_raw is literally sqlalchemy.sql.elements.literal_column, so a user could add the table themselves, etc..