Skip to content

Commit

Permalink
fix(repr): allow ops.TableNode in fmt_value
Browse files Browse the repository at this point in the history
Fixes a minor regression in the new repr
  • Loading branch information
gforsyth authored and cpcloud committed Mar 24, 2022
1 parent b0b8e5c commit 6f57003
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ibis/expr/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,18 @@ def _fmt_value_physical_table(op: ops.PhysicalTable, **_: Any) -> str:
return op.name


@fmt_value.register
def _fmt_value_table_node(
op: ops.TableNode, *, aliases: Aliases, **_: Any
) -> str:
"""Format a table as value.
This function is called when a table is used in a value expression. An
example is `table.count()`.
"""
return f"{aliases[op.table.op()]}"


@fmt_value.register
def _fmt_value_string_sql_like(
op: ops.StringSQLLike, *, aliases: Aliases
Expand Down
5 changes: 5 additions & 0 deletions ibis/tests/expr/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ def test_tables_have_format_rules(cls):
assert cls in ibis.expr.format.fmt_table_op.registry


@pytest.mark.parametrize("cls", [ops.PhysicalTable, ops.TableNode])
def test_tables_have_format_value_rules(cls):
assert cls in ibis.expr.format.fmt_value.registry


def test_window_no_group_by():
t = ibis.table(dict(a="int64", b="string"), name="t")
expr = t.a.mean().over(ibis.window(preceding=0))
Expand Down

0 comments on commit 6f57003

Please sign in to comment.