qudade commented on a change in pull request #26118: [SPARK-24915][PySpark] Fix Row handling with Schema. URL: https://github.com/apache/spark/pull/26118#discussion_r335021018
########## File path: python/pyspark/sql/types.py ########## @@ -599,6 +599,8 @@ def toInternal(self, obj): if isinstance(obj, dict): return tuple(f.toInternal(obj.get(n)) if c else obj.get(n) for n, f, c in zip(self.names, self.fields, self._needConversion)) + elif isinstance(obj, Row): + return self.toInternal(obj.asDict()) Review comment: yes, but because `Row` also behaves like a `dict` (as in `row[colName]`) the tuple handling can be off. e.g. if you have `row = Row(name='Alice', date=date(2019,10,1))` the underlying tuple reverses the order of fields (see examples above). How about `elif isinstance(obj, Row) and getattr(obj, "__from_dict__", False):` as in https://github.com/apache/spark/blob/master/python/pyspark/sql/types.py#L614 ? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org