St Functions¶
This page lists all st functions available in Spark SQL.
st_asbinary¶
st_asbinary(geo[, endianness]) - Returns the geospatial value (value of type GEOGRAPHY or GEOMETRY) in WKB format using the specified endianness ('NDR' for little-endian, 'XDR' for big-endian), if provided. Defaults to little-endian encoding.
Arguments:
- geo - A geospatial value, either a GEOGRAPHY or a GEOMETRY.
- endianness - The optional endianness of the output WKB, 'NDR' for little-endian (default) or 'XDR' for big-endian.
Examples:
> SELECT hex(st_asbinary(st_geogfromwkb(X'0101000000000000000000F03F0000000000000040')));
0101000000000000000000F03F0000000000000040
> SELECT hex(st_asbinary(st_geomfromwkb(X'0101000000000000000000F03F0000000000000040'), 'XDR'));
00000000013FF00000000000004000000000000000
Since: 4.1.0
st_geogfromwkb¶
st_geogfromwkb(wkb) - Parses the WKB description of a geography and returns the corresponding GEOGRAPHY value.
Arguments:
- wkb - A BINARY value in WKB format, representing a GEOGRAPHY value.
Examples:
> SELECT hex(st_asbinary(st_geogfromwkb(X'0101000000000000000000F03F0000000000000040')));
0101000000000000000000F03F0000000000000040
Since: 4.1.0
st_geomfromwkb¶
st_geomfromwkb(wkb[, srid]) - Parses the WKB description of a geometry and returns the corresponding GEOMETRY value.
Arguments:
- wkb - A BINARY value in WKB format, representing a GEOMETRY value.
- srid - The optional SRID value of the geometry. Default is 0.
Examples:
> SELECT hex(st_asbinary(st_geomfromwkb(X'0101000000000000000000F03F0000000000000040')));
0101000000000000000000F03F0000000000000040
> SELECT st_srid(st_geomfromwkb(X'0101000000000000000000F03F0000000000000040'));
0
> SELECT hex(st_asbinary(st_geomfromwkb(X'0101000000000000000000F03F0000000000000040', 4326)));
0101000000000000000000F03F0000000000000040
> SELECT st_srid(st_geomfromwkb(X'0101000000000000000000F03F0000000000000040', 4326));
4326
Since: 4.1.0
st_setsrid¶
st_setsrid(geo, srid) - Returns a new GEOGRAPHY or GEOMETRY value whose SRID is the specified SRID value.
Arguments:
- geo - A GEOGRAPHY or GEOMETRY value.
- srid - The new SRID value of the geography or geometry.
Examples:
> SELECT st_srid(st_setsrid(ST_GeogFromWKB(X'0101000000000000000000F03F0000000000000040'), 4326));
4326
> SELECT st_srid(st_setsrid(ST_GeomFromWKB(X'0101000000000000000000F03F0000000000000040'), 3857));
3857
Since: 4.1.0
st_srid¶
st_srid(geo) - Returns the SRID of the input GEOGRAPHY or GEOMETRY value.
Arguments:
- geo - A GEOGRAPHY or GEOMETRY value.
Examples:
> SELECT st_srid(st_geogfromwkb(X'0101000000000000000000F03F0000000000000040'));
4326
> SELECT st_srid(st_geomfromwkb(X'0101000000000000000000F03F0000000000000040'));
0
> SELECT st_srid(NULL);
NULL
Since: 4.1.0