Github user gberger commented on a diff in the pull request:
https://github.com/apache/spark/pull/19792#discussion_r156971910
--- Diff: python/pyspark/sql/types.py ---
@@ -1083,7 +1083,11 @@ def _infer_schema(row):
elif hasattr(row, "_fields"): # namedtuple
items = zip(row._fields, tuple(row))
else:
- names = ['_%d' % i for i in range(1, len(row) + 1)]
+ if names is None:
+ names = ['_%d' % i for i in range(1, len(row) + 1)]
+ elif len(names) < len(row):
+ names = names[:]
--- End diff --
Yes, I did not want to modify the original list since `.extend` is an
in-place operation. However, session.py#602 already creates a copy of the list
passed by the user, so this copying in `_infer_schema` is actually not
necessary. Removing now.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]