[ 
https://issues.apache.org/jira/browse/SEDONA-153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17584474#comment-17584474
 ] 

Jia Yu commented on SEDONA-153:
-------------------------------

[~imbruced] 

[~dougdennis] 

This is actually a behavior from Sedona Scala/Java side as ST_GeomFromWKT 
(implemented in Scala) could throw exceptions for null. We thought this is 
expected as we do not want to allow null for geometry constructors.

 

If you want to add this guard in either Python or Scala side, what will it do?

> 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)

Reply via email to