Skip to content

Commit bc69438

Browse files
committed
update var names
1 parent 4213afb commit bc69438

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

connectorx-python/connectorx/__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def read_sql(
266266
query: list[str] | str,
267267
*,
268268
return_type: Literal[
269-
"pandas", "polars", "arrow", "modin", "dask", "arrow_record_batches"
269+
"pandas", "polars", "arrow", "modin", "dask", "arrow_stream"
270270
] = "pandas",
271271
protocol: Protocol | None = None,
272272
partition_on: str | None = None,
@@ -288,7 +288,7 @@ def read_sql(
288288
query
289289
a SQL query or a list of SQL queries.
290290
return_type
291-
the return type of this function; one of "arrow(2)", "arrow_record_batches", "pandas", "modin", "dask" or "polars(2)".
291+
the return type of this function; one of "arrow", "arrow_stream", "pandas", "modin", "dask" or "polars".
292292
protocol
293293
backend-specific transfer protocol directive; defaults to 'binary' (except for redshift
294294
connection strings, where 'cursor' will be used instead).
@@ -301,10 +301,12 @@ def read_sql(
301301
index_col
302302
the index column to set; only applicable for return type "pandas", "modin", "dask".
303303
strategy
304-
strategy of rewriting the federated query for join pushdown
304+
strategy of rewriting the federated query for join pushdown.
305305
pre_execution_query
306306
SQL query or list of SQL queries executed before main query; can be used to set runtime
307307
configurations using SET statements; only applicable for source "Postgres" and "MySQL".
308+
batch_size
309+
the maximum size of each batch when return type is `arrow_stream`.
308310
309311
Examples
310312
========
@@ -431,16 +433,16 @@ def read_sql(
431433
except AttributeError:
432434
# previous polars api (< 0.8.*) was pl.DataFrame.from_arrow
433435
df = pl.DataFrame.from_arrow(df)
434-
elif return_type in {"arrow_record_batches"}:
435-
record_batch_size = int(kwargs.get("record_batch_size", 10000))
436+
elif return_type in {"arrow_stream"}:
437+
batch_size = int(kwargs.get("batch_size", 10000))
436438
result = _read_sql(
437439
conn,
438-
"arrow_record_batches",
440+
"arrow_stream",
439441
queries=queries,
440442
protocol=protocol,
441443
partition_query=partition_query,
442444
pre_execution_queries=pre_execution_queries,
443-
record_batch_size=record_batch_size
445+
batch_size=batch_size
444446
)
445447

446448
df = reconstruct_arrow_rb(result)

connectorx-python/connectorx/connectorx.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def read_sql(
3131
@overload
3232
def read_sql(
3333
conn: str,
34-
return_type: Literal["arrow", "arrow_record_batches"],
34+
return_type: Literal["arrow", "arrow_stream"],
3535
protocol: str | None,
3636
queries: list[str] | None,
3737
partition_query: dict[str, Any] | None,

connectorx-python/connectorx/tests/test_arrow.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def test_arrow_stream(postgres_url: str) -> None:
5050
reader = read_sql(
5151
postgres_url,
5252
query,
53-
return_type="arrow_record_batches",
54-
record_batch_size=2,
53+
return_type="arrow_stream",
54+
batch_size=2,
5555
)
5656
batches = []
5757
for batch in reader:
@@ -85,8 +85,8 @@ def test_arrow_stream_with_partition(postgres_url: str) -> None:
8585
partition_on="test_int",
8686
partition_range=(0, 2000),
8787
partition_num=3,
88-
return_type="arrow_record_batches",
89-
record_batch_size=2,
88+
return_type="arrow_stream",
89+
batch_size=2,
9090
)
9191
batches = []
9292
for batch in reader:

connectorx-python/src/cx_read_sql.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ pub fn read_sql<'py>(
7474
&queries,
7575
pre_execution_queries.as_deref(),
7676
)?),
77-
"arrow_record_batches" => {
77+
"arrow_stream" => {
7878
let batch_size = kwargs
79-
.and_then(|dict| dict.get_item("record_batch_size").ok().flatten())
79+
.and_then(|dict| dict.get_item("batch_size").ok().flatten())
8080
.and_then(|obj| obj.extract::<usize>().ok())
8181
.unwrap_or(10000);
8282

0 commit comments

Comments
 (0)