Skip to content

Commit

Permalink
use register for duckdb-polars
Browse files Browse the repository at this point in the history
  • Loading branch information
finn-rudolph committed Oct 7, 2024
1 parent cf82e33 commit 58f59bf
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/pydiverse/transform/_internal/backend/duckdb_polars.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,13 @@ def export(nd: AstNode, target: Target, final_select: list[Col]) -> pl.DataFrame
)
)

return eval(
"duckdb.sql(query_str).pl()",
{
"duckdb": duckdb,
"query_str": query_str,
# put all the source dfs in current scope
**{
desc.table.name: desc.df
for desc in nd.iter_subtree()
if isinstance(desc, DuckDbPolarsImpl)
},
},
)
# tell duckdb which table names in the SQL query correspond to which
# data frames
for desc in nd.iter_subtree():
if isinstance(desc, DuckDbPolarsImpl):
duckdb.register(desc.table.name, desc.df)

return duckdb.sql(query_str).pl()

raise AssertionError

Expand Down

0 comments on commit 58f59bf

Please sign in to comment.