From fc23fb3c821b499d41a0fe4259dfb936e746eb50 Mon Sep 17 00:00:00 2001 From: Ramit Gupta Date: Tue, 22 Sep 2026 17:33:14 +0530 Subject: [PATCH] HIVE-29353:Add basic support for encoding GeoHash & decoding it to Geometry Change-Id: I3a88b45b021ec8d40bd6a479b6f17ed15a411d38 --- pom.xml | 1 + ql/pom.xml | 7 ++ .../hadoop/hive/ql/exec/FunctionRegistry.java | 4 + .../hadoop/hive/ql/udf/esri/GeoHashUtils.java | 94 ++++++++++++++++ .../hadoop/hive/ql/udf/esri/LogUtils.java | 30 ++++-- .../hadoop/hive/ql/udf/esri/ST_GeoHash.java | 83 ++++++++++++++ .../hive/ql/udf/esri/ST_GeomFromGeoHash.java | 72 +++++++++++++ .../hadoop/hive/ql/udf/esri/TestGeoHash.java | 90 ++++++++++++++++ .../clientpositive/geospatial_geohash.q | 27 +++++ .../llap/geospatial_geohash.q.out | 101 ++++++++++++++++++ .../clientpositive/llap/show_functions.q.out | 4 + 11 files changed, 504 insertions(+), 9 deletions(-) create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/udf/esri/GeoHashUtils.java create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/udf/esri/ST_GeoHash.java create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/udf/esri/ST_GeomFromGeoHash.java create mode 100644 ql/src/test/org/apache/hadoop/hive/ql/udf/esri/TestGeoHash.java create mode 100644 ql/src/test/queries/clientpositive/geospatial_geohash.q create mode 100644 ql/src/test/results/clientpositive/llap/geospatial_geohash.q.out diff --git a/pom.xml b/pom.xml index 038b51d3e14b..776e3a0b8a0b 100644 --- a/pom.xml +++ b/pom.xml @@ -143,6 +143,7 @@ 2.2.4 1.12.0 1.20.0 + 1.4.0 22.0 2.4.21 2.2.220 diff --git a/ql/pom.xml b/ql/pom.xml index c0ba9974aade..099bcf2971cc 100644 --- a/ql/pom.xml +++ b/ql/pom.xml @@ -910,6 +910,12 @@ ${jts.version} compile + + ch.hsr + geohash + ${geohash.version} + compile + org.roaringbitmap RoaringBitmap @@ -1154,6 +1160,7 @@ org.locationtech.jts:jts-core org.locationtech.jts.io:jts-io-common com.esri.geometry:esri-geometry-api + ch.hsr:geohash org.apache.tez:tez-protobuf-history-plugin 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 81b8f30d6527..5d36e9b9c9d8 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 @@ -65,6 +65,8 @@ import org.apache.hadoop.hive.ql.udf.esri.ST_GeomFromGeoJson; import org.apache.hadoop.hive.ql.udf.esri.ST_GeomFromJson; import org.apache.hadoop.hive.ql.udf.esri.ST_GeomFromShape; +import org.apache.hadoop.hive.ql.udf.esri.ST_GeomFromGeoHash; +import org.apache.hadoop.hive.ql.udf.esri.ST_GeoHash; 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; @@ -737,6 +739,8 @@ public final class FunctionRegistry { system.registerFunction("ST_GeomFromGeoJson", ST_GeomFromGeoJson.class); system.registerFunction("ST_GeomFromJson", ST_GeomFromJson.class); system.registerFunction("ST_GeomFromShape", ST_GeomFromShape.class); + system.registerFunction("ST_GeomFromGeoHash", ST_GeomFromGeoHash.class); + system.registerFunction("ST_GeoHash", ST_GeoHash.class); system.registerFunction("ST_GeomFromText", ST_GeomFromText.class); system.registerFunction("ST_GeomFromWKB", ST_GeomFromWKB.class); system.registerFunction("ST_GeometryType", ST_GeometryType.class); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/esri/GeoHashUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/esri/GeoHashUtils.java new file mode 100644 index 000000000000..bc133bc5f0f1 --- /dev/null +++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/esri/GeoHashUtils.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.hadoop.hive.ql.udf.esri; + +import ch.hsr.geohash.BoundingBox; +import ch.hsr.geohash.GeoHash; +import org.locationtech.jts.geom.Coordinate; +import org.locationtech.jts.geom.Polygon; + +public final class GeoHashUtils { + + public static final int MIN_CHARACTER_PRECISION = 1; + + /** + * Maximum geohash length in base-32 characters for {@link GeoHash#geoHashStringWithCharacterPrecision}. + */ + public static final int MAX_CHARACTER_PRECISION = 12; + + public static final int DEFAULT_CHARACTER_PRECISION = 12; + + private GeoHashUtils() { + } + + public static String geohashForPoint(double longitude, double latitude, int characterPrecision) { + return GeoHash.geoHashStringWithCharacterPrecision(latitude, longitude, characterPrecision); + } + + /** + * Returns a rectangular polygon for the geohash cell (closed ring, lon/lat coordinates). + * + * @param geohash base-32 geohash string (non-empty) + * @param characterPrecision number of leading characters to use (1–12, at most {@code geohash} + * length) + */ + public static Polygon geohashCellPolygon(String geohash, int characterPrecision) { + if (geohash == null || geohash.isEmpty()) { + return null; + } + if (characterPrecision < MIN_CHARACTER_PRECISION || + characterPrecision > MAX_CHARACTER_PRECISION || + characterPrecision > geohash.length()) { + return null; + } + String hashPrefix = geohash.substring(0, characterPrecision); + BoundingBox box = GeoHash.fromGeohashString(hashPrefix).getBoundingBox(); + double west = box.getWestLongitude(); + double east = box.getEastLongitude(); + double south = box.getSouthLatitude(); + double north = box.getNorthLatitude(); + // Closed ring (west,south) -> (west,north) -> (east,north) -> (east,south) -> close. + Coordinate[] ring = new Coordinate[] { + new Coordinate(west, south), + new Coordinate(west, north), + new Coordinate(east, north), + new Coordinate(east, south), + new Coordinate(west, south) + }; + return GeometryUtils.GEOMETRY_FACTORY.createPolygon(ring); + } + + public static int resolveEncodePrecision(Integer precisionArg) { + int precision = precisionArg == null ? DEFAULT_CHARACTER_PRECISION : precisionArg; + if (precision < MIN_CHARACTER_PRECISION || precision > MAX_CHARACTER_PRECISION) { + return -1; + } + return precision; + } + + public static int resolveDecodePrecision(Integer precisionArg, int geohashLength) { + int precision = precisionArg == null ? geohashLength : precisionArg; + if (precision < MIN_CHARACTER_PRECISION || + precision > geohashLength || + geohashLength > MAX_CHARACTER_PRECISION) { + return -1; + } + return precision; + } +} diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/esri/LogUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/esri/LogUtils.java index 1d3b1ff3dcee..b8454f2f660f 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/udf/esri/LogUtils.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/esri/LogUtils.java @@ -35,15 +35,23 @@ public class LogUtils { private static final int MSG_EXCEPTION_THROWN = 9; private static final int MSG_NOT_3D = 10; private static final int MSG_NOT_MEASURED = 11; - - private static final String[] messages = - { "Mismatched spatial references ('%d' <> '%d')", "Invalid arguments - one or more arguments are null.", - "Invalid arguments. Expecting one or more x,y pairs.", - "Invalid arguments. Expecting one or more x,y pairs in array argument %d.", - "Invalid geometry type. Expecting %s but found %s", "Invalid arguments. Ill-formed text: %s ....", - "Invalid index. Expected range [%d, %d], actual index %d.", "Internal error - %s.", - "Invalid arguments. Expecting one or more arguments.", "Exception thrown by %s", "Invalid argument - not 3D", - "Invalid argument - not measured" }; + private static final int MSG_INVALID_PRECISION = 12; + + private static final String[] messages = { + "Mismatched spatial references ('%d' <> '%d')", + "Invalid arguments - one or more arguments are null.", + "Invalid arguments. Expecting one or more x,y pairs.", + "Invalid arguments. Expecting one or more x,y pairs in array argument %d.", + "Invalid geometry type. Expecting %s but found %s", + "Invalid arguments. Ill-formed text: %s ....", + "Invalid index. Expected range [%d, %d], actual index %d.", + "Internal error - %s.", + "Invalid arguments. Expecting one or more arguments.", + "Exception thrown by %s", + "Invalid argument - not 3D", + "Invalid argument - not measured", + "Invalid precision - Precision must be between %d and %d" + }; /** * Log when comparing geometries in different spatial references @@ -111,4 +119,8 @@ public static void Log_NotMeasured(Logger logger) { logger.error(messages[MSG_NOT_MEASURED]); } + public static void Log_InvalidPrecision(Logger logger, int minPrecision, int maxPrecision) { + logger.error(String.format(messages[MSG_INVALID_PRECISION], minPrecision, maxPrecision)); + } + } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/esri/ST_GeoHash.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/esri/ST_GeoHash.java new file mode 100644 index 000000000000..c06da074ad44 --- /dev/null +++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/esri/ST_GeoHash.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.hadoop.hive.ql.udf.esri; + +import org.apache.hadoop.hive.ql.exec.Description; +import org.apache.hadoop.io.BytesWritable; +import org.apache.hadoop.io.IntWritable; +import org.apache.hadoop.io.Text; +import org.locationtech.jts.geom.Geometry; +import org.locationtech.jts.geom.Point; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Description( + name = "ST_GeoHash", + value = """ + _FUNC_(point) - geohash for a point geometry + _FUNC_(point, precision) - geohash at given character precision + """, + extended = """ + SELECT _FUNC_(ST_Point(-126.965375, 43.234528), 12); -- 9pttyydekk4t + """) +public class ST_GeoHash extends ST_Geometry { + + static final Logger LOG = LoggerFactory.getLogger(ST_GeoHash.class.getName()); + + public Text evaluate(BytesWritable geomref) { + return evaluate(geomref, null); + } + + public Text evaluate(BytesWritable geomref, IntWritable precisionArg) { + if (geomref == null || geomref.getLength() == 0) { + LogUtils.Log_ArgumentsNull(LOG); + return null; + } + + GeometryUtils.OGCType type = GeometryUtils.getType(geomref); + if (type != GeometryUtils.OGCType.ST_POINT) { + LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_POINT, type); + return null; + } + + Geometry geom = GeometryUtils.geometryFromEsriShape(geomref); + if (geom == null) { + return null; + } + Point point = (Point) geom; + return geohashText(point.getX(), point.getY(), precisionArg); + } + + private Text geohashText(double longitude, double latitude, IntWritable precisionArg) { + int precision = + GeoHashUtils.resolveEncodePrecision(precisionArg == null ? null : precisionArg.get()); + if (precision < 0) { + LogUtils.Log_InvalidPrecision(LOG, GeoHashUtils.MIN_CHARACTER_PRECISION, + GeoHashUtils.MAX_CHARACTER_PRECISION); + return null; + } + try { + String hash = GeoHashUtils.geohashForPoint(longitude, latitude, precision); + return new Text(hash); + } catch (Exception e) { + LogUtils.Log_InternalError(LOG, "ST_GeoHash: " + e); + return null; + } + } +} diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/esri/ST_GeomFromGeoHash.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/esri/ST_GeomFromGeoHash.java new file mode 100644 index 000000000000..7098d6d96ecb --- /dev/null +++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/esri/ST_GeomFromGeoHash.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.hadoop.hive.ql.udf.esri; + +import org.apache.hadoop.hive.ql.exec.Description; +import org.apache.hadoop.io.BytesWritable; +import org.apache.hadoop.io.IntWritable; +import org.apache.hadoop.io.Text; +import org.locationtech.jts.geom.Polygon; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Description( + name = "ST_GeomFromGeoHash", + value = """ + _FUNC_(geohash) - polygon for the geohash cell + _FUNC_(geohash, precision) - polygon using the first precision characters + """, + extended = """ + SELECT ST_AsText(_FUNC_('9ptty', 5)); + """) +public class ST_GeomFromGeoHash extends ST_Geometry { + + static final Logger LOG = LoggerFactory.getLogger(ST_GeomFromGeoHash.class.getName()); + + public BytesWritable evaluate(Text geohashText) { + return evaluate(geohashText, null); + } + + public BytesWritable evaluate(Text geohashText, IntWritable precisionArg) { + String geohash = geohashText != null ? geohashText.toString().trim() : null; + if (geohash == null || geohash.isEmpty()) { + LogUtils.Log_ArgumentsNull(LOG); + return null; + } + + int characterPrecision = GeoHashUtils.resolveDecodePrecision(precisionArg == null ? null : precisionArg.get(), + geohash.length()); + if (characterPrecision < 0) { + LogUtils.Log_InvalidPrecision(LOG, GeoHashUtils.MIN_CHARACTER_PRECISION, + Math.min(geohash.length(), GeoHashUtils.MAX_CHARACTER_PRECISION)); + return null; + } + + try { + Polygon polygon = GeoHashUtils.geohashCellPolygon(geohash, characterPrecision); + if (polygon == null) { + return null; + } + return GeometryUtils.geometryToEsriShapeBytesWritable(polygon); + } catch (Exception e) { + LogUtils.Log_InternalError(LOG, "ST_GeomFromGeoHash: " + e); + return null; + } + } +} diff --git a/ql/src/test/org/apache/hadoop/hive/ql/udf/esri/TestGeoHash.java b/ql/src/test/org/apache/hadoop/hive/ql/udf/esri/TestGeoHash.java new file mode 100644 index 000000000000..e7947c92062d --- /dev/null +++ b/ql/src/test/org/apache/hadoop/hive/ql/udf/esri/TestGeoHash.java @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.hadoop.hive.ql.udf.esri; + +import org.apache.hadoop.hive.serde2.io.DoubleWritable; +import org.apache.hadoop.io.BytesWritable; +import org.apache.hadoop.io.IntWritable; +import org.apache.hadoop.io.Text; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +/** Unit tests for geohash UDFs; golden encode/decode output is covered by geospatial_geohash.q. */ +public class TestGeoHash { + + @Test + public void testStGeoHashFromPoint() { + ST_GeoHash gh = new ST_GeoHash(); + ST_Point pt = new ST_Point(); + BytesWritable geom2d = + pt.evaluate(new DoubleWritable(-126.965375), new DoubleWritable(43.234528)); + assertEquals("9pttyydekk4t", gh.evaluate(geom2d, new IntWritable(12)).toString()); + assertEquals("9ptty", gh.evaluate(geom2d, new IntWritable(5)).toString()); + + BytesWritable geom3d = pt.evaluate(new DoubleWritable(-126.965375), new DoubleWritable(43.234528), + new DoubleWritable(999.0)); + assertEquals("9pttyydekk4t", gh.evaluate(geom3d, new IntWritable(12)).toString()); + } + + @Test + public void testStGeoHashRejectsNonPoint() throws Exception { + ST_GeoHash gh = new ST_GeoHash(); + ST_LineString line = new ST_LineString(); + BytesWritable lineGeom = line.evaluate(new DoubleWritable(0), new DoubleWritable(0), + new DoubleWritable(1), new DoubleWritable(1)); + assertNull(gh.evaluate(lineGeom, new IntWritable(5))); + assertNull(gh.evaluate((BytesWritable) null)); + } + + @Test + public void testStGeoHashInvalidInput() { + ST_GeoHash gh = new ST_GeoHash(); + ST_Point pt = new ST_Point(); + BytesWritable point = pt.evaluate(new DoubleWritable(0), new DoubleWritable(0)); + + assertNull(gh.evaluate((BytesWritable) null)); + assertNull(gh.evaluate(point, new IntWritable(0))); + assertNull(gh.evaluate(point, new IntWritable(13))); + } + + @Test + public void testStGeomFromGeoHashInvalidInput() { + ST_GeomFromGeoHash fromHash = new ST_GeomFromGeoHash(); + assertNull(fromHash.evaluate(null)); + assertNull(fromHash.evaluate(new Text(""))); + assertNull(fromHash.evaluate(new Text("9ptty"), new IntWritable(0))); + assertNull(fromHash.evaluate(new Text("9ptty"), new IntWritable(6))); + assertNull(fromHash.evaluate(new Text("9ptty"), new IntWritable(13))); + } + + @Test + public void testGeoHashUtilsEncode() { + assertEquals(5, GeoHashUtils.geohashForPoint(0, 0, 5).length()); + assertEquals(GeoHashUtils.DEFAULT_CHARACTER_PRECISION, + GeoHashUtils.geohashForPoint(0, 0, GeoHashUtils.DEFAULT_CHARACTER_PRECISION).length()); + } + + @Test + public void testGeoHashUtilsCellPolygon() { + assertTrue(GeoHashUtils.geohashCellPolygon("9ptty", 5).isValid()); + } +} diff --git a/ql/src/test/queries/clientpositive/geospatial_geohash.q b/ql/src/test/queries/clientpositive/geospatial_geohash.q new file mode 100644 index 000000000000..9d30d222bfb4 --- /dev/null +++ b/ql/src/test/queries/clientpositive/geospatial_geohash.q @@ -0,0 +1,27 @@ +create table geohash_points (id int, longitude double, latitude double); + +insert into geohash_points values + (1, -126.965375, 43.234528), + (2, 0, 0), + (3, 19.0, 47.5), + (4, -122.4194, 37.7749); + +select id, longitude, latitude, + ST_GeoHash(ST_Point(longitude, latitude), 12) as geohash12, + ST_GeoHash(ST_Point(longitude, latitude), 5) as geohash5 +from geohash_points +order by id; + +-- Decode geohash cell. +select ST_AsText(ST_GeomFromGeoHash('9ptty', 5)); + +select ST_AsText(ST_GeomFromGeoHash('9ptty')); + +select ST_NumPoints(ST_GeomFromGeoHash('9ptty', 5)); + +-- Single-row sanity checks (null / invalid precision). +select ST_GeoHash(ST_Point(0, 0), 0); + +select ST_GeoHash(null); + +select ST_GeomFromGeoHash('9ptty', 0); diff --git a/ql/src/test/results/clientpositive/llap/geospatial_geohash.q.out b/ql/src/test/results/clientpositive/llap/geospatial_geohash.q.out new file mode 100644 index 000000000000..5451fac2f2c8 --- /dev/null +++ b/ql/src/test/results/clientpositive/llap/geospatial_geohash.q.out @@ -0,0 +1,101 @@ +PREHOOK: query: create table geohash_points (id int, longitude double, latitude double) +PREHOOK: type: CREATETABLE +PREHOOK: Output: database:default +PREHOOK: Output: default@geohash_points +POSTHOOK: query: create table geohash_points (id int, longitude double, latitude double) +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: database:default +POSTHOOK: Output: default@geohash_points +PREHOOK: query: insert into geohash_points values + (1, -126.965375, 43.234528), + (2, 0, 0), + (3, 19.0, 47.5), + (4, -122.4194, 37.7749) +PREHOOK: type: QUERY +PREHOOK: Input: _dummy_database@_dummy_table +PREHOOK: Output: default@geohash_points +POSTHOOK: query: insert into geohash_points values + (1, -126.965375, 43.234528), + (2, 0, 0), + (3, 19.0, 47.5), + (4, -122.4194, 37.7749) +POSTHOOK: type: QUERY +POSTHOOK: Input: _dummy_database@_dummy_table +POSTHOOK: Output: default@geohash_points +POSTHOOK: Lineage: geohash_points.id SCRIPT [] +POSTHOOK: Lineage: geohash_points.latitude SCRIPT [] +POSTHOOK: Lineage: geohash_points.longitude SCRIPT [] +PREHOOK: query: select id, longitude, latitude, + ST_GeoHash(ST_Point(longitude, latitude), 12) as geohash12, + ST_GeoHash(ST_Point(longitude, latitude), 5) as geohash5 +from geohash_points +order by id +PREHOOK: type: QUERY +PREHOOK: Input: default@geohash_points +#### A masked pattern was here #### +POSTHOOK: query: select id, longitude, latitude, + ST_GeoHash(ST_Point(longitude, latitude), 12) as geohash12, + ST_GeoHash(ST_Point(longitude, latitude), 5) as geohash5 +from geohash_points +order by id +POSTHOOK: type: QUERY +POSTHOOK: Input: default@geohash_points +#### A masked pattern was here #### +1 -126.965375 43.234528 9pttyydekk4t 9ptty +2 0.0 0.0 s00000000000 s0000 +3 19.0 47.5 u2mw0r57s1fb u2mw0 +4 -122.4194 37.7749 9q8yyk8ytpxr 9q8yy +PREHOOK: query: select ST_AsText(ST_GeomFromGeoHash('9ptty', 5)) +PREHOOK: type: QUERY +PREHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +POSTHOOK: query: select ST_AsText(ST_GeomFromGeoHash('9ptty', 5)) +POSTHOOK: type: QUERY +POSTHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +POLYGON ((-127.001953125 43.1982421875, -126.9580078125 43.1982421875, -126.9580078125 43.2421875, -127.001953125 43.2421875, -127.001953125 43.1982421875)) +PREHOOK: query: select ST_AsText(ST_GeomFromGeoHash('9ptty')) +PREHOOK: type: QUERY +PREHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +POSTHOOK: query: select ST_AsText(ST_GeomFromGeoHash('9ptty')) +POSTHOOK: type: QUERY +POSTHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +POLYGON ((-127.001953125 43.1982421875, -126.9580078125 43.1982421875, -126.9580078125 43.2421875, -127.001953125 43.2421875, -127.001953125 43.1982421875)) +PREHOOK: query: select ST_NumPoints(ST_GeomFromGeoHash('9ptty', 5)) +PREHOOK: type: QUERY +PREHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +POSTHOOK: query: select ST_NumPoints(ST_GeomFromGeoHash('9ptty', 5)) +POSTHOOK: type: QUERY +POSTHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +5 +PREHOOK: query: select ST_GeoHash(ST_Point(0, 0), 0) +PREHOOK: type: QUERY +PREHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +POSTHOOK: query: select ST_GeoHash(ST_Point(0, 0), 0) +POSTHOOK: type: QUERY +POSTHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +NULL +PREHOOK: query: select ST_GeoHash(null) +PREHOOK: type: QUERY +PREHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +POSTHOOK: query: select ST_GeoHash(null) +POSTHOOK: type: QUERY +POSTHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +NULL +PREHOOK: query: select ST_GeomFromGeoHash('9ptty', 0) +PREHOOK: type: QUERY +PREHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +POSTHOOK: query: select ST_GeomFromGeoHash('9ptty', 0) +POSTHOOK: type: QUERY +POSTHOOK: Input: _dummy_database@_dummy_table +#### A masked pattern was here #### +NULL 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 605e953d6349..2bf11504a137 100644 --- a/ql/src/test/results/clientpositive/llap/show_functions.q.out +++ b/ql/src/test/results/clientpositive/llap/show_functions.q.out @@ -390,9 +390,11 @@ st_envintersects st_equals st_exteriorring st_geodesiclengthwgs84 +st_geohash st_geomcollection st_geometryn st_geometrytype +st_geomfromgeohash st_geomfromgeojson st_geomfromjson st_geomfromshape @@ -1032,9 +1034,11 @@ st_envintersects st_equals st_exteriorring st_geodesiclengthwgs84 +st_geohash st_geomcollection st_geometryn st_geometrytype +st_geomfromgeohash st_geomfromgeojson st_geomfromjson st_geomfromshape