Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8cfaca6
docs: remove import bigframes.pandas as bpd boilerplate from many sam…
tswast Oct 7, 2025
c85d47f
fix docs
tswast Oct 7, 2025
78bfccf
fix unit tests
tswast Oct 7, 2025
210dc9a
skip sklearn test
tswast Oct 7, 2025
bed4069
fix snapshot
tswast Oct 7, 2025
aa23fca
Merge branch 'main' into tswast-doctest-boilerplate
tswast Oct 7, 2025
20cae2d
plumb through session for from_tuples and from_arrays
tswast Oct 8, 2025
f57a8c3
Merge remote-tracking branch 'origin/main' into tswast-doctest-boiler…
tswast Oct 8, 2025
d8ab16b
Merge remote-tracking branch 'origin/tswast-doctest-boilerplate' into…
tswast Oct 8, 2025
1dc648b
add from_frame
tswast Oct 8, 2025
9de6f9f
make sure polars session isnt skipped on Kokoro
tswast Oct 8, 2025
5d23dee
fix apply doctest
tswast Oct 8, 2025
20d7c27
make doctest conftest available everywhere
tswast Oct 8, 2025
534471e
Merge remote-tracking branch 'origin/main' into tswast-doctest-boiler…
tswast Oct 8, 2025
fbe606e
add python version flexibility for to_dict
tswast Oct 8, 2025
171f3ec
disambiguate explicit names
tswast Oct 8, 2025
ded5c1e
disambiguate explicit name none versus no name
tswast Oct 8, 2025
841bc64
fix for column name comparison in pandas bin op
tswast Oct 8, 2025
81f49a6
avoid setting column labels in special case of Series(block)
tswast Oct 8, 2025
f7a017a
Merge remote-tracking branch 'origin/main' into tswast-polars-session…
tswast Oct 8, 2025
5b60505
revert doctest changes
tswast Oct 8, 2025
a97cc93
revert doctest changes
tswast Oct 8, 2025
5aaacfe
revert df docstrings
tswast Oct 8, 2025
922bbf4
add polars series unit tests
tswast Oct 8, 2025
765b678
restore a test
tswast Oct 8, 2025
4aa47a8
Revert "restore a test"
tswast Oct 8, 2025
f75f5bf
skip null
tswast Oct 8, 2025
a7058ac
skip unsupported tests
tswast Oct 8, 2025
62d5911
revert more docs changes
tswast Oct 8, 2025
70021f3
revert more docs
tswast Oct 8, 2025
9350209
revert more docs
tswast Oct 8, 2025
23346b0
fix unit tests python 3.13
tswast Oct 9, 2025
03822d7
add test to reproduce name error
tswast Oct 9, 2025
dc02baf
Merge remote-tracking branch 'origin/main' into tswast-polars-session…
tswast Oct 9, 2025
ddbb32d
revert new session methods
tswast Oct 9, 2025
d80bfcb
fix TestSession read_pandas for Series
tswast Oct 9, 2025
0a5a935
revert more unnecessary changes
tswast Oct 9, 2025
1126244
even more
tswast Oct 9, 2025
d63a95f
add unit_noextras to improve code coverage
tswast Oct 9, 2025
6a8f694
Merge remote-tracking branch 'origin/main' into tswast-polars-session…
tswast Oct 9, 2025
6aadbaf
run system tests on latest fully supported
tswast Oct 9, 2025
95e4394
system-3.12 not found
tswast Oct 9, 2025
d33147a
cap polars version
tswast Oct 9, 2025
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
4 changes: 2 additions & 2 deletions bigframes/core/compile/polars/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,9 @@ def compile_agg_op(
if isinstance(op, agg_ops.MedianOp):
return pl.median(*inputs)
if isinstance(op, agg_ops.AllOp):
return pl.all(*inputs)
return pl.col(inputs).cast(pl.Boolean).all()
if isinstance(op, agg_ops.AnyOp):
return pl.any(*inputs) # type: ignore
return pl.col(inputs).cast(pl.Boolean).any()
if isinstance(op, agg_ops.NuniqueOp):
return pl.col(*inputs).drop_nulls().n_unique()
if isinstance(op, agg_ops.MinOp):
Expand Down
17 changes: 15 additions & 2 deletions bigframes/testing/polars_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,24 @@ def __init__(self):
self._loader = None # type: ignore

def read_pandas(self, pandas_dataframe, write_engine="default"):
original_input = pandas_dataframe

# override read_pandas to always keep data local-only
if isinstance(pandas_dataframe, pandas.Series):
if isinstance(pandas_dataframe, (pandas.Series, pandas.Index)):
pandas_dataframe = pandas_dataframe.to_frame()

local_block = bigframes.core.blocks.Block.from_local(pandas_dataframe, self)
return bigframes.dataframe.DataFrame(local_block)
bf_df = bigframes.dataframe.DataFrame(local_block)

if isinstance(original_input, pandas.Series):
series = bf_df[bf_df.columns[0]]
series.name = original_input.name
return series

if isinstance(original_input, pandas.Index):
return bf_df.index

return bf_df

@property
def bqclient(self):
Expand Down
11 changes: 5 additions & 6 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@
"3.11",
]

# pytest-retry is not yet compatible with pytest 8.x.
# https://github.com/str0zzapreti/pytest-retry/issues/32
PYTEST_VERSION = "pytest<8.0.0dev"
PYTEST_VERSION = "pytest==8.4.2"
SPHINX_VERSION = "sphinx==4.5.0"
LINT_PATHS = [
"docs",
Expand Down Expand Up @@ -91,7 +89,7 @@
# 3.10 is needed for Windows tests as it is the only version installed in the
# bigframes-windows container image. For more information, search
# bigframes/windows-docker, internally.
SYSTEM_TEST_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.13"]
SYSTEM_TEST_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12", "3.13"]
SYSTEM_TEST_STANDARD_DEPENDENCIES = [
"jinja2",
"mock",
Expand All @@ -115,7 +113,7 @@
# Make sure we leave some versions without "extras" so we know those
# dependencies are actually optional.
"3.10": ["tests", "scikit-learn", "anywidget"],
"3.11": ["tests", "scikit-learn", "polars", "anywidget"],
LATEST_FULLY_SUPPORTED_PYTHON: ["tests", "scikit-learn", "polars", "anywidget"],
"3.13": ["tests", "polars", "anywidget"],
}

Expand All @@ -126,8 +124,9 @@
# Sessions are executed in the order so putting the smaller sessions
# ahead to fail fast at presubmit running.
nox.options.sessions = [
"unit_noextras",
"system-3.9", # No extras.
"system-3.11",
f"system-{LATEST_FULLY_SUPPORTED_PYTHON}", # All extras.
"cover",
# TODO(b/401609005): remove
"cleanup",
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@
"google-cloud-pubsub >=2.21.4",
],
# used for local engine
"polars": ["polars >= 1.21.0"],
# TODO(tswast): relax upper pin when issue with test_engines_astype_int
# and test_divmods_series is resolved.
"polars": ["polars >= 1.21.0, <1.34.0"],
"scikit-learn": ["scikit-learn>=1.2.2"],
# Packages required for basic development flow.
"dev": [
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_local_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ def small_inline_frame() -> pd.DataFrame:
return df


def test_polars_local_engine_series(polars_session: bigframes.Session):
bf_series = bpd.Series([1, 2, 3], session=polars_session)
pd_series = pd.Series([1, 2, 3], dtype=bf_series.dtype)
bf_result = bf_series.to_pandas()
pd_result = pd_series
pandas.testing.assert_series_equal(bf_result, pd_result, check_index_type=False)


def test_polars_local_engine_add(
small_inline_frame: pd.DataFrame, polars_session: bigframes.Session
):
Expand Down
Loading