Skip to content

Commit

Permalink
hotfix: problem with multi-engine execution (letsql#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
mesejo committed Jun 5, 2024
1 parent e99e2f0 commit 3f1262c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
12 changes: 9 additions & 3 deletions python/letsql/backends/let/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,16 @@ def register(
return registered_table

def execute(self, expr: ir.Expr, **kwargs: Any):
def replace_table(node, _, **_kwargs):
return self._sources.get_table_or_op(node, node.__recreate__(_kwargs))
not_multi_engine = self._get_source(expr) != self
if (
not_multi_engine
): # this means is a single source that is not the letsql backend

def replace_table(node, _, **_kwargs):
return self._sources.get_table_or_op(node, node.__recreate__(_kwargs))

expr = expr.op().replace(replace_table).to_expr()

expr = expr.op().replace(replace_table).to_expr()
expr = self._register_and_transform_cache_tables(expr)
backend = self._get_source(expr)

Expand Down
29 changes: 29 additions & 0 deletions python/letsql/backends/let/tests/test_isolated_execution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import ibis

import letsql as ls


def test_multiple_pipes(pg):
"""This test address the issue reported on bug #69
link: https://github.com/letsql/letsql/issues/69
NOTE
The previous tests didn't catch it because the con object registered the table batting.
"""

con = ls.connect()
duckdb_con = ibis.duckdb.connect()
table_name = "batting"
pg_t = pg.table(table_name)[lambda t: t.yearID == 2015].pipe(
con.register, f"pg-{table_name}"
)
db_t = duckdb_con.register(pg_t.to_pyarrow(), f"{table_name}")[
lambda t: t.yearID == 2014
].pipe(con.register, f"db-{table_name}")

expr = pg_t.join(
db_t,
"playerID",
)

expr.execute()

0 comments on commit 3f1262c

Please sign in to comment.