This is an automated email from the ASF dual-hosted git repository.
ruifengz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 70a3ab5daa48 [MINOR][PYTHON][TESTS] Add test for Row with duplicated
field names
70a3ab5daa48 is described below
commit 70a3ab5daa4831935748867239549900815c9651
Author: Ruifeng Zheng <[email protected]>
AuthorDate: Mon Jan 19 09:13:03 2026 +0800
[MINOR][PYTHON][TESTS] Add test for Row with duplicated field names
### What changes were proposed in this pull request?
Add test for Row with duplicated field names
### Why are the changes needed?
We rely on such behavior, but we don't have any test for it.
### Does this PR introduce _any_ user-facing change?
NO, test-only
### How was this patch tested?
CI
### Was this patch authored or co-authored using generative AI tooling?
NO
Closes #53808 from zhengruifeng/test_row_duplicated_names.
Authored-by: Ruifeng Zheng <[email protected]>
Signed-off-by: Ruifeng Zheng <[email protected]>
---
python/pyspark/sql/tests/test_types.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/python/pyspark/sql/tests/test_types.py
b/python/pyspark/sql/tests/test_types.py
index ad5761ecd561..824bd7419ce3 100644
--- a/python/pyspark/sql/tests/test_types.py
+++ b/python/pyspark/sql/tests/test_types.py
@@ -69,6 +69,7 @@ from pyspark.sql.types import (
NullType,
VariantType,
VariantVal,
+ _create_row,
)
from pyspark.sql.types import (
_array_signed_int_typecode_ctype_mappings,
@@ -3014,6 +3015,25 @@ class DataTypeTests(unittest.TestCase):
row_class = Row("c1", "c2")
self.assertRaises(ValueError, lambda: row_class(1, 2, 3))
+ def test_row_with_duplicated_fields(self):
+ for fields, values, expected in [
+ (["a", "a"], [1, 1], "Row(a=1, a=1)"),
+ (["a", "a", "a", "b", "b"], [1, 2, 3, 4, 5], "Row(a=1, a=2, a=3,
b=4, b=5)"),
+ (["a", "a"], [1, _create_row(["a", "a"], [2, 3])], "Row(a=1,
a=Row(a=2, a=3))"),
+ (["a", "a"], [1, _create_row(["b", "b"], [2, 2])], "Row(a=1,
a=Row(b=2, b=2))"),
+ ]:
+ row = _create_row(fields, values)
+ self.assertEqual(str(row), expected)
+
+ r = _create_row(["a", "a", "a"], [1, 2, 3])
+ self.assertEqual(r.a, 1)
+ self.assertEqual(r["a"], 1)
+ self.assertEqual(r[0], 1)
+ self.assertEqual(r[1], 2)
+ self.assertEqual(r[2], 3)
+ self.assertEqual(list(r), [1, 2, 3])
+ self.assertEqual([v for v in r], [1, 2, 3])
+
class DataTypeVerificationTests(unittest.TestCase, PySparkErrorTestUtils):
def test_verify_type_exception_msg(self):
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]