Skip to content

Commit

Permalink
perf(sql): prevent sqlglot from extensive deepcopying every time we c…
Browse files Browse the repository at this point in the history
…reate a sqlglot object
  • Loading branch information
kszucs committed Mar 11, 2024
1 parent f33bf51 commit 005d609
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 71 deletions.
4 changes: 2 additions & 2 deletions ibis/backends/sql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def _to_sqlglot(
assert not isinstance(sql, sge.Subquery)

if isinstance(sql, sge.Table):
sql = sg.select(STAR).from_(sql)
sql = sg.select(STAR, copy=False).from_(sql, copy=False)

Check warning on line 110 in ibis/backends/sql/__init__.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/sql/__init__.py#L110

Added line #L110 was not covered by tests

assert not isinstance(sql, sge.Subquery)
return sql
Expand All @@ -117,7 +117,7 @@ def compile(
):
"""Compile an Ibis expression to a SQL string."""
query = self._to_sqlglot(expr, limit=limit, params=params, **kwargs)
sql = query.sql(dialect=self.dialect, pretty=True)
sql = query.sql(dialect=self.dialect, pretty=True, copy=False)
self._log(sql)
return sql

Expand Down
Loading

0 comments on commit 005d609

Please sign in to comment.