Skip to content

Commit

Permalink
refactor(viz): avoid repeatedly rendering redundant schemas in graphv…
Browse files Browse the repository at this point in the history
…iz output (#9518)
  • Loading branch information
cpcloud authored Jul 19, 2024
1 parent 6991f04 commit d53602b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ibis/expr/operations/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,18 @@ class Distinct(Simple):


@public
class TableUnnest(Simple):
class TableUnnest(Relation):
"""Cross join unnest operation."""

parent: Relation
column: Value[dt.Array]
offset: typing.Union[str, None]
keep_empty: bool

@attribute
def values(self):
return self.parent.fields

@attribute
def schema(self):
column = self.column
Expand Down
6 changes: 6 additions & 0 deletions ibis/expr/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ def get_type(node):
for right_column, type in right_schema.items()
]
schema = ibis.schema(pairs)
else:
# Simple relations have the same schema as their parent so avoid
# re-rendering the same schema fields for these relations
if isinstance(node, ops.relations.Simple):
return '<BR ALIGN="LEFT" />:: …'

return '<BR ALIGN="LEFT" />' + '<BR ALIGN="LEFT" />'.join(
f"<I>{escape(name)}</I>: {escape(str(type))}"
Expand Down Expand Up @@ -229,6 +234,7 @@ def draw(graph, path=None, format="png", verbose: bool = False):
.group_by(_.c)
.having(_.a.mean() > 0.0)
.aggregate(a_mean=_.a.mean(), b_sum=_.b.sum())
.order_by(_.a_mean)
.mutate(
arrays=ibis.array([1, 2, 3]),
maps=ibis.map({"a": 1, "b": 2}),
Expand Down

0 comments on commit d53602b

Please sign in to comment.