Skip to content

Commit 07d7f2a

Browse files
committed
Add comments
thanks @viirya
1 parent 403f579 commit 07d7f2a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

python/pyspark/sql/pandas/conversion.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ def _create_from_pandas_with_arrow(self, pdf, schema, timezone):
398398
for s in (pdf[c] for c in pdf)]
399399
struct = StructType()
400400
for name, t in zip(schema, inferred_types):
401+
# nullability is not determined on types inferred by Arrow or
402+
# by the non-Arrow conversion path, so default to nullable
401403
struct.add(name, from_arrow_type(t), nullable=True)
402404
schema = struct
403405

python/pyspark/sql/pandas/serializers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ def create_array(s, t):
164164
s = s.astype(s.dtypes.categories.dtype)
165165
try:
166166
mask = s.isnull()
167-
# pass _ndarray_values to avoid potential failed type checks from pandas array types
167+
# pass _ndarray_values to avoid erroneous failed type checks from pandas array types
168+
# that do not implement __arrow_array__ (i.e. pre-1.0.0 IntegerArray)
168169
array = pa.Array.from_pandas(s._ndarray_values, mask=mask, type=t,
169170
safe=self._safecheck)
170171
except pa.ArrowException as e:

0 commit comments

Comments
 (0)