jorisvandenbossche commented on code in PR #14048:
URL: https://github.com/apache/arrow/pull/14048#discussion_r965595748
##########
python/pyarrow/table.pxi:
##########
@@ -3401,6 +3401,9 @@ cdef class Table(_PandasConvertible):
.format(self.schema.names, target_schema.names))
for column, field in zip(self.itercolumns(), target_schema):
+ if column.null_count > 0 and not field.nullable:
+ raise RuntimeError("Casting field {!r} with null values to
non-nullable"
Review Comment:
I think this can be a ValueError
##########
python/pyarrow/table.pxi:
##########
@@ -3401,6 +3401,9 @@ cdef class Table(_PandasConvertible):
.format(self.schema.names, target_schema.names))
for column, field in zip(self.itercolumns(), target_schema):
+ if column.null_count > 0 and not field.nullable:
Review Comment:
```suggestion
if not field.nullable and column.null_count > 0:
```
Switching the order will avoid checking the null_count (potentially
expensive) if the field is nullable (which will be the most common case, since
this is the default)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]