Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): use to_pyarrow() instead of execute() when pretty printing scalars #10186

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ibis/backends/tests/test_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,22 @@ def test_no_recursion_error(con, monkeypatch):
exc.RelationError, match="The scalar expression cannot be converted"
):
repr(expr)


@pytest.mark.notimpl(
["impala", "flink", "pyspark"],
reason="backend calls `execute` as part of pyarrow conversion",
)
def test_scalar_uses_pyarrow(con, table, monkeypatch, mocker):
monkeypatch.setattr(ibis.options, "interactive", True)

execute_spy = mocker.spy(con, "execute")
to_pyarrow_spy = mocker.spy(con, "to_pyarrow")

repr(table.limit(1).string_col)

# pyarrow does get called
to_pyarrow_spy.assert_called_once()

# execute doesn't get called
execute_spy.assert_not_called()
2 changes: 1 addition & 1 deletion ibis/expr/types/pretty.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def _to_rich_scalar(
) -> Pretty:
value = format_values(
expr.type(),
[expr.execute()],
[expr.to_pyarrow().as_py()],
max_length=max_length or ibis.options.repr.interactive.max_length,
max_string=max_string or ibis.options.repr.interactive.max_string,
max_depth=max_depth or ibis.options.repr.interactive.max_depth,
Expand Down