jiayuasu commented on code in PR #2256:
URL: https://github.com/apache/sedona/pull/2256#discussion_r2264469765
##########
spark/common/src/test/scala/org/apache/sedona/sql/geography/ConstructorsTest.scala:
##########
@@ -73,4 +73,31 @@ class ConstructorsTest extends TestBaseScala {
"GEOMETRYCOLLECTION (POINT (50 50), LINESTRING (20 30, 40 60, 80 90),
POLYGON ((35 15, 45 15, 40 25, 35 15), (30 10, 40 20, 30 20, 30 10)))"
assert(expected.equals(actual))
}
+
+ it("Passed ST_GeogFromWKB") {
+ // RAW binary array
+ val wkbSeq = Seq[Array[Byte]](
+ Array[Byte](1, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, -124, -42, 0, -64, 0,
0, 0, 0, -128, -75,
+ -42, -65, 0, 0, 0, 96, -31, -17, -9, -65, 0, 0, 0, -128, 7, 93, -27,
-65))
+ val rawWkbDf = wkbSeq.toDF("wkb")
+ rawWkbDf.createOrReplaceTempView("rawWKBTable")
+ val geometries = {
+ sparkSession.sql("SELECT ST_GeogFromWKB(rawWKBTable.wkb) as countyshape
from rawWKBTable")
+ }
+ val expectedGeom =
+ "LINESTRING (-2.1047439575195317 -0.35482788085937506,
-1.4960645437240603 -0.6676061153411864)"
+ assert(
+ geometries
+ .first()
+ .getAs[Geography](0)
+ .toString(new PrecisionModel(1e16))
+ .equals(expectedGeom))
+ // null input
+ val nullGeom = sparkSession.sql("SELECT ST_GeogFromWKB(null)")
+ assert(nullGeom.first().isNullAt(0))
+ // Fail on wrong input type
+ intercept[Exception] {
+ sparkSession.sql("SELECT ST_GeogFromWKB(0)").collect()
Review Comment:
Please make sure this only intercept the corresponding wrong input type
exception instead of all exception. Otherwise it has no use.
For example, the old code throws a real exception which shouldn't be
intercepted.
If it is not possible to do so, please remove this intercept completely as
it has no use
--
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]