jiayuasu commented on code in PR #856:
URL: https://github.com/apache/sedona/pull/856#discussion_r1225726308
##########
sql/common/src/test/scala/org/apache/sedona/sql/dataFrameAPITestScala.scala:
##########
@@ -957,5 +957,13 @@ class dataFrameAPITestScala extends TestBaseScala {
val expectedResult = 3
assert(actualResult == expectedResult)
}
+
+ it("Passed ST_Force3D") {
+ val lineDf = sparkSession.sql("SELECT
ST_Force3D(ST_GeomFromWKT('LINESTRING (0 1, 1 0, 2 0)'), 2.3) AS geom")
Review Comment:
Please add the test case that has no zvalue supplied.
##########
flink/src/test/java/org/apache/sedona/flink/FunctionTest.java:
##########
@@ -699,4 +699,14 @@ public void testNumPoints() {
assertEquals(expected, actual);
}
+ @Test
Review Comment:
In Sedona Flink, the ST_Force3D has 2 overloaded `eval` functions. Please
test both funcs in the test.
##########
docs/api/sql/Function.md:
##########
@@ -576,6 +576,46 @@ Result:
+---------------------------------------------------------------+
```
+## ST_Force3D
+Introduction: Forces the geometry into a 3-dimensional model so that all
output representations will have X, Y and Z coordinates.
+An optionally given zValue is tacked onto the geometry if the geometry is
2-dimensional. Default value of zValue is 0.0
+If the given geometry is 3-dimensional, no change is performed on it.
+If the given geometry is empty, no change is performed on it.
+
+Format: `ST_Force3D(geometry, zValue)`
+
+Since: `1.4.1`
+
+Spark SQL Example:
+
+```sql
+SELECT ST_Force3D(geometry) AS geom
+```
+
+Input: `LINESTRING(0 1, 1 2, 2 1)`
+
+Output: `LINESTRING(0 1 0, 1 2 0, 2 1 0)`
Review Comment:
Isn't the output `LINESTRING Z`?
##########
sql/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala:
##########
@@ -1921,4 +1921,18 @@ class functionTestScala extends TestBaseScala with
Matchers with GeometrySample
assertEquals(expected, actual)
}
}
+
+ it("should pass ST_Force3D") {
+ val geomTestCases = Map(
+ ("'LINESTRING (0 1, 1 0, 2 0)'") -> "'LINESTRING Z(0 1 1, 1 0 1, 2 0
1)'",
+ ("'LINESTRING Z(0 1 3, 1 0 3, 2 0 3)'") -> "'LINESTRING Z(0 1 3, 1 0 3,
2 0 3)'",
+ ("'LINESTRING EMPTY'") -> "'LINESTRING EMPTY'"
+ )
+ for (((geom), expectedResult) <- geomTestCases) {
+ val df = sparkSession.sql(s"SELECT
ST_AsText(ST_Force3D(ST_GeomFromWKT($geom), 1)) AS geom, " + s"$expectedResult")
Review Comment:
Please add the test case that has no default zValue supplied
##########
flink/src/main/java/org/apache/sedona/flink/Catalog.java:
##########
@@ -95,7 +95,8 @@ public static UserDefinedFunction[] getFuncs() {
new Functions.ST_Split(),
new Functions.ST_S2CellIDs(),
new Functions.ST_GeometricMedian(),
- new Functions.ST_NumPoints()
+ new Functions.ST_NumPoints(),
+ new Functions.ST_Force3D()
Review Comment:
You might need to provide a default parameter here since the zValue is
optional.
--
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]