-
Notifications
You must be signed in to change notification settings - Fork 697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SEDONA-196] Add ST_Force3D #856
Conversation
This reverts commit c7f6236.
This reverts commit 85ae113.
Changed generic Exception to IllegalArgumentException in ST_NumPoints implementation and its corresponding test
# Conflicts: # common/src/main/java/org/apache/sedona/common/Functions.java # common/src/test/java/org/apache/sedona/common/FunctionsTest.java # flink/src/main/java/org/apache/sedona/flink/Catalog.java # flink/src/main/java/org/apache/sedona/flink/expressions/Functions.java # flink/src/test/java/org/apache/sedona/flink/FunctionTest.java # python/sedona/sql/st_functions.py # python/tests/sql/test_function.py # sql/common/src/main/scala/org/apache/sedona/sql/UDF/Catalog.scala # sql/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Functions.scala # sql/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/st_functions.scala # sql/common/src/test/scala/org/apache/sedona/sql/dataFrameAPITestScala.scala # sql/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
Refactored function name Made java tests more comprehensive by checking both nDims and WKT of returned geometry Added more test cases in scala test cases Updated documentation with empty geometry case and more examples
@@ -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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the test case that has no zvalue supplied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/
docs/api/sql/Function.md
Outdated
|
||
Input: `LINESTRING(0 1, 1 2, 2 1)` | ||
|
||
Output: `LINESTRING(0 1 0, 1 2 0, 2 1 0)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the output LINESTRING Z
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you're right, updated the documentation with a note explaining the output
@@ -148,6 +148,7 @@ object Catalog { | |||
function[ST_AreaSpheroid](), | |||
function[ST_LengthSpheroid](), | |||
function[ST_NumPoints](), | |||
function[ST_Force3D](), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/
Did you read the Contributor Guide?
Is this PR related to a JIRA ticket?
[SEDONA-XXX] my subject
.What changes were proposed in this PR?
How was this patch tested?
Did this PR include necessary documentation updates?
v1.4.1
format.