jiayuasu commented on code in PR #856:
URL: https://github.com/apache/sedona/pull/856#discussion_r1225942927


##########
sql/common/src/main/scala/org/apache/sedona/sql/UDF/Catalog.scala:
##########
@@ -148,6 +148,7 @@ object Catalog {
     function[ST_AreaSpheroid](),
     function[ST_LengthSpheroid](),
     function[ST_NumPoints](),
+    function[ST_Force3D](),

Review Comment:
   Please use ST_MinimumBoundingCirle's implementation as an example: (1) 
Function definition: 
https://github.com/apache/sedona/blob/master/sql/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Functions.scala#LL473C12-L473C36
   (2) Function catalog registration: 
https://github.com/apache/sedona/blob/master/sql/common/src/main/scala/org/apache/sedona/sql/UDF/Catalog.scala#L102
   
   The default value of the optional parameters must be supplied in the 
Function Catalog otherwise this is not an optional parameter.



##########
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:
   Same here: add a test case like ST_Force3D(geom), no z value is supplied. 
This will test the correctness of the the optional parameter.



##########
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:
   In addition, the test cases didn't test the correctness of the DataFrame 
style API, it mistakenly repeated the SQL test cases. Please read other test 
cases in this file and learn how to test DataFrame style APIs.
   
   Explanation of Sedona DataFrame style APIs: 
https://sedona.apache.org/latest-snapshot/api/sql/DataFrameAPI/



##########
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:
   What I mean is, add a test case like ST_Force3D(geom), no z value is 
supplied. This will test the correctness of the the optional parameter.



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

Reply via email to