@@ -1417,13 +1417,24 @@ def to_pyarrow(
1417
1417
params : Mapping [ir .Scalar , Any ] | None = None ,
1418
1418
limit : int | str | None = None ,
1419
1419
** kwargs : Any ,
1420
+ ) -> pa .Table | pa .Array | pa .Scalar :
1421
+ pa_table = self ._to_pyarrow_table (expr , params = params , limit = limit , ** kwargs )
1422
+ return expr .__pyarrow_result__ (pa_table )
1423
+
1424
+ def _to_pyarrow_table (
1425
+ self ,
1426
+ expr : ir .Expr ,
1427
+ / ,
1428
+ * ,
1429
+ params : Mapping [ir .Scalar , Any ] | None = None ,
1430
+ limit : int | str | None = None ,
1431
+ ** kwargs : Any ,
1420
1432
) -> pa .Table :
1421
1433
from ibis .backends .duckdb .converter import DuckDBPyArrowData
1422
1434
1423
- table = self ._to_duckdb_relation (
1424
- expr , params = params , limit = limit , ** kwargs
1425
- ).arrow ()
1426
- return expr .__pyarrow_result__ (table , data_mapper = DuckDBPyArrowData )
1435
+ rel = self ._to_duckdb_relation (expr , params = params , limit = limit , ** kwargs )
1436
+ pa_table = rel .arrow ()
1437
+ return DuckDBPyArrowData .convert_table (pa_table , expr .as_table ().schema ())
1427
1438
1428
1439
def execute (
1429
1440
self ,
@@ -1441,9 +1452,7 @@ def execute(
1441
1452
1442
1453
from ibis .backends .duckdb .converter import DuckDBPandasData
1443
1454
1444
- rel = self ._to_duckdb_relation (expr , params = params , limit = limit , ** kwargs )
1445
- table = rel .arrow ()
1446
-
1455
+ pa_table = self ._to_pyarrow_table (expr , params = params , limit = limit , ** kwargs )
1447
1456
df = pd .DataFrame (
1448
1457
{
1449
1458
name : (
@@ -1457,11 +1466,10 @@ def execute(
1457
1466
)
1458
1467
else col .to_pandas ()
1459
1468
)
1460
- for name , col in zip (table .column_names , table .columns )
1469
+ for name , col in zip (pa_table .column_names , pa_table .columns )
1461
1470
}
1462
1471
)
1463
- df = DuckDBPandasData .convert_table (df , expr .as_table ().schema ())
1464
- return expr .__pandas_result__ (df )
1472
+ return expr .__pandas_result__ (df , data_mapper = DuckDBPandasData )
1465
1473
1466
1474
@util .experimental
1467
1475
def to_torch (
0 commit comments