jiayuasu commented on code in PR #2260:
URL: https://github.com/apache/sedona/pull/2260#discussion_r2267979600
##########
spark/common/src/test/scala/org/apache/sedona/sql/geography/ConstructorsTest.scala:
##########
@@ -96,4 +96,31 @@ class ConstructorsTest extends TestBaseScala {
val nullGeom = sparkSession.sql("SELECT ST_GeogFromWKB(null)")
assert(nullGeom.first().isNullAt(0))
}
+
+ it("Passed ST_GeogFromEWKB") {
+ // UTF-8 encoded WKB String
+ val mixedWkbGeometryInputLocation =
+ getClass.getResource("/county_small_wkb.tsv").getPath
+ val polygonWkbDf = sparkSession.read
+ .format("csv")
+ .option("delimiter", "\t")
+ .option("header", "false")
+ .load(mixedWkbGeometryInputLocation)
+ polygonWkbDf.createOrReplaceTempView("polygontable")
+ val polygonDf = sparkSession.sql(
+ "select ST_GeogFromEWKB(polygontable._c0) as countyshape from
polygontable")
+ assert(polygonDf.count() == 100)
+ // 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_GeogFromEWKB(rawWKBTable.wkb) as countyshape
from rawWKBTable")
+ val expectedGeom = {
+ "LINESTRING (-2.1 -0.4, -1.5 -0.7)"
Review Comment:
Please test if SRID is preserved. Don't use test a WKT string.
--
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]