Copilot commented on code in PR #2420:
URL: https://github.com/apache/sedona/pull/2420#discussion_r2450309178
##########
spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala:
##########
@@ -4130,4 +4132,70 @@ class functionTestScala
squareWithTwoHolesSimplified.first().getAs[org.locationtech.jts.geom.Geometry](0)
assert(simplifiedMedialAxis != null, "Simplified medial axis should not be
null")
}
+
+ it("Test that CREATE VIEW fails with multiple temporary Sedona functions") {
+ val timestamp = System.currentTimeMillis()
+ val tmpDir: String =
+
Files.createTempDirectory("sedona_geoparquet_test_").toFile.getAbsolutePath
+
+ val buildings = sparkSession.sql("""
+ SELECT
+ ST_GeomFromWKT('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))') as geom,
+ 'Building 1' as PROP_ADDR
+ UNION ALL
+ SELECT
+ ST_GeomFromWKT('POLYGON((2 2, 3 2, 3 3, 2 3, 2 2))') as geom,
+ 'Building 2' as PROP_ADDR
+ """)
+ buildings.write
+ .mode("overwrite")
+ .option("path", s"$tmpDir/sedona_test_${timestamp}_buildings")
+ .saveAsTable("nyc_buildings_geom_test")
+
+ val zones = sparkSession.sql("""
+ SELECT
+ ST_GeomFromWKT('POLYGON((0 0, 5 0, 5 5, 0 5, 0 0))') as zone_geom,
+ 100.0 as elevation
+ """)
+ zones.write
+ .mode("overwrite")
+ .option("path", s"$tmpDir/sedona_test_${timestamp}_zones")
+ .saveAsTable("elevation_zones_test")
+
+ // Attempt to create a permanent VIEW with multiple Sedona functions
+ sparkSession.sql("""
+ CREATE VIEW nyc_buildings_with_functions AS
+ SELECT * FROM (
+ SELECT
+ nyc_buildings_geom_test.PROP_ADDR AS name,
+ nyc_buildings_geom_test.geom AS building_geom,
+ avg(elevation_zones_test.elevation) AS elevation
+ FROM
+ nyc_buildings_geom_test
+ JOIN
+ elevation_zones_test
+ ON
+ st_intersects(elevation_zones_test.zone_geom,
elevation_zones_test.zone_geom)
Review Comment:
The st_intersects function compares elevation_zones_test.zone_geom with
itself, which will always return true. This should likely be
st_intersects(elevation_zones_test.zone_geom, nyc_buildings_geom_test.geom) to
test the actual spatial relationship between buildings and zones.
```suggestion
st_intersects(nyc_buildings_geom_test.geom,
elevation_zones_test.zone_geom)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]