Skip to content
This repository was archived by the owner on May 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix unary op bug
  • Loading branch information
TrevorBergeron committed Nov 7, 2023
commit 43430fc3920187c1459480430247d5b6627fd3cd
4 changes: 1 addition & 3 deletions bigframes/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ def _compile_unordered(self) -> compiled.UnorderedIR:
def shape(self) -> typing.Tuple[int, int]:
"""Returns dimensions as (length, width) tuple."""
width = len(self._compile().columns)
Comment thread
TrevorBergeron marked this conversation as resolved.
count_expr = (
self._compile_unordered()._to_ibis_expr(ordering_mode="unordered").count()
)
count_expr = self._compile_unordered()._to_ibis_expr().count()

# Support in-memory engines for hermetic unit tests.
if not self.node.session:
Expand Down
14 changes: 9 additions & 5 deletions bigframes/core/compile/compiled.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,17 @@ def _reproject_to_table(self: T) -> T:
...

def project_unary_op(
self: T, column_name: str, op: ops.UnaryOp, output_name=None
self: T,
input_column_id: str,
op: ops.UnaryOp,
output_column_id: typing.Optional[str] = None,
) -> T:
"""Creates a new expression based on this expression with unary operation applied to one column."""
value = op._as_ibis(self._get_ibis_column(column_name)).name(output_name)
return self._set_or_replace_by_id(output_name, value)
result_id = (
output_column_id or input_column_id
) # overwrite input if not output id provided
value = op._as_ibis(self._get_ibis_column(input_column_id)).name(result_id)
return self._set_or_replace_by_id(result_id, value)

def project_binary_op(
self: T,
Expand Down Expand Up @@ -258,7 +264,6 @@ def _to_ibis_expr(
expose_hidden_cols: bool = False,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be able to remove this parameter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parameter is a bit tricky, as its mostly there to prevent ibis from doing to many re-projections. I don't want to risk removing this in this cl

fraction: Optional[float] = None,
col_id_overrides: typing.Mapping[str, str] = {},
**kwargs,
):
"""
Creates an Ibis table expression representing the DataFrame.
Expand Down Expand Up @@ -1061,7 +1066,6 @@ def _to_ibis_expr(
col_id_overrides: typing.Mapping[str, str] = {},
ordering_mode: Literal["string_encoded", "offset_col", "unordered"],
order_col_name: Optional[str] = ORDER_ID_COLUMN,
**kwargs,
):
"""
Creates an Ibis table expression representing the DataFrame.
Expand Down
2 changes: 1 addition & 1 deletion bigframes/core/compile/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _compile_node(
node: nodes.BigFrameNode, ordered: bool = True
) -> compiled.UnorderedIR:
"""Defines transformation but isn't cached, always use compile_node instead"""
raise ValueError(f"Can't compile unnrecognized node: {node}")
raise ValueError(f"Can't compile unrecognized node: {node}")


@_compile_node.register
Expand Down