[
https://issues.apache.org/jira/browse/SEDONA-153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17584562#comment-17584562
]
Jia Yu commented on SEDONA-153:
-------------------------------
[~dougdennis] My bad. ST_GeomFromWKT is nullable so if it gets a null input, it
returns null output. Please feel free to create a PR.
> Python Serialization Fails with Nulls
> -------------------------------------
>
> Key: SEDONA-153
> URL: https://issues.apache.org/jira/browse/SEDONA-153
> Project: Apache Sedona
> Issue Type: Bug
> Reporter: Doug Dennis
> Priority: Major
>
> The following currently fail due to Shapely not liking nulls/Nones:
> {code:python}
> def test_null_deserializer(self):
> result = self.spark.sql("select st_geomfromwkt(null)").collect()[0][0]
> assert result is None
> def test_null_serializer(self):
> data = [
> [1, None]
> ]
> schema = t.StructType(
> [
> t.StructField("id", IntegerType(), True),
> t.StructField("geom", GeometryType(), True),
> ]
> )
> self.spark.createDataFrame(
> data,
> schema
> ).createOrReplaceTempView("points")
> count = self.spark.sql("select count from points").collect()[0][0]
> assert count == 1
> {code}
> The solution is to add some null guards to methods in the python GeometryType
> class. I can make a PR for this but I wasn't sure if I needed to wait for
> this issue to be approved or acknowledged or something :)
> Edit: I adjusted the deserializer test. I accidentally used a previous
> version that fails on analysis. This version fails when the None is attempted
> to be iterated in Python.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)