You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Kyunam Kim <ky...@hotmail.com> on 2018/06/08 01:08:05 UTC
how to call database specific function when reading writing thru jdbc
For example, in SQL Server, when reading, I want to call a built-in function: STAsText()
SELECT id, shape.STAsText() FROM SpatialTable
val df = _sparkSession
.read
.jdbc(url, "dbo.SpatialTable", props)
.select("shape.STAsText()") // No, this doesn't work.
.as("shape")
Also when writing, I want to be able to call a built-in function: STGeomFromText like this:
INSERT INTO SpatialTable (GeomCol1) VALUES (geometry::STGeomFromText('POLYGON ((0 0, 150 0, 150 150, 0 150, 0 0))', 0));
How would go about doing this?
Thanks,
Kyunam