sedona
sedona copied to clipboard
Bug: ST_Withins returns False when comparing identical polygons
spark.sql("""
SELECT
ST_Within(
ST_GeomFromText('POINT (1 1)'),
ST_GeomFromText('POINT (1 1)')
), -- True
ST_Within(
ST_GeomFromText('POLYGON ((0 0, 1 0, 2 1, 3 1, 0 0))'),
ST_GeomFromText('POLYGON ((0 0, 1 0, 2 1, 3 1, 0 0))')
), -- False
ST_Within(
ST_GeomFromText('MULTIPOLYGON (((0 0, 1 1, 0 1, 0 0)))'),
ST_GeomFromText('MULTIPOLYGON (((0 0, 1 1, 0 1, 0 0)))')
) -- True
""").show()
Above is a query testing ST_Within on identical objects for Points, Polygons, and Multipolygons. The second case for Polygons returns False.
In the PostGIS implementation of ST_Within, "The within relation is reflexive: every geometry is within itself" so I'm guessing the second case is what's wrong.