Skip to content

Commit

Permalink
refactor(sqlglot): clean up explode usage
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and kszucs committed Feb 12, 2024
1 parent 776079c commit 4d99314
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
4 changes: 0 additions & 4 deletions ibis/backends/base/sqlglot/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,10 +1213,6 @@ def visit_SQLStringView(self, op, *, query: str, name: str, child):
def visit_SQLQueryResult(self, op, *, query, schema, source):
return sg.parse_one(query, read=self.dialect).subquery()

@visit_node.register(ops.Unnest)
def visit_Unnest(self, op, *, arg):
return sge.Explode(this=arg)

@visit_node.register(ops.JoinTable)
def visit_JoinTable(self, op, *, parent, index):
return parent
Expand Down
6 changes: 2 additions & 4 deletions ibis/backends/postgres/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,7 @@ def visit_ArrayRepeat(self, op, *, arg, times):
@visit_node.register(ops.ArrayDistinct)
def visit_ArrayDistinct(self, op, *, arg):
return self.if_(
arg.is_(NULL),
NULL,
self.f.array(sg.select(sge.Explode(this=arg)).distinct()),
arg.is_(NULL), NULL, self.f.array(sg.select(self.f.explode(arg)).distinct())
)

@visit_node.register(ops.ArrayUnion)
Expand All @@ -248,7 +246,7 @@ def visit_ArrayUnion(self, op, *, left, right):
def visit_ArrayIntersect(self, op, *, left, right):
return self.f.anon.array(
sg.intersect(
sg.select(sge.Explode(this=left)), sg.select(sge.Explode(this=right))
sg.select(self.f.explode(left)), sg.select(self.f.explode(right))
)
)

Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/snowflake/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def visit_Unnest(self, op, *, arg):
split = self.f.split(
self.f.array_to_string(self.f.nullif(arg, self.f.array()), sep), sep
)
expr = self.f.nullif(sge.Explode(this=split), "")
expr = self.f.nullif(self.f.explode(split), "")
return self.cast(expr, op.dtype)

@visit_node.register(ops.Quantile)
Expand Down

0 comments on commit 4d99314

Please sign in to comment.