Skip to content

Commit b7f650c

Browse files
committed
fix(pyarrow): avoid catching ValueError and hiding legitimate failures
1 parent c83494f commit b7f650c

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

ibis/backends/base/__init__.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -327,23 +327,18 @@ def to_pyarrow(
327327
"""
328328
pa = self._import_pyarrow()
329329
self._run_pre_execute_hooks(expr)
330+
330331
table_expr = expr.as_table()
331-
arrow_schema = table_expr.schema().to_pyarrow()
332-
try:
333-
with self.to_pyarrow_batches(
334-
table_expr, params=params, limit=limit, **kwargs
335-
) as reader:
336-
table = (
337-
pa.Table.from_batches(reader)
338-
.rename_columns(table_expr.columns)
339-
.cast(arrow_schema)
340-
)
341-
except pa.lib.ArrowInvalid:
342-
raise
343-
except ValueError:
344-
table = arrow_schema.empty_table()
345-
346-
return expr.__pyarrow_result__(table)
332+
schema = table_expr.schema()
333+
arrow_schema = schema.to_pyarrow()
334+
with self.to_pyarrow_batches(
335+
table_expr, params=params, limit=limit, **kwargs
336+
) as reader:
337+
table = pa.Table.from_batches(reader, schema=arrow_schema)
338+
339+
return expr.__pyarrow_result__(
340+
table.rename_columns(table_expr.columns).cast(arrow_schema)
341+
)
347342

348343
@util.experimental
349344
def to_pyarrow_batches(

0 commit comments

Comments
 (0)