This is an automated email from the ASF dual-hosted git repository.

jiayu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sedona.git


The following commit(s) were added to refs/heads/master by this push:
     new c878485ef [SEDONA-575] [SEDONA-577] Add ST_LineFromWKB, 
ST_GeometryFromText (#1443)
c878485ef is described below

commit c878485ef7f5941baa2871d6f0cc03b782e41a5c
Author: Jia Yu <[email protected]>
AuthorDate: Tue May 28 22:53:56 2024 -0700

    [SEDONA-575] [SEDONA-577] Add ST_LineFromWKB, ST_GeometryFromText (#1443)
    
    * [TASK-137] Add ST_LineFromWKB (#151)
    
    * init
    
    * init 2
    
    * add flink test
    
    * add scala, python, snowflake tests
    
    * add docs
    
    * Fix scala implementation
    
    * Fix test
    
    * Add ST_LineFromWKB
    
    * fix typo
    
    * Fix scala implementation
    
    * add scala dataframeapi test
    
    * Add flink tests
    
    * Add python dataframeapi test
    
    * Fix test
    
    * Fix doc
    
    * Fix test
    
    * Add tests
    
    * Fix test
    
    * Fix typo
    
    * Update docs
    
    * Update versions
    
    * [TASK-156] Add ST_GeometryFromText (#155)
    
    * feat: add ST_GeometryFromText
    
    * feat: add ST_GeometryFromText optional parameter
    
    * Update versions
    
    * Fix lint
    
    ---------
    
    Co-authored-by: Pranav Toggi <[email protected]>
    Co-authored-by: Furqaan Khan <[email protected]>
---
 .../org/apache/sedona/common/Constructors.java     | 13 +++++
 .../org/apache/sedona/common/FunctionsTest.java    | 20 +++++++
 docs/api/flink/Constructor.md                      | 55 +++++++++++++++++++
 docs/api/flink/Function.md                         |  4 +-
 docs/api/snowflake/vector-data/Constructor.md      | 51 +++++++++++++++++
 docs/api/sql/Constructor.md                        | 55 +++++++++++++++++++
 docs/api/sql/Function.md                           |  4 +-
 .../main/java/org/apache/sedona/flink/Catalog.java |  2 +
 .../sedona/flink/expressions/Constructors.java     | 50 +++++++++++++++--
 .../org/apache/sedona/flink/ConstructorTest.java   | 64 +++++++++++++++++++++-
 python/sedona/sql/st_constructors.py               | 28 ++++++++++
 python/tests/sql/test_constructor_test.py          | 13 +++++
 python/tests/sql/test_dataframe_api.py             |  3 +
 .../sedona/snowflake/snowsql/TestConstructors.java | 31 +++++++++++
 .../org/apache/sedona/snowflake/snowsql/UDFs.java  | 28 ++++++++++
 .../scala/org/apache/sedona/sql/UDF/Catalog.scala  |  2 +
 .../sql/sedona_sql/expressions/Constructors.scala  | 58 ++++++++++++++++++++
 .../sedona_sql/expressions/st_constructors.scala   | 13 +++++
 .../apache/sedona/sql/constructorTestScala.scala   | 54 ++++++++++++++++++
 .../apache/sedona/sql/dataFrameAPITestScala.scala  | 27 +++++++++
 20 files changed, 564 insertions(+), 11 deletions(-)

diff --git a/common/src/main/java/org/apache/sedona/common/Constructors.java 
b/common/src/main/java/org/apache/sedona/common/Constructors.java
index 6dd348c01..e33789ab6 100644
--- a/common/src/main/java/org/apache/sedona/common/Constructors.java
+++ b/common/src/main/java/org/apache/sedona/common/Constructors.java
@@ -79,6 +79,19 @@ public class Constructors {
         return geom;
     }
 
+    public  static Geometry lineFromWKB(byte[] wkb) throws ParseException {
+        return lineFromWKB(wkb, 0);
+    }
+
+    public static Geometry lineFromWKB(byte[] wkb, int srid) throws 
ParseException {
+        GeometryFactory geometryFactory = new GeometryFactory(new 
PrecisionModel(), srid);
+        Geometry geom =  new WKBReader(geometryFactory).read(wkb);
+        if (!(geom instanceof LineString)) {
+            return null;
+        }
+        return geom;
+    }
+
     public static Geometry mLineFromText(String wkt, int srid) throws 
ParseException {
         if (wkt == null || !wkt.startsWith("MULTILINESTRING")) {
             return null;
diff --git a/common/src/test/java/org/apache/sedona/common/FunctionsTest.java 
b/common/src/test/java/org/apache/sedona/common/FunctionsTest.java
index 6d15e20ca..4fe7d1578 100644
--- a/common/src/test/java/org/apache/sedona/common/FunctionsTest.java
+++ b/common/src/test/java/org/apache/sedona/common/FunctionsTest.java
@@ -152,6 +152,26 @@ public class FunctionsTest extends TestBase {
         assertNull(result);
     }
 
+    @Test
+    public void lineFromWKB() throws Exception{
+        Geometry geometry = GEOMETRY_FACTORY.createPoint(new Coordinate(1.0, 
2.0));
+        byte[] wkbGeom = Functions.asWKB(geometry);
+        Geometry result = Constructors.lineFromWKB(wkbGeom);
+        assertNull(result);
+
+        geometry = GEOMETRY_FACTORY.createLineString(coordArray(0.0, 0.0, 5.0, 
5.0, 5.0, 2.0));
+        wkbGeom = Functions.asWKB(geometry);
+        result = Constructors.lineFromWKB(wkbGeom, 4326);
+        assertEquals(geometry, result);
+        assertEquals(4326, Objects.requireNonNull(result).getSRID());
+
+        geometry = GEOMETRY_FACTORY.createLineString(coordArray(0.0, 0.0, 1.5, 
1.5, 2.0, 2.0));
+        wkbGeom = Functions.asWKB(geometry);
+        result = Constructors.lineFromWKB(wkbGeom);
+        assertEquals(geometry, result);
+        assertEquals(0, Objects.requireNonNull(result).getSRID());
+    }
+
     @Test
     public void splitLineStringByMultipoint() {
         LineString lineString = 
GEOMETRY_FACTORY.createLineString(coordArray(0.0, 0.0, 1.5, 1.5, 2.0, 2.0));
diff --git a/docs/api/flink/Constructor.md b/docs/api/flink/Constructor.md
index 3f26e08b7..a28542f26 100644
--- a/docs/api/flink/Constructor.md
+++ b/docs/api/flink/Constructor.md
@@ -291,6 +291,30 @@ Output:
 POINT(40.7128 -74.006)
 ```
 
+## ST_GeometryFromText
+
+Introduction: Construct a Geometry from WKT. If SRID is not set, it defaults 
to 0 (unknown). Alias of [ST_GeomFromWKT](#st_geomfromwkt)
+
+Format:
+
+`ST_GeometryFromText (Wkt: String)`
+
+`ST_GeometryFromText (Wkt: String, srid: Integer)`
+
+Since: `v1.6.1`
+
+SQL Example
+
+```sql
+SELECT ST_GeometryFromText('POINT(40.7128 -74.0060)')
+```
+
+Output:
+
+```
+POINT(40.7128 -74.006)
+```
+
 ## ST_LineFromText
 
 Introduction: Construct a LineString from Text
@@ -331,6 +355,37 @@ Output:
 LINESTRING (-74.0428197 40.6867969, -74.0421975 40.6921336, -74.050802 
40.6912794)
 ```
 
+## ST_LineFromWKB
+
+Introduction: Construct a LineString geometry from WKB string or Binary and an 
optional SRID. This function also supports EWKB format.
+
+!!!note
+    Returns null if geometry is not of type LineString.
+
+Format:
+
+`ST_LineFromWKB (Wkb: String)`
+
+`ST_LineFromWKB (Wkb: Binary)`
+
+`ST_LineFromWKB (Wkb: String, srid: Integer)`
+
+`ST_LineFromWKB (Wkb: Binary, srid: Integer)`
+
+Since: `v1.6.1`
+
+Example:
+
+```sql
+SELECT ST_LineFromWKB([01 02 00 00 00 02 00 00 00 00 00 00 00 84 D6 00 C0 00 
00 00 00 80 B5 D6 BF 00 00 00 60 E1 EF F7 BF 00 00 00 80 07 5D E5 BF])
+```
+
+Output:
+
+```
+LINESTRING (-2.1047439575195312 -0.354827880859375, -1.49606454372406 
-0.6676061153411865)
+```
+
 ## ST_MLineFromText
 
 Introduction: Construct a MultiLineString from Text and Optional SRID
diff --git a/docs/api/flink/Function.md b/docs/api/flink/Function.md
index 318c97354..28726f8b6 100644
--- a/docs/api/flink/Function.md
+++ b/docs/api/flink/Function.md
@@ -2074,7 +2074,7 @@ Introduction: Returns M maxima of the given geometry or 
null if there is no M co
 
 Format: `ST_MMax(geom: Geometry)`
 
-Since: `vTBD`
+Since: `v1.6.1`
 
 SQL Example
 
@@ -2096,7 +2096,7 @@ Introduction: Returns M minima of the given geometry or 
null if there is no M co
 
 Format: `ST_MMin(geom: Geometry)`
 
-Since: `vTBD`
+Since: `v1.6.1`
 
 SQL Example:
 
diff --git a/docs/api/snowflake/vector-data/Constructor.md 
b/docs/api/snowflake/vector-data/Constructor.md
index 796f77994..a87046def 100644
--- a/docs/api/snowflake/vector-data/Constructor.md
+++ b/docs/api/snowflake/vector-data/Constructor.md
@@ -266,6 +266,28 @@ Output:
 POINT(40.7128 -74.006)
 ```
 
+## ST_GeometryFromText
+
+Introduction: Construct a Geometry from WKT. If SRID is not set, it defaults 
to 0 (unknown). Alias of [ST_GeomFromWKT](#st_geomfromwkt)
+
+Format:
+
+`ST_GeometryFromText (Wkt: String)`
+
+`ST_GeometryFromText (Wkt: String, srid: Integer)`
+
+SQL Example
+
+```sql
+SELECT ST_GeometryFromText('POINT(40.7128 -74.0060)')
+```
+
+Output:
+
+```
+POINT(40.7128 -74.006)
+```
+
 ## ST_LineFromText
 
 Introduction: Construct a Line from Wkt text
@@ -303,6 +325,35 @@ Output:
 LINESTRING (-74.0428197 40.6867969, -74.0421975 40.6921336, -74.050802 
40.6912794)
 ```
 
+## ST_LineFromWKB
+
+Introduction: Construct a LineString geometry from WKB string or Binary and an 
optional SRID. This function also supports EWKB format.
+
+!!!note
+    Returns null if geometry is not of type LineString.
+
+Format:
+
+`ST_LineFromWKB (Wkb: String)`
+
+`ST_LineFromWKB (Wkb: Binary)`
+
+`ST_LineFromWKB (Wkb: String, srid: Integer)`
+
+`ST_LineFromWKB (Wkb: Binary, srid: Integer)`
+
+Example:
+
+```sql
+SELECT ST_LineFromWKB([01 02 00 00 00 02 00 00 00 00 00 00 00 84 D6 00 C0 00 
00 00 00 80 B5 D6 BF 00 00 00 60 E1 EF F7 BF 00 00 00 80 07 5D E5 BF])
+```
+
+Output:
+
+```
+LINESTRING (-2.1047439575195312 -0.354827880859375, -1.49606454372406 
-0.6676061153411865)
+```
+
 ## ST_MLineFromText
 
 Introduction: Construct a MultiLineString from Wkt. If srid is not set, it 
defaults to 0 (unknown).
diff --git a/docs/api/sql/Constructor.md b/docs/api/sql/Constructor.md
index 0fdd8177d..6a5db0706 100644
--- a/docs/api/sql/Constructor.md
+++ b/docs/api/sql/Constructor.md
@@ -341,6 +341,30 @@ Output:
 POINT(40.7128 -74.006)
 ```
 
+## ST_GeometryFromText
+
+Introduction: Construct a Geometry from WKT. If SRID is not set, it defaults 
to 0 (unknown). Alias of [ST_GeomFromWKT](#st_geomfromwkt)
+
+Format:
+
+`ST_GeometryFromText (Wkt: String)`
+
+`ST_GeometryFromText (Wkt: String, srid: Integer)`
+
+Since: `v1.6.1`
+
+SQL Example
+
+```sql
+SELECT ST_GeometryFromText('POINT(40.7128 -74.0060)')
+```
+
+Output:
+
+```
+POINT(40.7128 -74.006)
+```
+
 ## ST_LineFromText
 
 Introduction: Construct a Line from Wkt text
@@ -382,6 +406,37 @@ Output:
 LINESTRING (-74.0428197 40.6867969, -74.0421975 40.6921336, -74.050802 
40.6912794)
 ```
 
+## ST_LineFromWKB
+
+Introduction: Construct a LineString geometry from WKB string or Binary and an 
optional SRID. This function also supports EWKB format.
+
+!!!note
+       Returns null if geometry is not of type LineString.
+
+Format:
+
+`ST_LineFromWKB (Wkb: String)`
+
+`ST_LineFromWKB (Wkb: Binary)`
+
+`ST_LineFromWKB (Wkb: String, srid: Integer)`
+
+`ST_LineFromWKB (Wkb: Binary, srid: Integer)`
+
+Since: `v1.6.1`
+
+Example:
+
+```sql
+SELECT ST_LineFromWKB([01 02 00 00 00 02 00 00 00 00 00 00 00 84 D6 00 C0 00 
00 00 00 80 B5 D6 BF 00 00 00 60 E1 EF F7 BF 00 00 00 80 07 5D E5 BF])
+```
+
+Output:
+
+```
+LINESTRING (-2.1047439575195312 -0.354827880859375, -1.49606454372406 
-0.6676061153411865)
+```
+
 ## ST_MLineFromText
 
 Introduction: Construct a MultiLineString from Wkt. If srid is not set, it 
defaults to 0 (unknown).
diff --git a/docs/api/sql/Function.md b/docs/api/sql/Function.md
index 928770887..a09573fa3 100644
--- a/docs/api/sql/Function.md
+++ b/docs/api/sql/Function.md
@@ -2081,7 +2081,7 @@ Introduction: Returns M maxima of the given geometry or 
null if there is no M co
 
 Format: `ST_MMax(geom: Geometry)`
 
-Since: `vTBD`
+Since: `v1.6.1`
 
 SQL Example
 
@@ -2103,7 +2103,7 @@ Introduction: Returns M minima of the given geometry or 
null if there is no M co
 
 Format: `ST_MMin(geom: Geometry)`
 
-Since: `vTBD`
+Since: `v1.6.1`
 
 SQL Example:
 
diff --git a/flink/src/main/java/org/apache/sedona/flink/Catalog.java 
b/flink/src/main/java/org/apache/sedona/flink/Catalog.java
index 6b5639f97..234e58b59 100644
--- a/flink/src/main/java/org/apache/sedona/flink/Catalog.java
+++ b/flink/src/main/java/org/apache/sedona/flink/Catalog.java
@@ -28,6 +28,7 @@ public class Catalog {
                 new Constructors.ST_PointZM(),
                 new Constructors.ST_PointFromText(),
                 new Constructors.ST_PointFromWKB(),
+                new Constructors.ST_LineFromWKB(),
                 new Constructors.ST_MakePoint(),
                 new Constructors.ST_LineStringFromText(),
                 new Constructors.ST_LineFromText(),
@@ -36,6 +37,7 @@ public class Catalog {
                 new Constructors.ST_GeomFromWKT(),
                 new Constructors.ST_GeomFromEWKT(),
                 new Constructors.ST_GeomFromText(),
+                new Constructors.ST_GeometryFromText(),
                 new Constructors.ST_GeomFromWKB(),
                 new Constructors.ST_GeomFromEWKB(),
                 new Constructors.ST_GeomFromGeoJSON(),
diff --git 
a/flink/src/main/java/org/apache/sedona/flink/expressions/Constructors.java 
b/flink/src/main/java/org/apache/sedona/flink/expressions/Constructors.java
index 1e8f87ded..cd53ac09d 100644
--- a/flink/src/main/java/org/apache/sedona/flink/expressions/Constructors.java
+++ b/flink/src/main/java/org/apache/sedona/flink/expressions/Constructors.java
@@ -19,10 +19,7 @@ import org.apache.sedona.common.enums.FileDataSplitter;
 import org.apache.sedona.common.enums.GeometryType;
 import org.apache.sedona.common.utils.FormatUtils;
 import org.apache.sedona.common.utils.GeoHashDecoder;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.GeometryFactory;
-import org.locationtech.jts.geom.Point;
+import org.locationtech.jts.geom.*;
 import org.locationtech.jts.io.WKBReader;
 import org.locationtech.jts.io.ParseException;
 import org.locationtech.jts.io.gml2.GMLReader;
@@ -183,6 +180,19 @@ public class Constructors {
         }
     }
 
+    public static class ST_GeometryFromText extends ScalarFunction {
+        @DataTypeHint(value = "RAW", bridgedTo = 
org.locationtech.jts.geom.Geometry.class)
+        public Geometry eval(@DataTypeHint("String") String wktString) throws 
ParseException {
+            return 
org.apache.sedona.common.Constructors.geomFromWKT(wktString, 0);
+        }
+
+
+        @DataTypeHint(value = "RAW", bridgedTo = 
org.locationtech.jts.geom.Geometry.class)
+        public Geometry eval(@DataTypeHint("String") String wktString, 
@DataTypeHint("Int") Integer srid) throws ParseException {
+            return 
org.apache.sedona.common.Constructors.geomFromWKT(wktString, srid);
+        }
+    }
+
     public static class ST_GeomFromText extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = 
org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint("String") String wktString) throws 
ParseException {
@@ -250,6 +260,38 @@ public class Constructors {
         }
     }
 
+    public static class ST_LineFromWKB extends ScalarFunction {
+        @DataTypeHint(value = "RAW", bridgedTo = Geometry.class)
+        public Geometry eval(@DataTypeHint("String") String wkbString) throws 
ParseException {
+            Geometry geometry = getGeometryByFileData(wkbString, 
FileDataSplitter.WKB);
+            if (geometry instanceof LineString) {
+                geometry.setSRID(0);
+                return geometry;
+            }
+            return null;  // Return null if geometry is not a Point
+        }
+
+        @DataTypeHint(value = "RAW", bridgedTo = Geometry.class)
+        public Geometry eval(@DataTypeHint("String") String wkbString, int 
srid) throws ParseException {
+            Geometry geometry = getGeometryByFileData(wkbString, 
FileDataSplitter.WKB);
+            if (geometry instanceof LineString) {
+                geometry.setSRID(srid);
+                return geometry;
+            }
+            return null;  // Return null if geometry is not a Linestring
+        }
+
+        @DataTypeHint(value = "RAW", bridgedTo = Geometry.class)
+        public Geometry eval(@DataTypeHint("Bytes") byte[] wkb) throws 
ParseException {
+            return org.apache.sedona.common.Constructors.lineFromWKB(wkb, 0);
+        }
+
+        @DataTypeHint(value = "RAW", bridgedTo = Geometry.class)
+        public Geometry eval(@DataTypeHint("Bytes") byte[] wkb, int srid) 
throws ParseException {
+            return org.apache.sedona.common.Constructors.lineFromWKB(wkb, 
srid);
+        }
+    }
+
     public static class ST_GeomFromGeoJSON extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = 
org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint("String") String geoJson) throws 
ParseException {
diff --git a/flink/src/test/java/org/apache/sedona/flink/ConstructorTest.java 
b/flink/src/test/java/org/apache/sedona/flink/ConstructorTest.java
index 7534dc072..b92d92100 100644
--- a/flink/src/test/java/org/apache/sedona/flink/ConstructorTest.java
+++ b/flink/src/test/java/org/apache/sedona/flink/ConstructorTest.java
@@ -13,10 +13,13 @@
  */
 package org.apache.sedona.flink;
 
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Hex;
 import org.apache.flink.table.api.Table;
 import org.apache.flink.types.Row;
 import org.apache.flink.streaming.api.datastream.DataStream;
 import org.apache.sedona.flink.expressions.Constructors;
+import org.apache.sedona.flink.expressions.Functions;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.locationtech.jts.geom.Coordinate;
@@ -254,6 +257,22 @@ public class ConstructorTest extends TestBase{
         assertEquals(data.get(data.size() - 1).getField(0).toString(), 
result.getField(0).toString());
     }
 
+    @Test
+    public void testGeometryFromText() {
+        List<Row> data = createPolygonWKT(testDataSize);
+        Table wktTable = createTextTable(data, polygonColNames);
+        Table geomTable = 
wktTable.select(call(Constructors.ST_GeometryFromText.class.getSimpleName(),
+                        $(polygonColNames[0])).as(polygonColNames[0]),
+                $(polygonColNames[1]));
+        Row result = last(geomTable);
+        assertEquals(data.get(data.size() - 1).getField(0).toString(), 
result.getField(0).toString());
+
+        geomTable  = 
wktTable.select(call(Constructors.ST_GeometryFromText.class.getSimpleName(),
+                    $(polygonColNames[0]), 4326));
+        int actual = (int) 
last(geomTable.select(call(Functions.ST_SRID.class.getSimpleName(), 
$("_c0")))).getField(0);
+        assertEquals(4326, actual);
+    }
+
     @Test
     public void testPolygonFromEnvelope() {
         Double minX = 1.0;
@@ -322,11 +341,11 @@ public class ConstructorTest extends TestBase{
     @Test
     public void testPointFromWKB() throws Exception {
         String hexWkb1 = "010100000000000000000000000000000000000000";
-        byte[] wkbPoint1 = 
org.apache.commons.codec.binary.Hex.decodeHex(hexWkb1);
+        byte[] wkbPoint1 = Hex.decodeHex(hexWkb1);
         String hexWkb2 = "010100000000000000000024400000000000002e40";
-        byte[] wkbPoint2 = 
org.apache.commons.codec.binary.Hex.decodeHex(hexWkb2);
+        byte[] wkbPoint2 = Hex.decodeHex(hexWkb2);
         String hexWkb3 = 
"01030000000100000005000000000000000000e0bf000000000000e0bf000000000000e0bf000000000000e03f000000000000e03f000000000000e03f000000000000e03f000000000000e0bf000000000000e0bf000000000000e0bf";
-        byte[] wkbPolygon = 
org.apache.commons.codec.binary.Hex.decodeHex(hexWkb3);
+        byte[] wkbPolygon = Hex.decodeHex(hexWkb3);
 
         List<Row> data1 = new ArrayList<>();
         data1.add(Row.of(wkbPoint1));
@@ -362,6 +381,45 @@ public class ConstructorTest extends TestBase{
         assertNull(results2.get(2).getField(0));
     }
 
+    @Test
+    public void testLineFromWKB() throws DecoderException {
+        String hexWkb1 = 
"010200000003000000000000000000000000000000000000000000000000000040000000000000004000000000000010400000000000001040";
+        byte[] wkbLine1 = Hex.decodeHex(hexWkb1);
+        String hexWkb2 = 
"010200000003000000000000000000000000000000000000000000000000407f400000000000407f400000000000407f4000000000000059c0";
+        byte[] wkbLine2 = Hex.decodeHex(hexWkb2);
+        String hexWkb3 = 
"01030000000100000005000000000000000000e0bf000000000000e0bf000000000000e0bf000000000000e03f000000000000e03f000000000000e03f000000000000e03f000000000000e0bf000000000000e0bf000000000000e0bf";
+        byte[] wkbPolygon = Hex.decodeHex(hexWkb3);
+
+        List<Row> data1 = Arrays.asList(Row.of(wkbLine1), Row.of(wkbLine2), 
Row.of(wkbPolygon));
+        List<Row> data2 = Arrays.asList(Row.of(hexWkb1), Row.of(hexWkb2), 
Row.of(hexWkb3));
+
+        TypeInformation<?>[] colTypes1 = 
{PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO};
+        TypeInformation<?>[] colTypes2 = {BasicTypeInfo.STRING_TYPE_INFO};
+        RowTypeInfo typeInfo1 = new RowTypeInfo(colTypes1, new 
String[]{"wkb"});
+        RowTypeInfo typeInfo2 = new RowTypeInfo(colTypes2, new 
String[]{"wkb"});
+
+        DataStream<Row> wkbDS1 = env.fromCollection(data1).returns(typeInfo1);
+        Table wkbTable1 = tableEnv.fromDataStream(wkbDS1, $("wkb"));
+
+        DataStream<Row> wkbDS2 = env.fromCollection(data2).returns(typeInfo2);
+        Table wkbTable2 = tableEnv.fromDataStream(wkbDS2, $("wkb"));
+
+        Table lineTable1 = 
wkbTable1.select(call(Constructors.ST_LineFromWKB.class.getSimpleName(), 
$("wkb")).as("point"));
+        Table lineTable2 = 
wkbTable2.select(call(Constructors.ST_LineFromWKB.class.getSimpleName(), 
$("wkb")).as("point"));
+
+        // Test with byte array
+        List<Row> results1 = TestBase.take(lineTable1, 3);
+        assertEquals("LINESTRING (0 0, 2 2, 4 4)", 
results1.get(0).getField(0).toString());
+        assertEquals("LINESTRING (0 0, 500 500, 500 -100)", 
results1.get(1).getField(0).toString());
+        assertNull(results1.get(2).getField(0));
+
+        // Test with hex string
+        List<Row> results2 = TestBase.take(lineTable2, 3);
+        assertEquals("LINESTRING (0 0, 2 2, 4 4)", 
results2.get(0).getField(0).toString());
+        assertEquals("LINESTRING (0 0, 500 500, 500 -100)", 
results2.get(1).getField(0).toString());
+        assertNull(results2.get(2).getField(0));
+    }
+
     @Test
     public void testGeomFromEWKB()
     {
diff --git a/python/sedona/sql/st_constructors.py 
b/python/sedona/sql/st_constructors.py
index fae53f49b..c0fb0fd26 100644
--- a/python/sedona/sql/st_constructors.py
+++ b/python/sedona/sql/st_constructors.py
@@ -97,6 +97,20 @@ def ST_GeomFromText(wkt: ColumnOrName, srid: 
Optional[ColumnOrNameOrNumber] = No
 
     return _call_constructor_function("ST_GeomFromText", args)
 
+@validate_argument_types
+def ST_GeometryFromText(wkt: ColumnOrName, srid: 
Optional[ColumnOrNameOrNumber] = None) -> Column:
+    """Generate a geometry column from a Well-Known Text (WKT) string column.
+    This is an alias of ST_GeomFromWKT.
+
+    :param wkt: WKT string column to generate from.
+    :type wkt: ColumnOrName
+    :return: Geometry column representing the WKT string.
+    :rtype: Column
+    """
+    args = (wkt) if srid is None else (wkt, srid)
+
+    return _call_constructor_function("ST_GeometryFromText", args)
+
 
 @validate_argument_types
 def ST_GeomFromWKB(wkb: ColumnOrName) -> Column:
@@ -271,6 +285,20 @@ def ST_PointFromWKB(wkb: ColumnOrName, srid: 
Optional[ColumnOrNameOrNumber] = No
     args = (wkb) if srid is None else (wkb, srid)
     return _call_constructor_function("ST_PointFromWKB", args)
 
+@validate_argument_types
+def ST_LineFromWKB(wkb: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = 
None) -> Column:
+    """Generate a Line geometry column from a Well-Known Binary (WKB) binary 
column.
+
+    :param wkb: WKB binary column to generate from.
+    :type wkb: ColumnOrName
+    :param srid: SRID to be set for the geometry.
+    :type srid: ColumnOrNameOrNumber
+    :return: Geometry column representing the WKB binary.
+    :rtype: Column
+    """
+    args = (wkb) if srid is None else (wkb, srid)
+    return _call_constructor_function("ST_LineFromWKB", args)
+
 @validate_argument_types
 def ST_MakePoint(x: ColumnOrNameOrNumber, y: ColumnOrNameOrNumber, z: 
Optional[ColumnOrNameOrNumber] = None, m: Optional[ColumnOrNameOrNumber] = 
None) -> Column:
     """Generate a 2D, 3D Z or 4D ZM Point geometry. If z is None then a 2D 
point is generated.
diff --git a/python/tests/sql/test_constructor_test.py 
b/python/tests/sql/test_constructor_test.py
index cdcf114da..c90c5db7a 100644
--- a/python/tests/sql/test_constructor_test.py
+++ b/python/tests/sql/test_constructor_test.py
@@ -115,6 +115,19 @@ class TestConstructors(TestBase):
         polygon_df.show(10)
         assert polygon_df.count() == 100
 
+    def test_st_geometry_from_text(self):
+        polygon_wkt_df = self.spark.read.format("csv").\
+            option("delimiter", "\t").\
+            option("header", "false").\
+            load(mixed_wkt_geometry_input_location)
+
+        polygon_wkt_df.createOrReplaceTempView("polygontable")
+        polygon_df = self.spark.sql("select 
ST_GeometryFromText(polygontable._c0) as countyshape from polygontable")
+        assert polygon_df.count() == 100
+
+        polygon_df = self.spark.sql("select ST_GeomFromText(polygontable._c0, 
4326) as countyshape from polygontable")
+        assert polygon_df.count() == 100
+
     def test_st_geom_from_wkb(self):
         polygon_wkb_df = self.spark.read.format("csv").\
             option("delimiter", "\t").\
diff --git a/python/tests/sql/test_dataframe_api.py 
b/python/tests/sql/test_dataframe_api.py
index 628aceefa..420a26ed1 100644
--- a/python/tests/sql/test_dataframe_api.py
+++ b/python/tests/sql/test_dataframe_api.py
@@ -44,12 +44,14 @@ test_configurations = [
     (stc.ST_GeomFromKML, ("kml",), "constructor", "", "LINESTRING (-71.16 
42.26, -71.17 42.26)"),
     (stc.ST_GeomFromText, ("wkt",), "linestring_wkt", "", "LINESTRING (1 2, 3 
4)"),
     (stc.ST_GeomFromText, ("wkt",4326), "linestring_wkt", "", "LINESTRING (1 
2, 3 4)"),
+    (stc.ST_GeometryFromText, ("wkt", 4326), "linestring_wkt", "", "LINESTRING 
(1 2, 3 4)"),
     (stc.ST_GeomFromWKB, ("wkbLine",), "constructor", 
"ST_ReducePrecision(geom, 2)", "LINESTRING (-2.1 -0.35, -1.5 -0.67)"),
     (stc.ST_GeomFromEWKB, ("wkbLine",), "constructor", 
"ST_ReducePrecision(geom, 2)", "LINESTRING (-2.1 -0.35, -1.5 -0.67)"),
     (stc.ST_GeomFromWKT, ("wkt",), "linestring_wkt", "", "LINESTRING (1 2, 3 
4)"),
     (stc.ST_GeomFromWKT, ("wkt",4326), "linestring_wkt", "", "LINESTRING (1 2, 
3 4)"),
     (stc.ST_GeomFromEWKT, ("ewkt",), "linestring_ewkt", "", "LINESTRING (1 2, 
3 4)"),
     (stc.ST_LineFromText, ("wkt",), "linestring_wkt", "", "LINESTRING (1 2, 3 
4)"),
+    (stc.ST_LineFromWKB, ("wkbLine",), "constructor", 
"ST_ReducePrecision(geom, 2)", "LINESTRING (-2.1 -0.35, -1.5 -0.67)"),
     (stc.ST_LineStringFromText, ("multiple_point", lambda: f.lit(',')), 
"constructor", "", "LINESTRING (0 0, 1 0, 1 1, 0 0)"),
     (stc.ST_Point, ("x", "y"), "constructor", "", "POINT (0 1)"),
     (stc.ST_PointZ, ("x", "y", "z", 4326), "constructor", "", "POINT Z (0 1 
2)"),
@@ -237,6 +239,7 @@ wrong_type_configurations = [
     (stc.ST_GeomFromWKB, (None,)),
     (stc.ST_GeomFromEWKB, (None,)),
     (stc.ST_GeomFromWKT, (None,)),
+    (stc.ST_GeometryFromText, (None,)),
     (stc.ST_LineFromText, (None,)),
     (stc.ST_LineStringFromText, (None, "")),
     (stc.ST_LineStringFromText, ("", None)),
diff --git 
a/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestConstructors.java
 
b/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestConstructors.java
index dd6e6bc4f..941b31fc6 100644
--- 
a/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestConstructors.java
+++ 
b/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestConstructors.java
@@ -81,6 +81,21 @@ public class TestConstructors extends TestBase{
                 "POINT (0 1)"
         );
     }
+
+    @Test
+    public void test_ST_GeometryFromText() {
+        registerUDF("ST_GeometryFromText", String.class);
+        verifySqlSingleRes(
+                "select sedona.ST_AsText(sedona.ST_GeometryFromText('POINT (0 
1)'))",
+                "POINT (0 1)"
+        );
+        registerUDF("ST_GeometryFromText", String.class, int.class);
+        verifySqlSingleRes(
+                "select sedona.ST_AsText(sedona.ST_GeometryFromText('POINT (0 
1)', 4326))",
+                "POINT (0 1)"
+        );
+    }
+
     @Test
     public void test_ST_GeomFromWKB() {
         registerUDF("ST_GeomFromWKB", byte[].class);
@@ -104,6 +119,22 @@ public class TestConstructors extends TestBase{
                 "SRID=4326;POINT (10 15)"
         );
     }
+
+    @Test
+    public void test_ST_LineFromWKB() {
+        registerUDF("ST_LineFromWKB", byte[].class);
+        registerUDF("ST_AsEWKT", byte[].class);
+        verifySqlSingleRes(
+                "select 
sedona.ST_AsText(sedona.ST_LineFromWKB(ST_ASWKB(to_geometry('LINESTRING (0 0, 2 
2, 4 4)'))))",
+                "LINESTRING (0 0, 2 2, 4 4)"
+        );
+        registerUDF("ST_LineFromWKB", byte[].class, int.class);
+        verifySqlSingleRes(
+                "select 
sedona.ST_AsEWKT(sedona.ST_LineFromWKB(ST_ASWKB(to_geometry('LINESTRING (0 0, 2 
2, 4 4)')), 4326))",
+                "SRID=4326;LINESTRING (0 0, 2 2, 4 4)"
+        );
+    }
+
     @Test
     public void test_ST_GeomFromEWKB() {
         registerUDF("ST_GeomFromEWKB", byte[].class);
diff --git 
a/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/UDFs.java 
b/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/UDFs.java
index 14c00a64f..a4ed232b6 100644
--- a/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/UDFs.java
+++ b/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/UDFs.java
@@ -492,6 +492,20 @@ public class UDFs {
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"wkt"})
+    public static byte[] ST_GeometryFromText(String geomString) throws 
ParseException {
+        return GeometrySerde.serialize(
+                Constructors.geomFromWKT(geomString, 0)
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"wkt", "srid"})
+    public static byte[] ST_GeometryFromText(String geomString, int srid) 
throws ParseException {
+        return GeometrySerde.serialize(
+                Constructors.geomFromWKT(geomString, srid)
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"wkb"})
     public static byte[] ST_GeomFromWKB(byte[] wkb) throws ParseException {
         return wkb;
@@ -964,6 +978,20 @@ public class UDFs {
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"wkb"})
+    public static byte[] ST_LineFromWKB(byte[] wkb) throws ParseException {
+        return GeometrySerde.serialize(
+                Constructors.lineFromWKB(wkb, 0)
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"wkb", "srid"})
+    public static byte[] ST_LineFromWKB(byte[] wkb, int srid) throws 
ParseException {
+        return GeometrySerde.serialize(
+                Constructors.lineFromWKB(wkb, srid)
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry", "srid"})
     public static byte[] ST_Polygon(byte[] geometry, int srid) {
         return GeometrySerde.serialize(
diff --git 
a/spark/common/src/main/scala/org/apache/sedona/sql/UDF/Catalog.scala 
b/spark/common/src/main/scala/org/apache/sedona/sql/UDF/Catalog.scala
index 3e7eacf0a..a411f67b7 100644
--- a/spark/common/src/main/scala/org/apache/sedona/sql/UDF/Catalog.scala
+++ b/spark/common/src/main/scala/org/apache/sedona/sql/UDF/Catalog.scala
@@ -39,9 +39,11 @@ object Catalog {
     function[GeometryType](),
     function[ST_PointFromText](),
     function[ST_PointFromWKB](),
+    function[ST_LineFromWKB](),
     function[ST_PolygonFromText](),
     function[ST_LineStringFromText](),
     function[ST_GeomFromText](0),
+    function[ST_GeometryFromText](0),
     function[ST_LineFromText](),
     function[ST_GeomFromWKT](0),
     function[ST_GeomFromEWKT](),
diff --git 
a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Constructors.scala
 
b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Constructors.scala
index 5ca0a56bc..a7a7811e4 100644
--- 
a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Constructors.scala
+++ 
b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Constructors.scala
@@ -104,6 +104,19 @@ case class ST_GeomFromEWKT(inputExpressions: 
Seq[Expression])
   }
 }
 
+/**
+ * Return a Geometry from a WKT string. Alias to ST_GeomFromWKT
+ *
+ * @param inputExpressions This function takes a geometry string and a srid. 
The string format must be WKT.
+ */
+case class ST_GeometryFromText(inputExpressions: Seq[Expression])
+  extends InferredExpression(Constructors.geomFromWKT _) {
+
+  protected def withNewChildrenInternal(newChildren: IndexedSeq[Expression]) = 
{
+    copy(inputExpressions = newChildren)
+  }
+}
+
 
 /**
   * Return a Geometry from a WKT string
@@ -189,6 +202,51 @@ case class ST_GeomFromEWKB(inputExpressions: 
Seq[Expression])
 }
 
 
+case class ST_LineFromWKB(inputExpressions: Seq[Expression])
+  extends Expression with FoldableExpression with ImplicitCastInputTypes with 
CodegenFallback with UserDataGeneratator {
+
+  // Validate the number of input expressions (1 or 2)
+  assert(inputExpressions.length >= 1 && inputExpressions.length <= 2)
+
+  override def nullable: Boolean = true
+
+  override def eval(inputRow: InternalRow): Any = {
+    val wkb = inputExpressions.head.eval(inputRow)
+    val srid = if (inputExpressions.length > 1) 
inputExpressions(1).eval(inputRow) else 0
+
+    wkb match {
+      case geomString: UTF8String =>
+        // Parse UTF-8 encoded WKB string
+        val geom = Constructors.lineStringFromText(geomString.toString, "wkb")
+        if (geom.getGeometryType == "LineString") {
+          geom.setSRID(srid.asInstanceOf[Int])
+          geom.toGenericArrayData
+        } else {
+          null
+        }
+
+      case wkbArray: Array[Byte] =>
+        // Convert raw WKB byte array to geometry
+        Constructors.lineFromWKB(wkbArray, 
srid.asInstanceOf[Int]).toGenericArrayData
+
+      case _ => null
+    }
+  }
+
+  override def dataType: DataType = GeometryUDT
+
+  override def inputTypes: Seq[AbstractDataType] =
+    if (inputExpressions.length == 1) Seq(TypeCollection(StringType, 
BinaryType))
+    else Seq(TypeCollection(StringType, BinaryType), IntegerType)
+
+  override def children: Seq[Expression] = inputExpressions
+
+  protected def withNewChildrenInternal(newChildren: IndexedSeq[Expression]): 
ST_LineFromWKB = {
+    copy(inputExpressions = newChildren)
+  }
+}
+
+
 case class ST_PointFromWKB(inputExpressions: Seq[Expression])
   extends Expression with FoldableExpression with ImplicitCastInputTypes with 
CodegenFallback with UserDataGeneratator {
 
diff --git 
a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/st_constructors.scala
 
b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/st_constructors.scala
index 7c99844f4..eabf1429d 100644
--- 
a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/st_constructors.scala
+++ 
b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/st_constructors.scala
@@ -45,6 +45,13 @@ object st_constructors extends DataFrameAPI {
 
   def ST_GeomFromText(wkt: String, srid: Int): Column = 
wrapExpression[ST_GeomFromText](wkt, srid)
 
+  def ST_GeometryFromText(wkt: Column): Column = 
wrapExpression[ST_GeometryFromText](wkt, 0)
+  def ST_GeometryFromText(wkt: String): Column = 
wrapExpression[ST_GeometryFromText](wkt, 0)
+
+  def ST_GeometryFromText(wkt: Column, srid: Column): Column = 
wrapExpression[ST_GeometryFromText](wkt, srid)
+
+  def ST_GeometryFromText(wkt: String, srid: Int): Column = 
wrapExpression[ST_GeometryFromText](wkt, srid)
+
   def ST_GeomFromWKB(wkb: Column): Column = wrapExpression[ST_GeomFromWKB](wkb)
   def ST_GeomFromWKB(wkb: String): Column = wrapExpression[ST_GeomFromWKB](wkb)
 
@@ -107,6 +114,12 @@ object st_constructors extends DataFrameAPI {
   def ST_PointFromWKB(wkb: Column, srid: Column): Column = 
wrapExpression[ST_PointFromWKB](wkb, srid)
   def ST_PointFromWKB(wkb: String, srid: Int): Column = 
wrapExpression[ST_PointFromWKB](wkb, srid)
 
+  def ST_LineFromWKB(wkb: Column): Column = 
wrapExpression[ST_LineFromWKB](wkb, 0)
+  def ST_LineFromWKB(wkb: String): Column = 
wrapExpression[ST_LineFromWKB](wkb, 0)
+
+  def ST_LineFromWKB(wkb: Column, srid: Column): Column = 
wrapExpression[ST_LineFromWKB](wkb, srid)
+  def ST_LineFromWKB(wkb: String, srid: Int): Column = 
wrapExpression[ST_LineFromWKB](wkb, srid)
+
   def ST_MakePoint(x: Column, y: Column): Column = 
wrapExpression[ST_MakePoint](x, y, null, null)
   def ST_MakePoint(x: String, y: String): Column = 
wrapExpression[ST_MakePoint](x, y, null, null)
   def ST_MakePoint(x: Double, y: Double): Column = 
wrapExpression[ST_MakePoint](x, y, null, null)
diff --git 
a/spark/common/src/test/scala/org/apache/sedona/sql/constructorTestScala.scala 
b/spark/common/src/test/scala/org/apache/sedona/sql/constructorTestScala.scala
index 024771e05..564e9e6d6 100644
--- 
a/spark/common/src/test/scala/org/apache/sedona/sql/constructorTestScala.scala
+++ 
b/spark/common/src/test/scala/org/apache/sedona/sql/constructorTestScala.scala
@@ -234,6 +234,19 @@ class constructorTestScala extends TestBaseScala {
       }
     }
 
+    it("Passed ST_GeometryFromText") {
+      var polygonWktDf = sparkSession.read.format("csv").option("delimiter", 
"\t").option("header", "false").load(mixedWktGeometryInputLocation)
+      polygonWktDf.createOrReplaceTempView("polygontable")
+      var polygonDf = sparkSession.sql("select 
ST_GeometryFromText(polygontable._c0, 4326) as countyshape from polygontable")
+      assert(polygonDf.count() == 100)
+      val nullGeom = sparkSession.sql("select ST_GeometryFromText(null)")
+      assert(nullGeom.first().isNullAt(0))
+      // Fail on wrong input type
+      intercept[Exception] {
+        sparkSession.sql("SELECT ST_GeometryFromText(0)").collect()
+      }
+    }
+
     it("Passed ST_GeomFromWKT multipolygon read as polygon bug") {
       val multipolygon =
         """'MULTIPOLYGON (((-97.143362 27.84948, -97.14051 27.849375, 
-97.13742 27.849375, -97.13647 27.851056, -97.136945 27.853788, -97.138728 
27.855784, -97.141223 27.853158, -97.143362 27.84948)),
@@ -247,6 +260,47 @@ class constructorTestScala extends TestBaseScala {
       assert(wkt.first().getAs[Geometry](0).getGeometryType === "MultiPolygon")
     }
 
+    it("Passed ST_LineFromWKB") {
+      val geometryDf = Seq(
+        
"010200000003000000000000000000000000000000000000000000000000000840000000000000084000000000000010400000000000001040",
+        "0101000000000000000000F03F0000000000000040",
+        
"01020000000300000000000000000000c000000000000000c000000000000010400000000000001040000000000000104000000000000000c0",
+        
"0103000000010000000500000000000000000000000000000000000000000000000000f03f000000000000f03f0000000000001440000000000000f03f0000000000001440000000000000000000000000000000000000000000000000"
+      ).map(Tuple1.apply).toDF("wkb")
+
+      geometryDf.createOrReplaceTempView("wkbtable")
+
+      var validLineDf = sparkSession.sql("SELECT ST_LineFromWKB(wkbtable.wkb) 
FROM wkbtable")
+      var rows = validLineDf.collect()
+      assert(rows.length == 4)
+
+      var expectedPoints = Seq("LINESTRING (0 0, 3 3, 4 4)", null, "LINESTRING 
(-2 -2, 4 4, 4 -2)", null)
+      for (i <- rows.indices) {
+        if (expectedPoints(i) == null) {
+          assert(rows(i).isNullAt(0))
+        } else {
+          assert(rows(i).getAs[Geometry](0).toString == expectedPoints(i))
+        }
+      }
+
+      validLineDf = sparkSession.sql("SELECT 
ST_AsEWKT(ST_LineFromWKB(wkbtable.wkb, 4326)) FROM wkbtable")
+      rows = validLineDf.collect()
+      assert(rows.length == 4)
+
+      expectedPoints = Seq("SRID=4326;LINESTRING (0 0, 3 3, 4 4)", null, 
"SRID=4326;LINESTRING (-2 -2, 4 4, 4 -2)", null)
+      for (i <- rows.indices) {
+        if (expectedPoints(i) == null) {
+          assert(rows(i).isNullAt(0))
+        } else {
+          assert(rows(i).get(0).toString == expectedPoints(i))
+        }
+      }
+
+      intercept[Exception] {
+        sparkSession.sql("SELECT ST_LineFromWKB('invalid')").collect()
+      }
+    }
+
     it("Passed ST_GeomFromWKB") {
       // UTF-8 encoded WKB String
       val polygonWkbDf = sparkSession.read.format("csv").option("delimiter", 
"\t").option("header", "false").load(mixedWkbGeometryInputLocation)
diff --git 
a/spark/common/src/test/scala/org/apache/sedona/sql/dataFrameAPITestScala.scala 
b/spark/common/src/test/scala/org/apache/sedona/sql/dataFrameAPITestScala.scala
index 3bf263be4..70e7201dd 100644
--- 
a/spark/common/src/test/scala/org/apache/sedona/sql/dataFrameAPITestScala.scala
+++ 
b/spark/common/src/test/scala/org/apache/sedona/sql/dataFrameAPITestScala.scala
@@ -140,6 +140,19 @@ class dataFrameAPITestScala extends TestBaseScala {
       assert(actualResult == expectedResult)
     }
 
+    it("passed st_linefromwkb") {
+      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 df = wkbSeq.toDF("wkb").select(ST_LineFromWKB("wkb"))
+      val actualResult = df.take(1)(0).get(0).asInstanceOf[Geometry].toText()
+      val expectedResult = "LINESTRING (-2.1047439575195312 
-0.354827880859375, -1.49606454372406 -0.6676061153411865)"
+      assert(actualResult == expectedResult)
+
+      val wkbStringSeq = 
Seq("0102000000020000000000000084d600c00000000080b5d6bf00000060e1eff7bf00000080075de5bf")
+      val dfWithString = wkbStringSeq.toDF("wkb").select(ST_LineFromWKB("wkb"))
+      val actualStringResult = 
dfWithString.take(1)(0).get(0).asInstanceOf[Geometry].toText()
+      assert(actualStringResult == expectedResult)
+    }
+
     it("passed st_geomfromwkt") {
       val df = sparkSession.sql("SELECT 'POINT(0.0 1.0)' AS 
wkt").select(ST_GeomFromWKT("wkt"))
       val actualResult = df.take(1)(0).get(0).asInstanceOf[Geometry].toText()
@@ -161,6 +174,20 @@ class dataFrameAPITestScala extends TestBaseScala {
       assert(actualResult.getSRID == 4269)
     }
 
+    it("passed ST_GeometryFromText") {
+      val df = sparkSession.sql("SELECT 'POINT(0.0 1.0)' AS 
wkt").select(ST_GeometryFromText("wkt"))
+      val actualResult = df.take(1)(0).get(0).asInstanceOf[Geometry].toText()
+      val expectedResult = "POINT (0 1)"
+      assert(actualResult == expectedResult)
+    }
+
+    it("passed ST_GeometryFromText with srid") {
+      val df = sparkSession.sql("SELECT 'POINT(0.0 1.0)' AS 
wkt").select(ST_GeometryFromText("wkt", 4326))
+      val actualResult = df.take(1)(0).get(0).asInstanceOf[Geometry]
+      assert(actualResult.toText == "POINT (0 1)")
+      assert(actualResult.getSRID == 4326)
+    }
+
     it("passed st_geomfromtext") {
       val df = sparkSession.sql("SELECT 'POINT(0.0 1.0)' AS 
wkt").select(ST_GeomFromText("wkt"))
       val actualResult = df.take(1)(0).get(0).asInstanceOf[Geometry].toText()


Reply via email to