You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ay...@apache.org on 2022/06/21 06:31:26 UTC

[hive] branch master updated: HIVE-26240: Add tests for Esri UDFs for Geospatial. (#3385). (Ayush Saxena, reviewed by Mahesh Kumar Behera)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 8251d80714a HIVE-26240: Add tests for Esri UDFs for Geospatial. (#3385). (Ayush Saxena, reviewed by Mahesh Kumar Behera)
8251d80714a is described below

commit 8251d80714a89440e09084a65d4503e5712ecf50
Author: Ayush Saxena <ay...@apache.org>
AuthorDate: Tue Jun 21 12:01:20 2022 +0530

    HIVE-26240: Add tests for Esri UDFs for Geospatial. (#3385). (Ayush Saxena, reviewed by Mahesh Kumar Behera)
---
 .../hadoop/hive/ql/exec/FunctionRegistry.java      |   2 +
 .../test/queries/clientpositive/geospatial_udfs.q  | 163 +++++++
 .../clientpositive/llap/geospatial_udfs.q.out      | 471 +++++++++++++++++++++
 .../clientpositive/llap/show_functions.q.out       |   3 +
 4 files changed, 639 insertions(+)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
index 3fc5fd45626..4ff75712ad3 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
@@ -67,6 +67,7 @@ import org.apache.hadoop.hive.ql.udf.esri.ST_GeomFromText;
 import org.apache.hadoop.hive.ql.udf.esri.ST_GeomFromWKB;
 import org.apache.hadoop.hive.ql.udf.esri.ST_GeometryN;
 import org.apache.hadoop.hive.ql.udf.esri.ST_GeometryProcessing;
+import org.apache.hadoop.hive.ql.udf.esri.ST_GeometryType;
 import org.apache.hadoop.hive.ql.udf.esri.ST_InteriorRingN;
 import org.apache.hadoop.hive.ql.udf.esri.ST_Intersection;
 import org.apache.hadoop.hive.ql.udf.esri.ST_Intersects;
@@ -708,6 +709,7 @@ public final class FunctionRegistry {
     system.registerFunction("ST_GeomFromShape", ST_GeomFromShape.class);
     system.registerFunction("ST_GeomFromText", ST_GeomFromText.class);
     system.registerFunction("ST_GeomFromWKB", ST_GeomFromWKB.class);
+    system.registerFunction("ST_GeometryType", ST_GeometryType.class);
     system.registerFunction("ST_InteriorRingN", ST_InteriorRingN.class);
     system.registerFunction("ST_Intersection", ST_Intersection.class);
     system.registerFunction("ST_Intersects", ST_Intersects.class);
diff --git a/ql/src/test/queries/clientpositive/geospatial_udfs.q b/ql/src/test/queries/clientpositive/geospatial_udfs.q
new file mode 100644
index 00000000000..1f7d055fb27
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/geospatial_udfs.q
@@ -0,0 +1,163 @@
+-- create a table with two columns one for each point.
+create table geom_binary
+(
+  id   int,
+  geom binary
+);
+
+-- insert data into the table.
+insert into geom_binary values
+(1, ST_GeomFromText('multipolygon (((0 0, 0 1, 1 0, 0 0)), ((2 2, 2 3, 3 2, 2 2)))')),
+(2, ST_GeomFromText('multilinestring ((2 4, 10 10), (20 20, 7 8))')),
+(3, ST_GeomFromText('MULTIPOINT ((10 40), (40 30), (20 20), (30 10))')),
+(4, ST_GeomFromText('polygon ((0 0, 0 10, 10 10, 0 0))')),
+(6, ST_GeomFromText('linestring (10 10, 20 20)')),
+(7, ST_GeomFromText('point (10.02 20.01)')),
+(8, ST_GeomFromText('linestring z (1.5 2.5 2, 3.0 2.2 1)')),
+(9, ST_GeomFromText('multipoint z((0 0 1), (2 2 3))')),
+(10, ST_GeomFromText('point z(10.02 20.01 25.0)')),
+(11, ST_GeomFromText('multipolygon (((0 0, 1 0, 0 1, 0 0)), ((2 2, 1 2, 2 1, 2 2)))')),
+(12, ST_GeomFromText('polygon ((0 0, 8 0, 0 8, 0 0), (1 1, 1 5, 5 1, 1 1))')),
+(13, ST_PointZ(1.5, 2.5, 2)),
+(14, ST_Point(5, 6)),
+(15, ST_Polygon(1,1, 1,4, 4,4, 4,1)),
+(16, ST_Linestring('linestring (10 10, 20 20)')),
+(17, ST_LineString(0.,0., 3.,4., 0.,4., 0.,0.)),
+(18, ST_MultiLineString('multilinestring ((0 0, 3 4, 2 2, 0 0), (6 2, 7 5, 6 8, 6 2))')),
+(19, ST_GeomFromText('point empty')),
+(20, ST_LineString(0,0, 1,0, 1,1, 0,2, 2,2, 1,1, 2,0)),
+(21, ST_Point('point m(0. 3. 1)')),
+(22, ST_Point('pointzm (0. 3. 1. 2.)')),
+(23, ST_GeomFromText('linestring m (10 10 2, 20 20 4)')),
+(24, ST_Polygon(1, 1, 1, 4, 4, 4, 4, 1)),
+(25, ST_Polygon(2,0, 2,1, 3,1)),
+(26, ST_GeomFromJSON(('{"x":0.0,"y":0.0}'))),
+(27, ST_GeomFromGeoJSON('{"type":"LineString", "coordinates":[[1,2], [3,4]]}')),
+(28, ST_GeometryN(ST_GeomFromText('multilinestring ((2 4, 10 10), (20 20, 7 8))'), 2));
+
+
+-- Check the values as text.
+select id, ST_AsText(geom), ST_GeometryType(ST_GeomFromWKB(ST_AsBinary(geom))), ST_MaxX(geom), ST_MaxY(geom),
+       ST_MaxZ(geom), ST_MinX(geom), ST_MinY(geom), ST_MinZ(geom), ST_NumGeometries(geom), ST_AsText(ST_Centroid(geom)),
+       ST_Dimension(geom), ST_IsEmpty(geom), ST_IsMeasured(geom), ST_IsSimple(geom)
+from geom_binary
+order by id;
+
+select ST_GeometryType(ST_MLineFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 2;
+
+select ST_GeometryType(ST_MPointFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 9;
+
+select ST_GeometryType(ST_MPolyFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 11;
+
+select ST_AsJson(ST_MultiLineString(ST_AsText(geom)))
+from geom_binary
+where id = 2;
+
+select ST_Equals(ST_MultiPoint((ST_AsText(geom))), ST_GeomFromText('MULTIPOINT ((10 40), (40 30))')),
+       ST_Equals(ST_MultiPoint((ST_AsText(geom))), ST_GeomFromText('MULTIPOINT ((10 40), (40 30), (20 20), (30 10))'))
+from geom_binary
+where id = 3;
+
+select ST_AsJson(ST_MultiPolygon(ST_AsText(geom)))
+from geom_binary
+where id = 11;
+
+select ST_AsText(ST_PointN(geom, 2))
+from geom_binary
+where id = 3;
+
+select ST_NumInteriorRing(ST_Polygon(ST_AsText(geom))),
+       ST_GeometryType(ST_PolyFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 4 OR id = 12;
+
+select ST_NumPoints(geom)
+from geom_binary
+where id = 2 OR id = 3 OR id = 9;
+
+select ST_Overlaps(ST_Polygon(ST_AsText(geom)), ST_Polygon(1, 1, 1, 4, 4, 4, 4, 1))
+from geom_binary
+where id = 4;
+
+select ST_GeometryType(ST_PointFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 7;
+
+select ST_GeometryType(ST_PointFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 7;
+
+select ST_X(geom), ST_Y(geom), ST_Z(geom), ST_CoordDim(geom), ST_Is3D(geom)
+from geom_binary
+where id = 14 OR id = 13 order by id;
+
+select id
+from geom_binary
+where (id = 4 OR id = 12 OR id = 15) AND (ST_Within(ST_Point(2, 3), (ST_Polygon(ST_AsText(geom)))));
+
+select id
+from geom_binary
+where (id = 4 OR id = 12 OR id = 15) AND (ST_Contains((ST_Polygon(ST_AsText(geom))), ST_Point(2, 3)));
+
+select id, ST_Area(ST_Polygon(ST_AsText(geom)))
+from geom_binary
+where (id = 4 OR id = 12 OR id = 15);
+
+select ST_AsText(ST_Boundary(geom))
+from geom_binary
+where id = 4;
+
+select ST_AsText(ST_Buffer(geom, 1))
+from geom_binary
+where id = 7;
+
+SELECT ST_AsText(ST_ConvexHull(geom, ST_Point(0, 1), ST_Point(1, 1)))
+from geom_binary
+where id = 14;
+
+select ST_IsClosed(geom)
+from geom_binary
+where id = 16 OR id = 17 OR id =18;
+
+select ST_IsRing(geom), ST_AsText(ST_StartPoint(geom)), ST_AsText(ST_EndPoint(geom)),
+       ST_Distance(geom, ST_Point(3.0, 4.0)), ST_Crosses(geom, st_linestring(15,0, 15,15))
+from geom_binary
+where id = 16 OR id = 17;
+
+select ST_Equals(ST_LineFromWKB(ST_AsBinary(geom)), ST_GeomFromText('linestring (11 12, 21 23)')),
+       ST_Equals(ST_LineFromWKB(ST_AsBinary(geom)), ST_GeomFromText('linestring (10 10, 20 20)'))
+from geom_binary
+where id = 6;
+
+select ST_M(geom), ST_MaxM(geom), ST_MinM(geom)
+from geom_binary
+where id = 21 OR id = 22 OR id=23;
+
+select ST_Touches(ST_Point(1, 2), geom), ST_Touches(ST_Point(8, 8), geom)
+from geom_binary
+where id = 24;
+
+select ST_Relate(geom, ST_Polygon(1, 1, 1, 4, 4, 4, 4, 1), '****T****'),
+       ST_Relate(geom, ST_Polygon(1, 1, 1, 4, 4, 4, 4, 1), 'T********')
+from geom_binary
+where id = 25;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ql/src/test/results/clientpositive/llap/geospatial_udfs.q.out b/ql/src/test/results/clientpositive/llap/geospatial_udfs.q.out
new file mode 100644
index 00000000000..8184bd6c607
--- /dev/null
+++ b/ql/src/test/results/clientpositive/llap/geospatial_udfs.q.out
@@ -0,0 +1,471 @@
+PREHOOK: query: create table geom_binary
+(
+  id   int,
+  geom binary
+)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@geom_binary
+POSTHOOK: query: create table geom_binary
+(
+  id   int,
+  geom binary
+)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@geom_binary
+PREHOOK: query: insert into geom_binary values
+(1, ST_GeomFromText('multipolygon (((0 0, 0 1, 1 0, 0 0)), ((2 2, 2 3, 3 2, 2 2)))')),
+(2, ST_GeomFromText('multilinestring ((2 4, 10 10), (20 20, 7 8))')),
+(3, ST_GeomFromText('MULTIPOINT ((10 40), (40 30), (20 20), (30 10))')),
+(4, ST_GeomFromText('polygon ((0 0, 0 10, 10 10, 0 0))')),
+(6, ST_GeomFromText('linestring (10 10, 20 20)')),
+(7, ST_GeomFromText('point (10.02 20.01)')),
+(8, ST_GeomFromText('linestring z (1.5 2.5 2, 3.0 2.2 1)')),
+(9, ST_GeomFromText('multipoint z((0 0 1), (2 2 3))')),
+(10, ST_GeomFromText('point z(10.02 20.01 25.0)')),
+(11, ST_GeomFromText('multipolygon (((0 0, 1 0, 0 1, 0 0)), ((2 2, 1 2, 2 1, 2 2)))')),
+(12, ST_GeomFromText('polygon ((0 0, 8 0, 0 8, 0 0), (1 1, 1 5, 5 1, 1 1))')),
+(13, ST_PointZ(1.5, 2.5, 2)),
+(14, ST_Point(5, 6)),
+(15, ST_Polygon(1,1, 1,4, 4,4, 4,1)),
+(16, ST_Linestring('linestring (10 10, 20 20)')),
+(17, ST_LineString(0.,0., 3.,4., 0.,4., 0.,0.)),
+(18, ST_MultiLineString('multilinestring ((0 0, 3 4, 2 2, 0 0), (6 2, 7 5, 6 8, 6 2))')),
+(19, ST_GeomFromText('point empty')),
+(20, ST_LineString(0,0, 1,0, 1,1, 0,2, 2,2, 1,1, 2,0)),
+(21, ST_Point('point m(0. 3. 1)')),
+(22, ST_Point('pointzm (0. 3. 1. 2.)')),
+(23, ST_GeomFromText('linestring m (10 10 2, 20 20 4)')),
+(24, ST_Polygon(1, 1, 1, 4, 4, 4, 4, 1)),
+(25, ST_Polygon(2,0, 2,1, 3,1)),
+(26, ST_GeomFromJSON(('{"x":0.0,"y":0.0}'))),
+(27, ST_GeomFromGeoJSON('{"type":"LineString", "coordinates":[[1,2], [3,4]]}')),
+(28, ST_GeometryN(ST_GeomFromText('multilinestring ((2 4, 10 10), (20 20, 7 8))'), 2))
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@geom_binary
+POSTHOOK: query: insert into geom_binary values
+(1, ST_GeomFromText('multipolygon (((0 0, 0 1, 1 0, 0 0)), ((2 2, 2 3, 3 2, 2 2)))')),
+(2, ST_GeomFromText('multilinestring ((2 4, 10 10), (20 20, 7 8))')),
+(3, ST_GeomFromText('MULTIPOINT ((10 40), (40 30), (20 20), (30 10))')),
+(4, ST_GeomFromText('polygon ((0 0, 0 10, 10 10, 0 0))')),
+(6, ST_GeomFromText('linestring (10 10, 20 20)')),
+(7, ST_GeomFromText('point (10.02 20.01)')),
+(8, ST_GeomFromText('linestring z (1.5 2.5 2, 3.0 2.2 1)')),
+(9, ST_GeomFromText('multipoint z((0 0 1), (2 2 3))')),
+(10, ST_GeomFromText('point z(10.02 20.01 25.0)')),
+(11, ST_GeomFromText('multipolygon (((0 0, 1 0, 0 1, 0 0)), ((2 2, 1 2, 2 1, 2 2)))')),
+(12, ST_GeomFromText('polygon ((0 0, 8 0, 0 8, 0 0), (1 1, 1 5, 5 1, 1 1))')),
+(13, ST_PointZ(1.5, 2.5, 2)),
+(14, ST_Point(5, 6)),
+(15, ST_Polygon(1,1, 1,4, 4,4, 4,1)),
+(16, ST_Linestring('linestring (10 10, 20 20)')),
+(17, ST_LineString(0.,0., 3.,4., 0.,4., 0.,0.)),
+(18, ST_MultiLineString('multilinestring ((0 0, 3 4, 2 2, 0 0), (6 2, 7 5, 6 8, 6 2))')),
+(19, ST_GeomFromText('point empty')),
+(20, ST_LineString(0,0, 1,0, 1,1, 0,2, 2,2, 1,1, 2,0)),
+(21, ST_Point('point m(0. 3. 1)')),
+(22, ST_Point('pointzm (0. 3. 1. 2.)')),
+(23, ST_GeomFromText('linestring m (10 10 2, 20 20 4)')),
+(24, ST_Polygon(1, 1, 1, 4, 4, 4, 4, 1)),
+(25, ST_Polygon(2,0, 2,1, 3,1)),
+(26, ST_GeomFromJSON(('{"x":0.0,"y":0.0}'))),
+(27, ST_GeomFromGeoJSON('{"type":"LineString", "coordinates":[[1,2], [3,4]]}')),
+(28, ST_GeometryN(ST_GeomFromText('multilinestring ((2 4, 10 10), (20 20, 7 8))'), 2))
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@geom_binary
+POSTHOOK: Lineage: geom_binary.geom SCRIPT []
+POSTHOOK: Lineage: geom_binary.id SCRIPT []
+PREHOOK: query: select id, ST_AsText(geom), ST_GeometryType(ST_GeomFromWKB(ST_AsBinary(geom))), ST_MaxX(geom), ST_MaxY(geom),
+       ST_MaxZ(geom), ST_MinX(geom), ST_MinY(geom), ST_MinZ(geom), ST_NumGeometries(geom), ST_AsText(ST_Centroid(geom)),
+       ST_Dimension(geom), ST_IsEmpty(geom), ST_IsMeasured(geom), ST_IsSimple(geom)
+from geom_binary
+order by id
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select id, ST_AsText(geom), ST_GeometryType(ST_GeomFromWKB(ST_AsBinary(geom))), ST_MaxX(geom), ST_MaxY(geom),
+       ST_MaxZ(geom), ST_MinX(geom), ST_MinY(geom), ST_MinZ(geom), ST_NumGeometries(geom), ST_AsText(ST_Centroid(geom)),
+       ST_Dimension(geom), ST_IsEmpty(geom), ST_IsMeasured(geom), ST_IsSimple(geom)
+from geom_binary
+order by id
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+1	MULTIPOLYGON (((0 0, 1 0, 0 1, 0 0)), ((2 2, 3 2, 2 3, 2 2)))	ST_MULTIPOLYGON	3.0	3.0	NULL	0.0	0.0	NULL	2	POINT (1.3333333333333333 1.3333333333333333)	2	false	false	true
+2	MULTILINESTRING ((2 4, 10 10), (20 20, 7 8))	ST_MULTILINESTRING	20.0	20.0	NULL	2.0	4.0	NULL	2	POINT (10.791617601072488 11.472176427667655)	1	false	false	true
+3	MULTIPOINT ((10 40), (40 30), (20 20), (30 10))	ST_MULTIPOINT	40.0	40.0	NULL	10.0	10.0	NULL	4	POINT (25 25)	0	false	false	true
+4	POLYGON ((0 0, 10 10, 0 10, 0 0))	ST_POLYGON	10.0	10.0	NULL	0.0	0.0	NULL	NULL	POINT (3.3333333333333335 6.666666666666667)	2	false	false	true
+6	LINESTRING (10 10, 20 20)	ST_LINESTRING	20.0	20.0	NULL	10.0	10.0	NULL	NULL	POINT (15 15)	1	false	false	true
+7	POINT (10.02 20.01)	ST_POINT	10.02	20.01	NULL	10.02	20.01	NULL	NULL	POINT (10.02 20.01)	0	false	false	true
+8	LINESTRING Z (1.5 2.5 2, 3 2.2 1)	ST_LINESTRING	3.0	2.5	2.0	1.5	2.2	1.0	NULL	POINT (2.25 2.35)	1	false	false	true
+9	MULTIPOINT Z ((0 0 1), (2 2 3))	ST_MULTIPOINT	2.0	2.0	3.0	0.0	0.0	1.0	2	POINT (1 1)	0	false	false	true
+10	POINT Z (10.02 20.01 25)	ST_POINT	10.02	20.01	25.0	10.02	20.01	25.0	NULL	POINT (10.02 20.01)	0	false	false	true
+11	MULTIPOLYGON (((0 0, 1 0, 0 1, 0 0)), ((2 2, 1 2, 2 1, 2 2)))	ST_MULTIPOLYGON	2.0	2.0	NULL	0.0	0.0	NULL	2	POINT (1 1)	2	false	false	true
+12	POLYGON ((0 0, 8 0, 0 8, 0 0), (1 1, 1 5, 5 1, 1 1))	ST_POLYGON	8.0	8.0	NULL	0.0	0.0	NULL	NULL	POINT (2.7777777777777777 2.7777777777777777)	2	false	false	true
+13	POINT Z (1.5 2.5 2)	ST_POINT	1.5	2.5	2.0	1.5	2.5	2.0	NULL	POINT (1.5 2.5)	0	false	false	true
+14	POINT (5 6)	ST_POINT	5.0	6.0	NULL	5.0	6.0	NULL	NULL	POINT (5 6)	0	false	false	true
+15	POLYGON ((1 1, 4 1, 4 4, 1 4, 1 1))	ST_POLYGON	4.0	4.0	NULL	1.0	1.0	NULL	NULL	POINT (2.5 2.5)	2	false	false	true
+16	LINESTRING (10 10, 20 20)	ST_LINESTRING	20.0	20.0	NULL	10.0	10.0	NULL	NULL	POINT (15 15)	1	false	false	true
+17	LINESTRING (0 0, 3 4, 0 4, 0 0)	ST_LINESTRING	3.0	4.0	NULL	0.0	0.0	NULL	NULL	POINT (1 2.5)	1	false	false	true
+18	MULTILINESTRING ((0 0, 3 4, 2 2, 0 0), (6 2, 7 5, 6 8, 6 2))	ST_MULTILINESTRING	7.0	8.0	NULL	0.0	0.0	NULL	2	POINT (4.155076025772472 3.624959796288092)	1	false	false	true
+19	POINT EMPTY	ST_POINT	NaN	NaN	NULL	NaN	NaN	NULL	NULL	POINT EMPTY	0	true	false	true
+20	LINESTRING (0 0, 1 0, 1 1, 0 2, 2 2, 1 1, 2 0)	ST_LINESTRING	2.0	2.0	NULL	0.0	0.0	NULL	NULL	POINT (1.0251262658470837 1.1464466094067263)	1	false	false	false
+21	POINT M (0 3 1)	ST_POINT	0.0	3.0	NULL	0.0	3.0	NULL	NULL	POINT (0 3)	0	false	true	true
+22	POINT ZM (0 3 1 2)	ST_POINT	0.0	3.0	1.0	0.0	3.0	1.0	NULL	POINT (0 3)	0	false	true	true
+23	LINESTRING M (10 10 2, 20 20 4)	ST_LINESTRING	20.0	20.0	NULL	10.0	10.0	NULL	NULL	POINT (15 15)	1	false	true	true
+24	POLYGON ((1 1, 4 1, 4 4, 1 4, 1 1))	ST_POLYGON	4.0	4.0	NULL	1.0	1.0	NULL	NULL	POINT (2.5 2.5)	2	false	false	true
+25	POLYGON ((2 0, 3 1, 2 1, 2 0))	ST_POLYGON	3.0	1.0	NULL	2.0	0.0	NULL	NULL	POINT (2.3333333333333335 0.6666666666666666)	2	false	false	true
+26	POINT (0 0)	ST_POINT	0.0	0.0	NULL	0.0	0.0	NULL	NULL	POINT (0 0)	0	false	false	true
+27	LINESTRING (1 2, 3 4)	ST_LINESTRING	3.0	4.0	NULL	1.0	2.0	NULL	NULL	POINT (2 3)	1	false	false	true
+28	LINESTRING (20 20, 7 8)	ST_LINESTRING	20.0	20.0	NULL	7.0	8.0	NULL	NULL	POINT (13.5 14)	1	false	false	true
+PREHOOK: query: select ST_GeometryType(ST_MLineFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 2
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_GeometryType(ST_MLineFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 2
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+ST_MULTILINESTRING
+PREHOOK: query: select ST_GeometryType(ST_MPointFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 9
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_GeometryType(ST_MPointFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 9
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+ST_MULTIPOINT
+PREHOOK: query: select ST_GeometryType(ST_MPolyFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 11
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_GeometryType(ST_MPolyFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 11
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+ST_MULTIPOLYGON
+PREHOOK: query: select ST_AsJson(ST_MultiLineString(ST_AsText(geom)))
+from geom_binary
+where id = 2
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_AsJson(ST_MultiLineString(ST_AsText(geom)))
+from geom_binary
+where id = 2
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+{"paths":[[[2,4],[10,10]],[[20,20],[7,8]]]}
+PREHOOK: query: select ST_Equals(ST_MultiPoint((ST_AsText(geom))), ST_GeomFromText('MULTIPOINT ((10 40), (40 30))')),
+       ST_Equals(ST_MultiPoint((ST_AsText(geom))), ST_GeomFromText('MULTIPOINT ((10 40), (40 30), (20 20), (30 10))'))
+from geom_binary
+where id = 3
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_Equals(ST_MultiPoint((ST_AsText(geom))), ST_GeomFromText('MULTIPOINT ((10 40), (40 30))')),
+       ST_Equals(ST_MultiPoint((ST_AsText(geom))), ST_GeomFromText('MULTIPOINT ((10 40), (40 30), (20 20), (30 10))'))
+from geom_binary
+where id = 3
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+false	true
+PREHOOK: query: select ST_AsJson(ST_MultiPolygon(ST_AsText(geom)))
+from geom_binary
+where id = 11
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_AsJson(ST_MultiPolygon(ST_AsText(geom)))
+from geom_binary
+where id = 11
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+{"rings":[[[0,0],[0,1],[1,0],[0,0]],[[2,2],[2,1],[1,2],[2,2]]]}
+PREHOOK: query: select ST_AsText(ST_PointN(geom, 2))
+from geom_binary
+where id = 3
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_AsText(ST_PointN(geom, 2))
+from geom_binary
+where id = 3
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POINT (40 30)
+PREHOOK: query: select ST_NumInteriorRing(ST_Polygon(ST_AsText(geom))),
+       ST_GeometryType(ST_PolyFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 4 OR id = 12
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_NumInteriorRing(ST_Polygon(ST_AsText(geom))),
+       ST_GeometryType(ST_PolyFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 4 OR id = 12
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+0	ST_POLYGON
+1	ST_POLYGON
+PREHOOK: query: select ST_NumPoints(geom)
+from geom_binary
+where id = 2 OR id = 3 OR id = 9
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_NumPoints(geom)
+from geom_binary
+where id = 2 OR id = 3 OR id = 9
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+4
+4
+2
+PREHOOK: query: select ST_Overlaps(ST_Polygon(ST_AsText(geom)), ST_Polygon(1, 1, 1, 4, 4, 4, 4, 1))
+from geom_binary
+where id = 4
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_Overlaps(ST_Polygon(ST_AsText(geom)), ST_Polygon(1, 1, 1, 4, 4, 4, 4, 1))
+from geom_binary
+where id = 4
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+true
+PREHOOK: query: select ST_GeometryType(ST_PointFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 7
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_GeometryType(ST_PointFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 7
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+ST_POINT
+PREHOOK: query: select ST_GeometryType(ST_PointFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 7
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_GeometryType(ST_PointFromWKB(ST_AsBinary(geom)))
+from geom_binary
+where id = 7
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+ST_POINT
+PREHOOK: query: select ST_X(geom), ST_Y(geom), ST_Z(geom), ST_CoordDim(geom), ST_Is3D(geom)
+from geom_binary
+where id = 14 OR id = 13 order by id
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_X(geom), ST_Y(geom), ST_Z(geom), ST_CoordDim(geom), ST_Is3D(geom)
+from geom_binary
+where id = 14 OR id = 13 order by id
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+1.5	2.5	2.0	3	true
+5.0	6.0	NULL	2	false
+PREHOOK: query: select id
+from geom_binary
+where (id = 4 OR id = 12 OR id = 15) AND (ST_Within(ST_Point(2, 3), (ST_Polygon(ST_AsText(geom)))))
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select id
+from geom_binary
+where (id = 4 OR id = 12 OR id = 15) AND (ST_Within(ST_Point(2, 3), (ST_Polygon(ST_AsText(geom)))))
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+4
+15
+PREHOOK: query: select id
+from geom_binary
+where (id = 4 OR id = 12 OR id = 15) AND (ST_Contains((ST_Polygon(ST_AsText(geom))), ST_Point(2, 3)))
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select id
+from geom_binary
+where (id = 4 OR id = 12 OR id = 15) AND (ST_Contains((ST_Polygon(ST_AsText(geom))), ST_Point(2, 3)))
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+4
+15
+PREHOOK: query: select id, ST_Area(ST_Polygon(ST_AsText(geom)))
+from geom_binary
+where (id = 4 OR id = 12 OR id = 15)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select id, ST_Area(ST_Polygon(ST_AsText(geom)))
+from geom_binary
+where (id = 4 OR id = 12 OR id = 15)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+4	50.0
+12	24.0
+15	9.0
+PREHOOK: query: select ST_AsText(ST_Boundary(geom))
+from geom_binary
+where id = 4
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_AsText(ST_Boundary(geom))
+from geom_binary
+where id = 4
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+LINESTRING (0 0, 10 10, 0 10, 0 0)
+PREHOOK: query: select ST_AsText(ST_Buffer(geom, 1))
+from geom_binary
+where id = 7
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_AsText(ST_Buffer(geom, 1))
+from geom_binary
+where id = 7
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POLYGON ((11.02 20.01, 11.017858923238602 20.075403129230146, 11.011444861373809 20.140526192220054, 11.00078528040323 20.20509032201613, 10.985925826289067 20.26881904510252, 10.966930129495104 20.331439465303163, 10.943879532511286 20.39268343236509, 10.916872741532687 20.452288690219003, 10.886025403784437 20.51, 10.851469612302544 20.565570233019603, 10.813353340291235 20.61876142900872, 10.771839807478976 20.66934581510007, 10.727106781186547 20.717106781186548, 10.679345815100069 2 [...]
+PREHOOK: query: SELECT ST_AsText(ST_ConvexHull(geom, ST_Point(0, 1), ST_Point(1, 1)))
+from geom_binary
+where id = 14
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: SELECT ST_AsText(ST_ConvexHull(geom, ST_Point(0, 1), ST_Point(1, 1)))
+from geom_binary
+where id = 14
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+MULTIPOLYGON (((5 6, 0 1, 1 1, 5 6)))
+PREHOOK: query: select ST_IsClosed(geom)
+from geom_binary
+where id = 16 OR id = 17 OR id =18
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_IsClosed(geom)
+from geom_binary
+where id = 16 OR id = 17 OR id =18
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+false
+true
+true
+PREHOOK: query: select ST_IsRing(geom), ST_AsText(ST_StartPoint(geom)), ST_AsText(ST_EndPoint(geom)),
+       ST_Distance(geom, ST_Point(3.0, 4.0)), ST_Crosses(geom, st_linestring(15,0, 15,15))
+from geom_binary
+where id = 16 OR id = 17
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_IsRing(geom), ST_AsText(ST_StartPoint(geom)), ST_AsText(ST_EndPoint(geom)),
+       ST_Distance(geom, ST_Point(3.0, 4.0)), ST_Crosses(geom, st_linestring(15,0, 15,15))
+from geom_binary
+where id = 16 OR id = 17
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+false	POINT (10 10)	POINT (20 20)	9.219544457292887	false
+true	POINT (0 0)	POINT (0 0)	0.0	false
+PREHOOK: query: select ST_Equals(ST_LineFromWKB(ST_AsBinary(geom)), ST_GeomFromText('linestring (11 12, 21 23)')),
+       ST_Equals(ST_LineFromWKB(ST_AsBinary(geom)), ST_GeomFromText('linestring (10 10, 20 20)'))
+from geom_binary
+where id = 6
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_Equals(ST_LineFromWKB(ST_AsBinary(geom)), ST_GeomFromText('linestring (11 12, 21 23)')),
+       ST_Equals(ST_LineFromWKB(ST_AsBinary(geom)), ST_GeomFromText('linestring (10 10, 20 20)'))
+from geom_binary
+where id = 6
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+false	true
+PREHOOK: query: select ST_M(geom), ST_MaxM(geom), ST_MinM(geom)
+from geom_binary
+where id = 21 OR id = 22 OR id=23
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_M(geom), ST_MaxM(geom), ST_MinM(geom)
+from geom_binary
+where id = 21 OR id = 22 OR id=23
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+1.0	1.0	1.0
+2.0	2.0	2.0
+NULL	4.0	2.0
+PREHOOK: query: select ST_Touches(ST_Point(1, 2), geom), ST_Touches(ST_Point(8, 8), geom)
+from geom_binary
+where id = 24
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_Touches(ST_Point(1, 2), geom), ST_Touches(ST_Point(8, 8), geom)
+from geom_binary
+where id = 24
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+true	false
+PREHOOK: query: select ST_Relate(geom, ST_Polygon(1, 1, 1, 4, 4, 4, 4, 1), '****T****'),
+       ST_Relate(geom, ST_Polygon(1, 1, 1, 4, 4, 4, 4, 1), 'T********')
+from geom_binary
+where id = 25
+PREHOOK: type: QUERY
+PREHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+POSTHOOK: query: select ST_Relate(geom, ST_Polygon(1, 1, 1, 4, 4, 4, 4, 1), '****T****'),
+       ST_Relate(geom, ST_Polygon(1, 1, 1, 4, 4, 4, 4, 1), 'T********')
+from geom_binary
+where id = 25
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@geom_binary
+#### A masked pattern was here ####
+true	false
diff --git a/ql/src/test/results/clientpositive/llap/show_functions.q.out b/ql/src/test/results/clientpositive/llap/show_functions.q.out
index bf0b4d217df..dd9751f72cf 100644
--- a/ql/src/test/results/clientpositive/llap/show_functions.q.out
+++ b/ql/src/test/results/clientpositive/llap/show_functions.q.out
@@ -372,6 +372,7 @@ st_geodesiclengthwgs84
 st_geomcollection
 st_geometryn
 st_geometryprocessing
+st_geometrytype
 st_geomfromgeojson
 st_geomfromjson
 st_geomfromshape
@@ -596,6 +597,7 @@ st_binenvelope
 st_difference
 st_distance
 st_envelope
+st_geometrytype
 st_geomfromshape
 st_issimple
 st_relate
@@ -982,6 +984,7 @@ st_geodesiclengthwgs84
 st_geomcollection
 st_geometryn
 st_geometryprocessing
+st_geometrytype
 st_geomfromgeojson
 st_geomfromjson
 st_geomfromshape