From a3f1def50d0bf1aa3e95a86f492c8facd6477c60 Mon Sep 17 00:00:00 2001 From: Vu Anh Phung Date: Wed, 19 Aug 2026 17:45:45 +0000 Subject: [PATCH 1/3] feat(pyo3): expose statement row limit Signed-off-by: Vu Anh Phung --- pyo3/NEXT_CHANGELOG.md | 2 ++ pyo3/src/statement.rs | 7 +++++++ pyo3/tests/test_execute.py | 16 ++++++++++++++++ pyo3/tests/test_module.py | 4 ++++ 4 files changed, 29 insertions(+) diff --git a/pyo3/NEXT_CHANGELOG.md b/pyo3/NEXT_CHANGELOG.md index 191ce3b4..a352ecc7 100644 --- a/pyo3/NEXT_CHANGELOG.md +++ b/pyo3/NEXT_CHANGELOG.md @@ -15,6 +15,8 @@ changes go in the root `NEXT_CHANGELOG.md`. - `Session(..., identity_federation_client_id=...)` selects SP-wide Workload Identity Federation during mandatory token exchange. +- `Statement.set_row_limit(...)` sets the SEA server-side row cap; passing + `None` clears it. ### Updated diff --git a/pyo3/src/statement.rs b/pyo3/src/statement.rs index 0810b117..0ef923b7 100644 --- a/pyo3/src/statement.rs +++ b/pyo3/src/statement.rs @@ -66,6 +66,13 @@ impl Statement { Ok(()) } + /// Set the server-side row cap for this statement. ``None`` clears it. + fn set_row_limit(&mut self, row_limit: Option) -> PyResult<()> { + let inner = alive_mut!(self, "Statement"); + inner.stmt.spec().row_limit(row_limit); + Ok(()) + } + /// Set per-statement query tags. /// /// ``tags`` is a ``dict[str, str | None]`` — a ``None`` value emits diff --git a/pyo3/tests/test_execute.py b/pyo3/tests/test_execute.py index 19fa9220..fb74ac11 100644 --- a/pyo3/tests/test_execute.py +++ b/pyo3/tests/test_execute.py @@ -58,6 +58,22 @@ def test_range_drains_to_pyarrow_table(session): stmt.close() +@pytest.mark.parametrize("row_limit", [None, 0, 1, 5]) +@live +def test_row_limit(session, row_limit): + stmt = session.statement() + stmt.set_sql("SELECT id FROM range(10) ORDER BY id") + stmt.set_row_limit(row_limit) + exec_ = stmt.execute() + try: + table = exec_.fetch_all_arrow() + expected = list(range(10 if row_limit is None else row_limit)) + assert table.column(0).to_pylist() == expected + finally: + exec_.close() + stmt.close() + + @live def test_executed_statement_double_close_is_idempotent(session): stmt = session.statement() diff --git a/pyo3/tests/test_module.py b/pyo3/tests/test_module.py index 93f79a55..d059dfab 100644 --- a/pyo3/tests/test_module.py +++ b/pyo3/tests/test_module.py @@ -36,3 +36,7 @@ def test_exports_expected_classes(): } actual = {n for n in dir(k) if not n.startswith("_")} assert expected.issubset(actual), f"missing exports: {expected - actual}" + + +def test_statement_exposes_row_limit(): + assert callable(k.Statement.set_row_limit) From 48eed166bdaba6b571f6ae976cb5bea93b079a59 Mon Sep 17 00:00:00 2001 From: Vu Anh Phung Date: Wed, 19 Aug 2026 18:33:19 +0000 Subject: [PATCH 2/3] docs(pyo3): clarify zero row limit forwarding Signed-off-by: Vu Anh Phung --- pyo3/src/statement.rs | 4 +++- pyo3/tests/test_execute.py | 2 +- src/statement/mutable.rs | 15 +++++++++------ src/statement/spec.rs | 4 +++- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/pyo3/src/statement.rs b/pyo3/src/statement.rs index 0ef923b7..5ffdbaf5 100644 --- a/pyo3/src/statement.rs +++ b/pyo3/src/statement.rs @@ -66,7 +66,9 @@ impl Statement { Ok(()) } - /// Set the server-side row cap for this statement. ``None`` clears it. + /// Set the SEA ``row_limit`` field for this statement. ``None`` omits it. + /// Values are forwarded verbatim, including ``0``; this method does not + /// apply JDBC ``maxRows`` normalization (where ``0`` means unlimited). fn set_row_limit(&mut self, row_limit: Option) -> PyResult<()> { let inner = alive_mut!(self, "Statement"); inner.stmt.spec().row_limit(row_limit); diff --git a/pyo3/tests/test_execute.py b/pyo3/tests/test_execute.py index fb74ac11..04f2ae54 100644 --- a/pyo3/tests/test_execute.py +++ b/pyo3/tests/test_execute.py @@ -58,7 +58,7 @@ def test_range_drains_to_pyarrow_table(session): stmt.close() -@pytest.mark.parametrize("row_limit", [None, 0, 1, 5]) +@pytest.mark.parametrize("row_limit", [None, 1, 5]) @live def test_row_limit(session, row_limit): stmt = session.statement() diff --git a/src/statement/mutable.rs b/src/statement/mutable.rs index 0102aa74..7edd483d 100644 --- a/src/statement/mutable.rs +++ b/src/statement/mutable.rs @@ -900,12 +900,15 @@ mod tests { fn build_execute_params_threads_row_limit_to_wire() { // Headline parity feature: spec.row_limit must reach // ExecuteParams.row_limit. A regression dropping it would otherwise - // pass every other test (the seam this pins). - let mut spec = StatementSpec::new(); - spec.sql("SELECT 1").row_limit(Some(100)); - let (sql, params) = build_execute_params(&spec, None).unwrap(); - assert_eq!(sql, "SELECT 1"); - assert_eq!(params.row_limit, Some(100)); + // pass every other test (the seam this pins). Zero is intentionally + // forwarded rather than normalized to None as JDBC maxRows would be. + for row_limit in [0, 100] { + let mut spec = StatementSpec::new(); + spec.sql("SELECT 1").row_limit(Some(row_limit)); + let (sql, params) = build_execute_params(&spec, None).unwrap(); + assert_eq!(sql, "SELECT 1"); + assert_eq!(params.row_limit, Some(row_limit)); + } } #[test] diff --git a/src/statement/spec.rs b/src/statement/spec.rs index 288bb0ae..f5e84e58 100644 --- a/src/statement/spec.rs +++ b/src/statement/spec.rs @@ -387,7 +387,9 @@ impl StatementSpec { Ok(self) } - /// Set the server-side row cap (SEA `row_limit`). `None` clears it. + /// Set the SEA `row_limit` field. `None` omits it. Values are forwarded + /// verbatim, including `0`; this does not apply JDBC `maxRows` + /// normalization (where `0` means unlimited). pub fn row_limit(&mut self, row_limit: Option) -> &mut Self { self.row_limit = row_limit; self From a8ada52bbd26afa68b78e19d921a755ddf44d5cf Mon Sep 17 00:00:00 2001 From: Vu Anh Phung Date: Wed, 19 Aug 2026 22:32:14 +0000 Subject: [PATCH 3/3] docs(pyo3): remove zero-specific guidance Signed-off-by: Vu Anh Phung --- pyo3/src/statement.rs | 4 +--- src/statement/mutable.rs | 15 ++++++--------- src/statement/spec.rs | 4 +--- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/pyo3/src/statement.rs b/pyo3/src/statement.rs index 5ffdbaf5..0ef923b7 100644 --- a/pyo3/src/statement.rs +++ b/pyo3/src/statement.rs @@ -66,9 +66,7 @@ impl Statement { Ok(()) } - /// Set the SEA ``row_limit`` field for this statement. ``None`` omits it. - /// Values are forwarded verbatim, including ``0``; this method does not - /// apply JDBC ``maxRows`` normalization (where ``0`` means unlimited). + /// Set the server-side row cap for this statement. ``None`` clears it. fn set_row_limit(&mut self, row_limit: Option) -> PyResult<()> { let inner = alive_mut!(self, "Statement"); inner.stmt.spec().row_limit(row_limit); diff --git a/src/statement/mutable.rs b/src/statement/mutable.rs index 7edd483d..0102aa74 100644 --- a/src/statement/mutable.rs +++ b/src/statement/mutable.rs @@ -900,15 +900,12 @@ mod tests { fn build_execute_params_threads_row_limit_to_wire() { // Headline parity feature: spec.row_limit must reach // ExecuteParams.row_limit. A regression dropping it would otherwise - // pass every other test (the seam this pins). Zero is intentionally - // forwarded rather than normalized to None as JDBC maxRows would be. - for row_limit in [0, 100] { - let mut spec = StatementSpec::new(); - spec.sql("SELECT 1").row_limit(Some(row_limit)); - let (sql, params) = build_execute_params(&spec, None).unwrap(); - assert_eq!(sql, "SELECT 1"); - assert_eq!(params.row_limit, Some(row_limit)); - } + // pass every other test (the seam this pins). + let mut spec = StatementSpec::new(); + spec.sql("SELECT 1").row_limit(Some(100)); + let (sql, params) = build_execute_params(&spec, None).unwrap(); + assert_eq!(sql, "SELECT 1"); + assert_eq!(params.row_limit, Some(100)); } #[test] diff --git a/src/statement/spec.rs b/src/statement/spec.rs index f5e84e58..288bb0ae 100644 --- a/src/statement/spec.rs +++ b/src/statement/spec.rs @@ -387,9 +387,7 @@ impl StatementSpec { Ok(self) } - /// Set the SEA `row_limit` field. `None` omits it. Values are forwarded - /// verbatim, including `0`; this does not apply JDBC `maxRows` - /// normalization (where `0` means unlimited). + /// Set the server-side row cap (SEA `row_limit`). `None` clears it. pub fn row_limit(&mut self, row_limit: Option) -> &mut Self { self.row_limit = row_limit; self