Skip to content

Commit

Permalink
fix(sql): avoid reselecting relations that do not need it to prevent …
Browse files Browse the repository at this point in the history
…dropping order by clauses
  • Loading branch information
cpcloud committed Sep 8, 2023
1 parent b9fb231 commit 8ae2f03
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ibis/backends/base/sql/alchemy/query_builder.py
Expand Up @@ -222,13 +222,14 @@ def _compile_table_set(self):
if self.table_set is not None:
helper = self.table_set_formatter_class(self, self.table_set)
result = helper.get_result()
if isinstance(result, sql.selectable.Select):
return result.subquery()
return result
else:
return None

def _add_select(self, table_set):
if not self.select_set:
return table_set.element

to_select = []

context = self.context
Expand Down Expand Up @@ -374,6 +375,11 @@ class AlchemySelectBuilder(SelectBuilder):
def _convert_group_by(self, exprs):
return exprs

def _collect_SQLQueryResult(self, op, toplevel=False):
if toplevel:
self.table_set = op
self.select_set = []


class AlchemySetOp(SetOp):
def compile(self):
Expand Down

0 comments on commit 8ae2f03

Please sign in to comment.