From a05b1cacf18f675f34ed8389d2bb5d361b7a48db Mon Sep 17 00:00:00 2001 From: Oliver Borchert Date: Wed, 2 Sep 2026 17:42:28 -0700 Subject: [PATCH 1/2] test: Fix tests for polars v2.0.0rc1 --- tests/schema/test_validate.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/schema/test_validate.py b/tests/schema/test_validate.py index 1f1a515..1159cdc 100644 --- a/tests/schema/test_validate.py +++ b/tests/schema/test_validate.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause from pathlib import Path +from typing import Literal import polars as pl import polars.exceptions as plexc @@ -55,6 +56,7 @@ def _validate_and_collect( df: pl.DataFrame | pl.LazyFrame, *, cast: bool = False, + engine: Literal["auto", "in-memory"] = "auto", ) -> pl.DataFrame: # Whether validation is performed eagerly is now determined by the input type: an # eager data frame raises within `validate`, a lazy frame raises upon collection. @@ -64,7 +66,7 @@ def _validate_and_collect( return result else: assert isinstance(result, pl.LazyFrame) - return result.collect() + return result.collect(engine=engine) # -------------------------------------- SCHEMA -------------------------------------- # @@ -146,7 +148,8 @@ def test_invalid_primary_key_with_examples( ValidationError if eager else plexc.ComputeError, match=r"'primary_key' failed for 2 rows; examples: \[\{'a': 1\}\]", ): - _validate_and_collect(MySchema, df) + # Streaming validation fails fast and may only count the first batch. + _validate_and_collect(MySchema, df, engine="in-memory") @pytest.mark.parametrize("df_type", [pl.DataFrame, pl.LazyFrame]) From d5bb90a0d1def11de09031f448d7eb222ef3a4e8 Mon Sep 17 00:00:00 2001 From: Oliver Borchert Date: Thu, 3 Sep 2026 16:33:23 +0200 Subject: [PATCH 2/2] Update comment for lazy validation in test Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- tests/schema/test_validate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/schema/test_validate.py b/tests/schema/test_validate.py index 1159cdc..62c092c 100644 --- a/tests/schema/test_validate.py +++ b/tests/schema/test_validate.py @@ -148,7 +148,7 @@ def test_invalid_primary_key_with_examples( ValidationError if eager else plexc.ComputeError, match=r"'primary_key' failed for 2 rows; examples: \[\{'a': 1\}\]", ): - # Streaming validation fails fast and may only count the first batch. + # For lazy validation, Polars' streaming engine can fail fast and may only count the first batch. _validate_and_collect(MySchema, df, engine="in-memory")