[
https://issues.apache.org/jira/browse/SEDONA-119?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17614892#comment-17614892
]
Kristin Cowalcijk commented on SEDONA-119:
------------------------------------------
Spatial joins in SQL were translated to {{JoinQuery.SpatialJoinQuery}} calls by
a Spark planner extension. Since {{JoinQuery.SpatialJoinQuery}} only supports
intersects and covers as spatial predicate, so the translation was inaccurate
and leads to incorrect results.
There're 2 possible ways to fix this problem:
# Perform a post-filtering on join results. We can add {{predicate}} to
{{extraCondition}} when predicate is not one of {{ST_Intersects}},
{{ST_Covers}} and {{ST_CoveredBy}}. This makes joins with predicates such as
{{ST_Touches}} suffer from redundant spatial relationship computations (one
extra query.covers(geom) call).
# Add support to more spatial predicates in RDD API.
Currently we're working on the 2nd approach, I've opened another ticket for
discussing RDD API changes related to this issue.
> ST_Touches join query returns true for polygons whose interiors intersect
> -------------------------------------------------------------------------
>
> Key: SEDONA-119
> URL: https://issues.apache.org/jira/browse/SEDONA-119
> Project: Apache Sedona
> Issue Type: Bug
> Affects Versions: 1.2.1
> Reporter: Dimitris Bilidas
> Priority: Major
>
> Consider the following example:
>
> {code:java}
> var polygonDf1 = sparkSession.sql("select ST_GeomFromWKT('POLYGON ((0 0, 10
> 10, 10 0, 0 0))') as p1")
> polygonDf1.createOrReplaceTempView("polygondf1")
> var polygonDf2 = sparkSession.sql("select ST_GeomFromWKT('POLYGON ((0 0, 1 1,
> 1 0, 0 0))') as p2")
> polygonDf2.createOrReplaceTempView("polygondf2")
> var rangeJoinDf = sparkSession.sql("select * from polygondf1, polygondf2
> where ST_Touches(polygondf1.p1,polygondf2.p2) ") {code}
> The correct result should be empty, but SEDONA returns a result.
>
> In case of a spatial filter, the correct result is returned. That is, if we
> replace the last query with:
> {code:java}
> select * from polygondf1 where
> ST_Touches(polygondf1.p1,ST_GeomFromWKT('POLYGON ((0 0, 1 1, 1 0, 0
> 0))')){code}
> Then, the result is indeed empty.
> I have checked that JTS version 1.18.2 returns the correct answer, so the
> problem must be somewhere else.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)