diff --git a/python/pyspark/sql/tests/test_types.py b/python/pyspark/sql/tests/test_types.py index d665053d94904..80f2c0fcbc033 100644 --- a/python/pyspark/sql/tests/test_types.py +++ b/python/pyspark/sql/tests/test_types.py @@ -192,6 +192,7 @@ def __init__(self): Row(a=1), Row("a")(1), A(), + Row(b=Row(c=datetime.datetime(1970, 1, 1, 0, 0))), ] df = self.spark.createDataFrame([data]) @@ -214,6 +215,7 @@ def __init__(self): "struct", "struct", "struct", + "struct>", ] self.assertEqual(actual, expected) @@ -236,14 +238,25 @@ def __init__(self): Row(a=1), Row(a=1), Row(a=1), + Row(b=Row(c=datetime.datetime(1970, 1, 1, 0, 0))), ] self.assertEqual(actual, expected) with self.sql_conf({"spark.sql.timestampType": "TIMESTAMP_NTZ"}): with self.sql_conf({"spark.sql.session.timeZone": "America/Sao_Paulo"}): - df = self.spark.createDataFrame([(datetime.datetime(1970, 1, 1, 0, 0),)]) + data = [ + ( + datetime.datetime(1970, 1, 1, 0, 0), + Row(a=Row(a=datetime.datetime(1970, 1, 1, 0, 0))), + ) + ] + df = self.spark.createDataFrame(data) self.assertEqual(list(df.schema)[0].dataType.simpleString(), "timestamp_ntz") self.assertEqual(df.first()[0], datetime.datetime(1970, 1, 1, 0, 0)) + self.assertEqual( + list(df.schema)[1].dataType.simpleString(), "struct>" + ) + self.assertEqual(df.first()[1], Row(a=Row(a=datetime.datetime(1970, 1, 1, 0, 0)))) df = self.spark.createDataFrame( [