Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-46255][PYTHON][CONNECT] Support complex type -> string conversion #44171

Closed
wants to merge 1 commit into from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 0 additions & 16 deletions python/pyspark/sql/connect/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,22 +222,6 @@ def convert_string(value: Any) -> Any:
if value is None:
return None
else:
# only atomic types are supported
assert isinstance(
value,
(
bool,
int,
float,
str,
bytes,
bytearray,
decimal.Decimal,
datetime.date,
datetime.datetime,
datetime.timedelta,
),
)
if isinstance(value, bool):
# To match the PySpark which convert bool to string in
# the JVM side (python.EvaluatePython.makeFromJava)
Expand Down
13 changes: 13 additions & 0 deletions python/pyspark/sql/tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,19 @@ def test_convert_row_to_dict(self):
self.assertEqual(1, row.asDict()["l"][0].a)
self.assertEqual(1.0, row.asDict()["d"]["key"].c)

def test_convert_list_to_str(self):
data = [[[123], 120]]
schema = StructType(
[
StructField("name", StringType(), True),
StructField("income", LongType(), True),
]
)
df = self.spark.createDataFrame(data, schema)
self.assertEqual(df.schema, schema)
self.assertEqual(df.count(), 1)
self.assertEqual(df.head(), Row(name="[123]", income=120))

def test_udt(self):
from pyspark.sql.types import _parse_datatype_json_string, _infer_type, _make_type_verifier

Expand Down