Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions python/pyspark/sql/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,12 @@ def test_to_local_iterator_not_fully_consumed(self):
break
self.assertEqual(df.take(8), result)

def test_different_col_order(self):
row = self.spark.createDataFrame(
self.sc.parallelize([Row(A="1", B="2")]), "B string, A string").first()
self.assertEqual(row['A'], "1")
self.assertEqual(row['B'], "2")


class QueryExecutionListenerTests(unittest.TestCase, SQLTestUtils):
# These tests are separate because it uses 'spark.sql.queryExecutionListeners' which is
Expand Down
2 changes: 2 additions & 0 deletions python/pyspark/sql/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,8 @@ def toInternal(self, obj):
return tuple(obj.get(n) for n in self.names)
elif isinstance(obj, Row) and getattr(obj, "__from_dict__", False):
return tuple(obj[n] for n in self.names)
elif isinstance(obj, Row) and hasattr(obj, "__fields__"):
return tuple(obj[n] for n in self.names)
elif isinstance(obj, (list, tuple)):
return tuple(obj)
elif hasattr(obj, "__dict__"):
Expand Down