From 1ddd3ede6cbd43892dbda9dd9bffd1c8daaddc12 Mon Sep 17 00:00:00 2001 From: Valentin de la Cruz Barquero <6054336+vdelacruzb@users.noreply.github.com> Date: Tue, 29 Oct 2024 11:26:06 +0100 Subject: [PATCH] release: 2024-10-28 (#533) --- CHANGELOG.md | 5 +++ clouds/bigquery/CHANGELOG.md | 5 +++ clouds/bigquery/common/package.json | 2 +- .../modules/doc/h3/H3_FROMGEOGPOINT.md | 2 +- clouds/bigquery/modules/doc/h3/H3_POLYFILL.md | 2 +- .../modules/doc/h3/H3_POLYFILL_MODE.md | 2 +- .../modules/doc/h3/H3_POLYFILL_TABLE.md | 2 +- .../doc/quadbin/QUADBIN_FROMGEOGPOINT.md | 2 +- .../doc/quadbin/QUADBIN_FROMLONGLAT.md | 2 +- .../modules/doc/quadbin/QUADBIN_POLYFILL.md | 2 +- .../doc/quadbin/QUADBIN_POLYFILL_MODE.md | 2 +- .../doc/quadbin/QUADBIN_POLYFILL_TABLE.md | 2 +- .../modules/doc/s2/S2_FROMGEOGPOINT.md | 2 +- .../modules/sql/h3/H3_FROMGEOGPOINT.sql | 15 +++++++-- .../sql/quadbin/QUADBIN_FROMGEOGPOINT.sql | 15 +++++++-- .../modules/test/h3/H3_FROMGEOGPOINT.test.js | 31 +++++++++++++++++ .../quadbin/QUADBIN_FROMGEOGPOINT.test.js | 7 ++++ clouds/bigquery/version | 2 +- clouds/postgres/CHANGELOG.md | 4 +++ .../modules/doc/h3/H3_FROMGEOGPOINT.md | 2 +- clouds/postgres/modules/doc/h3/H3_POLYFILL.md | 2 +- .../doc/quadbin/QUADBIN_FROMGEOGPOINT.md | 2 +- .../doc/quadbin/QUADBIN_FROMLONGLAT.md | 2 +- .../modules/doc/quadbin/QUADBIN_POLYFILL.md | 2 +- .../modules/sql/h3/H3_FROMGEOGPOINT.sql | 17 ++++++++-- .../sql/quadbin/QUADBIN_FROMGEOGPOINT.sql | 17 ++++++++-- .../modules/test/h3/test_H3_FROMGEOGPOINT.py | 31 +++++++++++++++++ .../quadbin/test_QUADBIN_FROMGEOGPOINT.py | 8 +++++ clouds/postgres/version | 2 +- clouds/redshift/CHANGELOG.md | 4 +++ .../doc/quadbin/QUADBIN_FROMGEOGPOINT.md | 2 +- .../doc/quadbin/QUADBIN_FROMLONGLAT.md | 2 +- .../modules/doc/quadbin/QUADBIN_POLYFILL.md | 2 +- .../modules/doc/s2/S2_FROMGEOGPOINT.md | 2 +- .../redshift/modules/doc/s2/S2_FROMLONGLAT.md | 2 +- .../sql/quadbin/QUADBIN_FROMGEOGPOINT.sql | 15 +++++++-- .../quadbin/test_QUADBIN_FROMGEOGPOINT.py | 9 +++++ clouds/redshift/version | 2 +- clouds/snowflake/CHANGELOG.md | 4 +++ .../modules/doc/h3/H3_FROMGEOGPOINT.md | 2 +- .../modules/doc/h3/H3_POLYFILL_TABLE.md | 2 +- .../doc/quadbin/QUADBIN_FROMGEOGPOINT.md | 2 +- .../doc/quadbin/QUADBIN_FROMLONGLAT.md | 2 +- .../modules/doc/quadbin/QUADBIN_POLYFILL.md | 2 +- .../modules/doc/s2/S2_FROMGEOGPOINT.md | 2 +- .../modules/sql/h3/H3_FROMGEOGPOINT.sql | 8 +++++ .../sql/quadbin/QUADBIN_FROMGEOGPOINT.sql | 14 ++++++-- ...POINT.spec.js => H3_FROMGEOGPOINT.test.js} | 33 +++++++++++++++++++ ...LONGLAT.spec.js => H3_FROMLONGLAT.test.js} | 0 .../quadbin/QUADBIN_FROMGEOGPOINT.test.js | 7 ++++ clouds/snowflake/version | 2 +- 51 files changed, 262 insertions(+), 49 deletions(-) rename clouds/snowflake/modules/test/h3/{H3_FROMGEOGPOINT.spec.js => H3_FROMGEOGPOINT.test.js} (62%) rename clouds/snowflake/modules/test/h3/{H3_FROMLONGLAT.spec.js => H3_FROMLONGLAT.test.js} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8000d888a..70c97ee15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ CARTO Analytics Toolbox Core. All notable commits to this project will be documented in this file. +## 2024-10-28 + +- chore(bq): fix @google-cloud/bigquery to version 7.9.0 (#531) +- chore(bq,sf,rs,pg|h3,quadbin): added "geo" aliases for certain functions (#526) + ## 2024-09-23 - feat(sf): added warehouse option for SF (#524) diff --git a/clouds/bigquery/CHANGELOG.md b/clouds/bigquery/CHANGELOG.md index d25171df8..d82bac8e9 100644 --- a/clouds/bigquery/CHANGELOG.md +++ b/clouds/bigquery/CHANGELOG.md @@ -4,6 +4,11 @@ CARTO Analytics Toolbox Core for BigQuery. All notable commits to this project will be documented in this file. +## [1.2.4] - 2024-10-28 + +- chore: fix @google-cloud/bigquery to version 7.9.0 (#531) +- chore(h3,quadbin): added "geo" aliases for certain functions (#526) + ## [1.2.3] - 2024-06-27 - chore(quadbin): optimize polyfill (#513) diff --git a/clouds/bigquery/common/package.json b/clouds/bigquery/common/package.json index cb669992e..0343e37c9 100644 --- a/clouds/bigquery/common/package.json +++ b/clouds/bigquery/common/package.json @@ -1,7 +1,7 @@ { "license": "BSD-3-Clause", "devDependencies": { - "@google-cloud/bigquery": "^7.3.0", + "@google-cloud/bigquery": "7.9.0", "@rollup/plugin-commonjs": "^17.1.0", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^13.0.0", diff --git a/clouds/bigquery/modules/doc/h3/H3_FROMGEOGPOINT.md b/clouds/bigquery/modules/doc/h3/H3_FROMGEOGPOINT.md index 63bd18b66..5f92aaee1 100644 --- a/clouds/bigquery/modules/doc/h3/H3_FROMGEOGPOINT.md +++ b/clouds/bigquery/modules/doc/h3/H3_FROMGEOGPOINT.md @@ -6,7 +6,7 @@ H3_FROMGEOGPOINT(point, resolution) **Description** -Returns the H3 cell index that the point belongs to in the required `resolution`. It will return `null` on error (invalid geography type or resolution out of bounds). +Returns the H3 cell index that the point belongs to in the requested `resolution`. It will return `null` on error (invalid geography type or resolution out of bounds). This function is an alias for `H3_FROMGEOPOINT`. * `point`: `GEOGRAPHY` point to get the H3 cell from. * `resolution`: `INT64` number between 0 and 15 with the [H3 resolution](https://h3geo.org/docs/core-library/restable). diff --git a/clouds/bigquery/modules/doc/h3/H3_POLYFILL.md b/clouds/bigquery/modules/doc/h3/H3_POLYFILL.md index 72067fd74..7ff458703 100644 --- a/clouds/bigquery/modules/doc/h3/H3_POLYFILL.md +++ b/clouds/bigquery/modules/doc/h3/H3_POLYFILL.md @@ -6,7 +6,7 @@ H3_POLYFILL(geog, resolution) **Description** -Returns an array of H3 cell indexes contained in the given geography (Polygon, MultiPolygon) at a given level of detail. Containment is determined by the cells' center. This function is equivalent to [`H3_POLYFILL_MODE`](h3#h3_polyfill_mode) with mode `center`. +Returns an array of H3 cell indexes contained in the given geography (Polygon, MultiPolygon) at a requested resolution. Containment is determined by the cells' center. This function is equivalent to [`H3_POLYFILL_MODE`](h3#h3_polyfill_mode) with mode `center`. * `geog`: `GEOGRAPHY` representing the shape to cover. * `resolution`: `INT64` level of detail. The value must be between 0 and 15 ([H3 resolution table](https://h3geo.org/docs/core-library/restable)). diff --git a/clouds/bigquery/modules/doc/h3/H3_POLYFILL_MODE.md b/clouds/bigquery/modules/doc/h3/H3_POLYFILL_MODE.md index da41d4e68..00f2f3891 100644 --- a/clouds/bigquery/modules/doc/h3/H3_POLYFILL_MODE.md +++ b/clouds/bigquery/modules/doc/h3/H3_POLYFILL_MODE.md @@ -6,7 +6,7 @@ H3_POLYFILL_MODE(geog, resolution, mode) **Description** -Returns an array of H3 cell indexes contained in the given geography at a given level of detail. Containment is determined by the mode: center, intersects, contains. +Returns an array of H3 cell indexes contained in the given geography at a requested resolution. Containment is determined by the mode: center, intersects, contains. * `geog`: `GEOGRAPHY` representing the shape to cover. * `resolution`: `INT64` level of detail. The value must be between 0 and 15 ([H3 resolution table](https://h3geo.org/docs/core-library/restable)). diff --git a/clouds/bigquery/modules/doc/h3/H3_POLYFILL_TABLE.md b/clouds/bigquery/modules/doc/h3/H3_POLYFILL_TABLE.md index 885c23b72..5491aabb9 100644 --- a/clouds/bigquery/modules/doc/h3/H3_POLYFILL_TABLE.md +++ b/clouds/bigquery/modules/doc/h3/H3_POLYFILL_TABLE.md @@ -6,7 +6,7 @@ H3_POLYFILL_TABLE(input_query, resolution, mode, output_table) **Description** -Returns a table with the H3 cell indexes contained in the given geography at a given level of detail. Containment is determined by the mode: center, intersects, contains. All the attributes except the geography will be included in the output table, clustered by the h3 column. +Returns a table with the H3 cell indexes contained in the given geography at a requested resolution. Containment is determined by the mode: center, intersects, contains. All the attributes except the geography will be included in the output table, clustered by the h3 column. * `input_query`: `STRING` input data to polyfill. It must contain a column `geom` with the shape to cover. Additionally, other columns can be included. * `resolution`: `INT64` level of detail. The value must be between 0 and 15 ([H3 resolution table](https://h3geo.org/docs/core-library/restable)). diff --git a/clouds/bigquery/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md b/clouds/bigquery/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md index 59799e32f..a72b28323 100644 --- a/clouds/bigquery/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md +++ b/clouds/bigquery/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md @@ -6,7 +6,7 @@ QUADBIN_FROMGEOGPOINT(point, resolution) **Description** -Returns the Quadbin of a given point at a given level of detail. +Returns the Quadbin of a given point at a requested resolution. This function is an alias for `QUADBIN_FROMGEOPOINT`. * `point`: `GEOGRAPHY` point to get the Quadbin from. * `resolution`: `INT64` level of detail or zoom. diff --git a/clouds/bigquery/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md b/clouds/bigquery/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md index e992b2bd1..4cddb420c 100644 --- a/clouds/bigquery/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md +++ b/clouds/bigquery/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md @@ -6,7 +6,7 @@ QUADBIN_FROMLONGLAT(longitude, latitude, resolution) **Description** -Returns the Quadbin representation of a point for a given level of detail and geographic coordinates. +Returns the Quadbin representation of a point for a requested resolution and geographic coordinates. * `longitude`: `FLOAT64` longitude (WGS84) of the point. * `latitude`: `FLOAT64` latitude (WGS84) of the point. diff --git a/clouds/bigquery/modules/doc/quadbin/QUADBIN_POLYFILL.md b/clouds/bigquery/modules/doc/quadbin/QUADBIN_POLYFILL.md index 86dbb8407..4abbf4126 100644 --- a/clouds/bigquery/modules/doc/quadbin/QUADBIN_POLYFILL.md +++ b/clouds/bigquery/modules/doc/quadbin/QUADBIN_POLYFILL.md @@ -6,7 +6,7 @@ QUADBIN_POLYFILL(geog, resolution) **Description** -Returns an array of quadbin cell indexes contained in the given geography (Polygon, MultiPolygon) at a given level of detail. Containment is determined by the cells' center. This function is equivalent to [`QUADBIN_POLYFILL_MODE`](quadbin#quadbin_polyfill_mode) with mode `center`. +Returns an array of quadbin cell indexes contained in the given geography (Polygon, MultiPolygon) at a requested resolution. Containment is determined by the cells' center. This function is equivalent to [`QUADBIN_POLYFILL_MODE`](quadbin#quadbin_polyfill_mode) with mode `center`. * `geog`: `GEOGRAPHY` representing the shape to cover. * `resolution`: `INT64` level of detail. The value must be between 0 and 26. diff --git a/clouds/bigquery/modules/doc/quadbin/QUADBIN_POLYFILL_MODE.md b/clouds/bigquery/modules/doc/quadbin/QUADBIN_POLYFILL_MODE.md index a88990d71..80e10d6c4 100644 --- a/clouds/bigquery/modules/doc/quadbin/QUADBIN_POLYFILL_MODE.md +++ b/clouds/bigquery/modules/doc/quadbin/QUADBIN_POLYFILL_MODE.md @@ -6,7 +6,7 @@ QUADBIN_POLYFILL_MODE(geog, resolution, mode) **Description** -Returns an array of quadbin cell indexes contained in the given geography at a given level of detail. Containment is determined by the mode: center, intersects, contains. +Returns an array of quadbin cell indexes contained in the given geography at a requested resolution. Containment is determined by the mode: center, intersects, contains. * `geog`: `GEOGRAPHY` representing the shape to cover. * `resolution`: `INT64` level of detail. The value must be between 0 and 26. diff --git a/clouds/bigquery/modules/doc/quadbin/QUADBIN_POLYFILL_TABLE.md b/clouds/bigquery/modules/doc/quadbin/QUADBIN_POLYFILL_TABLE.md index f3f59728a..ccc695491 100644 --- a/clouds/bigquery/modules/doc/quadbin/QUADBIN_POLYFILL_TABLE.md +++ b/clouds/bigquery/modules/doc/quadbin/QUADBIN_POLYFILL_TABLE.md @@ -6,7 +6,7 @@ QUADBIN_POLYFILL_TABLE(input_query, resolution, mode, output_table) **Description** -Returns a table with the quadbin cell indexes contained in the given geography at a given level of detail. Containment is determined by the mode: center, intersects, contains. All the attributes except the geography will be included in the output table, clustered by the quadbin column. +Returns a table with the quadbin cell indexes contained in the given geography at a requested resolution. Containment is determined by the mode: center, intersects, contains. All the attributes except the geography will be included in the output table, clustered by the quadbin column. * `input_query`: `STRING` input data to polyfill. It must contain a column `geom` with the shape to cover. Additionally, other columns can be included. * `resolution`: `INT64` level of detail. The value must be between 0 and 26. diff --git a/clouds/bigquery/modules/doc/s2/S2_FROMGEOGPOINT.md b/clouds/bigquery/modules/doc/s2/S2_FROMGEOGPOINT.md index 9e4899640..f7e40ce5a 100644 --- a/clouds/bigquery/modules/doc/s2/S2_FROMGEOGPOINT.md +++ b/clouds/bigquery/modules/doc/s2/S2_FROMGEOGPOINT.md @@ -6,7 +6,7 @@ S2_FROMGEOGPOINT(point, resolution) **Description** -Returns the S2 cell ID of a given point at a given level of detail. +Returns the S2 cell ID of a given point at a requested resolution. * `point`: `GEOGRAPHY` point to get the ID from. * `resolution`: `INT64` level of detail or zoom. diff --git a/clouds/bigquery/modules/sql/h3/H3_FROMGEOGPOINT.sql b/clouds/bigquery/modules/sql/h3/H3_FROMGEOGPOINT.sql index 12ad026a3..f6725b114 100644 --- a/clouds/bigquery/modules/sql/h3/H3_FROMGEOGPOINT.sql +++ b/clouds/bigquery/modules/sql/h3/H3_FROMGEOGPOINT.sql @@ -1,6 +1,6 @@ ----------------------------- --- Copyright (C) 2021 CARTO ----------------------------- +-------------------------------- +-- Copyright (C) 2021-2024 CARTO +-------------------------------- CREATE OR REPLACE FUNCTION `@@BQ_DATASET@@.H3_FROMGEOGPOINT` (geog GEOGRAPHY, resolution INT64) @@ -10,3 +10,12 @@ AS ( SAFE.ST_X(geog), SAFE.ST_Y(geog), resolution ) ); + +CREATE OR REPLACE FUNCTION `@@BQ_DATASET@@.H3_FROMGEOPOINT` +(geo GEOGRAPHY, resolution INT64) +RETURNS STRING +AS ( + `@@BQ_DATASET@@.H3_FROMGEOGPOINT`( + geo, resolution + ) +); diff --git a/clouds/bigquery/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql b/clouds/bigquery/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql index 53cf9ecd1..94eaa4570 100644 --- a/clouds/bigquery/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql +++ b/clouds/bigquery/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql @@ -1,6 +1,6 @@ ----------------------------- --- Copyright (C) 2022 CARTO ----------------------------- +-------------------------------- +-- Copyright (C) 2022-2024 CARTO +-------------------------------- CREATE OR REPLACE FUNCTION `@@BQ_DATASET@@.QUADBIN_FROMGEOGPOINT` (point GEOGRAPHY, resolution INT64) @@ -10,3 +10,12 @@ AS ( ST_X(point), ST_Y(point), resolution ) ); + +CREATE OR REPLACE FUNCTION `@@BQ_DATASET@@.QUADBIN_FROMGEOPOINT` +(point GEOGRAPHY, resolution INT64) +RETURNS INT64 +AS ( + `@@BQ_DATASET@@.QUADBIN_FROMGEOGPOINT`( + point, resolution + ) +); diff --git a/clouds/bigquery/modules/test/h3/H3_FROMGEOGPOINT.test.js b/clouds/bigquery/modules/test/h3/H3_FROMGEOGPOINT.test.js index fe75d3e43..f8ce4d8aa 100644 --- a/clouds/bigquery/modules/test/h3/H3_FROMGEOGPOINT.test.js +++ b/clouds/bigquery/modules/test/h3/H3_FROMGEOGPOINT.test.js @@ -50,4 +50,35 @@ test('H3_FROMGEOGPOINT returns NULL with non POINT geographies', async () => { null, null ]); +}); + +test('H3_FROMGEOPOINT returns the proper INT64', async () => { + const query = ` + WITH inputs AS + ( + SELECT 1 AS id, ST_GEOGPOINT(-122.0553238, 37.3615593) as geom, 5 as resolution UNION ALL + SELECT 2 AS id, ST_GEOGPOINT(-164.991559, 30.943387) as geom, 5 as resolution UNION ALL + SELECT 3 AS id, ST_GEOGPOINT(71.52790329909925, 46.04189431883772) as geom, 15 as resolution UNION ALL + + -- null inputs + SELECT 4 AS id, NULL AS geom, 5 as resolution UNION ALL + SELECT 5 AS id, ST_GEOGPOINT(-122.0553238, 37.3615593) as geom, -1 as resolution UNION ALL + SELECT 6 AS id, ST_GEOGPOINT(-122.0553238, 37.3615593) as geom, 20 as resolution UNION ALL + SELECT 7 AS id, ST_GEOGPOINT(-122.0553238, 37.3615593) as geom, NULL as resolution + ) + SELECT CAST(\`@@BQ_DATASET@@.H3_FROMGEOPOINT\`(geom, resolution) AS STRING) as h3_id + FROM inputs + ORDER BY id ASC + `; + const rows = await runQuery(query); + expect(rows.length).toEqual(7); + expect(rows.map((r) => r.h3_id)).toEqual([ + '85283473fffffff', + '8547732ffffffff', + '8f2000000000000', + null, + null, + null, + null + ]); }); \ No newline at end of file diff --git a/clouds/bigquery/modules/test/quadbin/QUADBIN_FROMGEOGPOINT.test.js b/clouds/bigquery/modules/test/quadbin/QUADBIN_FROMGEOGPOINT.test.js index 51f2a03dd..93b094856 100644 --- a/clouds/bigquery/modules/test/quadbin/QUADBIN_FROMGEOGPOINT.test.js +++ b/clouds/bigquery/modules/test/quadbin/QUADBIN_FROMGEOGPOINT.test.js @@ -5,4 +5,11 @@ test('QUADBIN_FROMGEOGPOINT should work', async () => { const rows = await runQuery(query); expect(rows.length).toEqual(1); expect(rows[0].output).toEqual('5209574053332910079'); +}); + +test('QUADBIN_FROMGEOPOINT should work', async () => { + const query = 'SELECT CAST(`@@BQ_DATASET@@.QUADBIN_FROMGEOPOINT`(ST_GEOGPOINT(40.4168, -3.7038), 4) AS STRING) AS output'; + const rows = await runQuery(query); + expect(rows.length).toEqual(1); + expect(rows[0].output).toEqual('5209574053332910079'); }); \ No newline at end of file diff --git a/clouds/bigquery/version b/clouds/bigquery/version index 0495c4a88..e8ea05db8 100644 --- a/clouds/bigquery/version +++ b/clouds/bigquery/version @@ -1 +1 @@ -1.2.3 +1.2.4 diff --git a/clouds/postgres/CHANGELOG.md b/clouds/postgres/CHANGELOG.md index c79ebd098..c7f3a0185 100644 --- a/clouds/postgres/CHANGELOG.md +++ b/clouds/postgres/CHANGELOG.md @@ -4,6 +4,10 @@ CARTO Analytics Toolbox Core for Postgres. All notable commits to this project will be documented in this file. +## [1.3.1] - 2024-10-28 + +- chore(h3,quadbin): added "geo" aliases for certain functions (#526) + ## [1.3.0] - 2024-01-17 - feat(quadbin): add function QUADBIN_DISTANCE (#457) diff --git a/clouds/postgres/modules/doc/h3/H3_FROMGEOGPOINT.md b/clouds/postgres/modules/doc/h3/H3_FROMGEOGPOINT.md index acd6c6a4f..3972eebef 100644 --- a/clouds/postgres/modules/doc/h3/H3_FROMGEOGPOINT.md +++ b/clouds/postgres/modules/doc/h3/H3_FROMGEOGPOINT.md @@ -6,7 +6,7 @@ H3_FROMGEOGPOINT(point, resolution) **Description** -Returns the H3 cell index that the point belongs to in the required `resolution`. It will return `null` on error (invalid geography type or resolution out of bounds). +Returns the H3 cell index that the point belongs to in the requested `resolution`. It will return `null` on error (invalid geography type or resolution out of bounds). This function is an alias for `H3_FROMGEOPOINT`. * `point`: `GEOMETRY` point to get the H3 cell from. * `resolution`: `INT` number between 0 and 15 with the [H3 resolution](https://h3geo.org/docs/core-library/restable). diff --git a/clouds/postgres/modules/doc/h3/H3_POLYFILL.md b/clouds/postgres/modules/doc/h3/H3_POLYFILL.md index f0d82c1a3..76b71f69f 100644 --- a/clouds/postgres/modules/doc/h3/H3_POLYFILL.md +++ b/clouds/postgres/modules/doc/h3/H3_POLYFILL.md @@ -6,7 +6,7 @@ H3_POLYFILL(geom, resolution [, mode]) **Description** -Returns an array of H3 cell indexes contained in the given geometry at a given level of detail. Containment is determined by the mode: center, intersects, contains. +Returns an array of H3 cell indexes contained in the given geometry at a requested resolution. Containment is determined by the mode: center, intersects, contains. * `geom`: `GEOMETRY` representing the shape to cover. * `resolution`: `INT` level of detail. The value must be between 0 and 15 ([H3 resolution table](https://h3geo.org/docs/core-library/restable)). diff --git a/clouds/postgres/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md b/clouds/postgres/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md index 18a095d29..d8d339541 100644 --- a/clouds/postgres/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md +++ b/clouds/postgres/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md @@ -6,7 +6,7 @@ QUADBIN_FROMGEOGPOINT(point, resolution) **Description** -Returns the Quadbin of a given point at a given level of detail. +Returns the Quadbin of a given point at a requested resolution. This function is an alias for `QUADBIN_FROMGEOPOINT`. * `point`: `GEOMETRY` point to get the Quadbin from. * `resolution`: `BIGINT` level of detail or zoom. diff --git a/clouds/postgres/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md b/clouds/postgres/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md index 459e6209a..c775c5e42 100644 --- a/clouds/postgres/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md +++ b/clouds/postgres/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md @@ -6,7 +6,7 @@ QUADBIN_FROMLONGLAT(longitude, latitude, resolution) **Description** -Returns the Quadbin representation of a point for a given level of detail and geographic coordinates. +Returns the Quadbin representation of a point for a requested resolution and geographic coordinates. * `longitude`: `DOUBLE PRECISION` longitude (WGS84) of the point. * `latitude`: `DOUBLE PRECISION` latitude (WGS84) of the point. diff --git a/clouds/postgres/modules/doc/quadbin/QUADBIN_POLYFILL.md b/clouds/postgres/modules/doc/quadbin/QUADBIN_POLYFILL.md index 5634f4200..a6ffed008 100644 --- a/clouds/postgres/modules/doc/quadbin/QUADBIN_POLYFILL.md +++ b/clouds/postgres/modules/doc/quadbin/QUADBIN_POLYFILL.md @@ -6,7 +6,7 @@ QUADBIN_POLYFILL(geom, resolution [, mode]) **Description** -Returns an array of quadbin cell indexes contained in the given geometry at a given level of detail. Containment is determined by the mode: center, intersects, contains. +Returns an array of quadbin cell indexes contained in the given geometry at a requested resolution. Containment is determined by the mode: center, intersects, contains. * `geom`: `GEOMETRY` representing the shape to cover. * `resolution`: `INT` level of detail. The value must be between 0 and 26. diff --git a/clouds/postgres/modules/sql/h3/H3_FROMGEOGPOINT.sql b/clouds/postgres/modules/sql/h3/H3_FROMGEOGPOINT.sql index 4c66d3c4c..664818065 100644 --- a/clouds/postgres/modules/sql/h3/H3_FROMGEOGPOINT.sql +++ b/clouds/postgres/modules/sql/h3/H3_FROMGEOGPOINT.sql @@ -1,6 +1,6 @@ ----------------------------- --- Copyright (C) 2023 CARTO ----------------------------- +-------------------------------- +-- Copyright (C) 2023-2024 CARTO +-------------------------------- CREATE OR REPLACE FUNCTION @@PG_SCHEMA@@.H3_FROMGEOGPOINT( geog GEOMETRY, @@ -17,3 +17,14 @@ $BODY$ END $BODY$ LANGUAGE sql IMMUTABLE PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION @@PG_SCHEMA@@.H3_FROMGEOPOINT( + geo GEOMETRY, + resolution INT +) +RETURNS VARCHAR(16) +AS +$BODY$ + SELECT @@PG_SCHEMA@@.H3_FROMGEOGPOINT(geo, resolution) +$BODY$ +LANGUAGE sql IMMUTABLE PARALLEL SAFE; diff --git a/clouds/postgres/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql b/clouds/postgres/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql index ff3a1ea6c..140020bb5 100644 --- a/clouds/postgres/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql +++ b/clouds/postgres/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql @@ -1,6 +1,6 @@ ----------------------------- --- Copyright (C) 2022 CARTO ----------------------------- +-------------------------------- +-- Copyright (C) 2022-2024 CARTO +-------------------------------- CREATE OR REPLACE FUNCTION @@PG_SCHEMA@@.QUADBIN_FROMGEOGPOINT( point GEOMETRY, @@ -20,3 +20,14 @@ $BODY$ FROM __geom4326; $BODY$ LANGUAGE sql IMMUTABLE PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION @@PG_SCHEMA@@.QUADBIN_FROMGEOPOINT( + point GEOMETRY, + resolution INT +) +RETURNS BIGINT +AS +$BODY$ + SELECT @@PG_SCHEMA@@.QUADBIN_FROMGEOGPOINT(point, resolution) +$BODY$ +LANGUAGE sql IMMUTABLE PARALLEL SAFE; diff --git a/clouds/postgres/modules/test/h3/test_H3_FROMGEOGPOINT.py b/clouds/postgres/modules/test/h3/test_H3_FROMGEOGPOINT.py index b75073ead..a829113ef 100644 --- a/clouds/postgres/modules/test/h3/test_H3_FROMGEOGPOINT.py +++ b/clouds/postgres/modules/test/h3/test_H3_FROMGEOGPOINT.py @@ -51,3 +51,34 @@ def test_h3_fromgeogpoint_non_points(): assert result[0][0] is None assert result[1][0] is None assert result[2][0] is None + + +def test_h3_fromgeopoint(): + """Returns the proper index.""" + result = run_query( + """ + WITH inputs AS + ( + SELECT 1 AS id, ST_POINT(-122.0553238, 37.3615593) as geom, 5 as resolution UNION ALL + SELECT 2 AS id, ST_POINT(-164.991559, 30.943387) as geom, 5 as resolution UNION ALL + SELECT 3 AS id, ST_POINT(71.52790329909925, 46.04189431883772) as geom, 15 as resolution UNION ALL + + -- null inputs + SELECT 4 AS id, NULL AS geom, 5 as resolution UNION ALL + SELECT 5 AS id, ST_POINT(-122.0553238, 37.3615593) as geom, -1 as resolution UNION ALL + SELECT 6 AS id, ST_POINT(-122.0553238, 37.3615593) as geom, 20 as resolution UNION ALL + SELECT 7 AS id, ST_POINT(-122.0553238, 37.3615593) as geom, NULL as resolution + ) + SELECT @@PG_SCHEMA@@.H3_FROMGEOPOINT(geom, resolution) as h3_id + FROM inputs + ORDER BY id ASC + """ # noqa + ) + assert len(result) == 7 + assert result[0][0] == '85283473fffffff' + assert result[1][0] == '8547732ffffffff' + assert result[2][0] == '8f2000000000000' + assert result[3][0] is None + assert result[4][0] is None + assert result[5][0] is None + assert result[6][0] is None diff --git a/clouds/postgres/modules/test/quadbin/test_QUADBIN_FROMGEOGPOINT.py b/clouds/postgres/modules/test/quadbin/test_QUADBIN_FROMGEOGPOINT.py index 0589405c2..525d0387e 100644 --- a/clouds/postgres/modules/test/quadbin/test_QUADBIN_FROMGEOGPOINT.py +++ b/clouds/postgres/modules/test/quadbin/test_QUADBIN_FROMGEOGPOINT.py @@ -29,3 +29,11 @@ def test_quadbin_fromgeogpoint_other_srid(): """ ) assert result[0][0] == 5209574053332910079 + + +def test_quadbin_fromgeopoint_no_srid(): + """Computes quadbin for point with no SRID.""" + result = run_query( + 'SELECT @@PG_SCHEMA@@.QUADBIN_FROMGEOPOINT(ST_MAKEPOINT(40.4168, -3.7038), 4)' + ) + assert result[0][0] == 5209574053332910079 diff --git a/clouds/postgres/version b/clouds/postgres/version index f0bb29e76..3a3cd8cc8 100644 --- a/clouds/postgres/version +++ b/clouds/postgres/version @@ -1 +1 @@ -1.3.0 +1.3.1 diff --git a/clouds/redshift/CHANGELOG.md b/clouds/redshift/CHANGELOG.md index 2bb8d7e69..86dd8ef25 100644 --- a/clouds/redshift/CHANGELOG.md +++ b/clouds/redshift/CHANGELOG.md @@ -4,6 +4,10 @@ CARTO Analytics Toolbox Core for Redshift. All notable commits to this project will be documented in this file. +## [1.1.2] - 2024-10-28 + +- chore(h3,quadbin): added "geo" aliases for certain functions (#526) + ## [1.1.1] - 2024-04-18 - docs(processing): update voronoi doc (#492) diff --git a/clouds/redshift/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md b/clouds/redshift/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md index 344f309d1..9bceebc8f 100644 --- a/clouds/redshift/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md +++ b/clouds/redshift/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md @@ -6,7 +6,7 @@ QUADBIN_FROMGEOGPOINT(point, resolution) **Description** -Returns the Quadbin of a given point at a given level of detail. +Returns the Quadbin of a given point at a requested resolution. This function is an alias for `QUADBIN_FROMGEOPOINT`. * `point`: `GEOMETRY` point to get the Quadbin from. * `resolution`: `INT` level of detail or zoom. diff --git a/clouds/redshift/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md b/clouds/redshift/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md index 64988427d..ee210792f 100644 --- a/clouds/redshift/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md +++ b/clouds/redshift/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md @@ -6,7 +6,7 @@ QUADBIN_FROMLONGLAT(longitude, latitude, resolution) **Description** -Returns the Quadbin representation of a point for a given level of detail and geographic coordinates. +Returns the Quadbin representation of a point for a requested resolution and geographic coordinates. * `longitude`: `FLOAT8` longitude (WGS84) of the point. * `latitude`: `FLOAT8` latitude (WGS84) of the point. diff --git a/clouds/redshift/modules/doc/quadbin/QUADBIN_POLYFILL.md b/clouds/redshift/modules/doc/quadbin/QUADBIN_POLYFILL.md index b639558d1..4a003d066 100644 --- a/clouds/redshift/modules/doc/quadbin/QUADBIN_POLYFILL.md +++ b/clouds/redshift/modules/doc/quadbin/QUADBIN_POLYFILL.md @@ -6,7 +6,7 @@ QUADBIN_POLYFILL(geography, resolution) **Description** -Returns an array of Quadbins that intersect with the given geography at a given level of detail. +Returns an array of Quadbins that intersect with the given geography at a requested resolution. * `geography`: `GEOMETRY` geography to extract the Quadbins from. * `resolution`: `INT` level of detail or zoom. diff --git a/clouds/redshift/modules/doc/s2/S2_FROMGEOGPOINT.md b/clouds/redshift/modules/doc/s2/S2_FROMGEOGPOINT.md index a62c6f5fb..b541d8084 100644 --- a/clouds/redshift/modules/doc/s2/S2_FROMGEOGPOINT.md +++ b/clouds/redshift/modules/doc/s2/S2_FROMGEOGPOINT.md @@ -6,7 +6,7 @@ S2_FROMGEOGPOINT(point, resolution) **Description** -Returns the S2 cell ID of a given point at a given level of detail. +Returns the S2 cell ID of a given point at a requested resolution. * `point`: `GEOGRAPHY` vertical coordinate of the map. * `resolution`: `INT4` level of detail or zoom. diff --git a/clouds/redshift/modules/doc/s2/S2_FROMLONGLAT.md b/clouds/redshift/modules/doc/s2/S2_FROMLONGLAT.md index 6141521a0..958e53b53 100644 --- a/clouds/redshift/modules/doc/s2/S2_FROMLONGLAT.md +++ b/clouds/redshift/modules/doc/s2/S2_FROMLONGLAT.md @@ -6,7 +6,7 @@ S2_FROMLONGLAT(longitude, latitude, resolution) **Description** -Returns the S2 cell ID representation for a given level of detail and geographic coordinates. +Returns the S2 cell ID representation for a requested resolution and geographic coordinates. * `longitude`: `FLOAT8` horizontal coordinate of the map. * `latitude`: `FLOAT8` vertical coordinate of the map. diff --git a/clouds/redshift/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql b/clouds/redshift/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql index b936d4b8e..1c208255e 100644 --- a/clouds/redshift/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql +++ b/clouds/redshift/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql @@ -1,6 +1,6 @@ ----------------------------- --- Copyright (C) 2022 CARTO ----------------------------- +-------------------------------- +-- Copyright (C) 2022-2024 CARTO +-------------------------------- CREATE OR REPLACE FUNCTION @@RS_SCHEMA@@.QUADBIN_FROMGEOGPOINT (GEOMETRY, INT) @@ -13,3 +13,12 @@ AS $$ ELSE @@RS_SCHEMA@@.QUADBIN_FROMLONGLAT(ST_X(ST_TRANSFORM($1, 4326)), ST_Y(ST_TRANSFORM($1, 4326)), $2) END $$ LANGUAGE sql; + +CREATE OR REPLACE FUNCTION @@RS_SCHEMA@@.QUADBIN_FROMGEOPOINT +(GEOMETRY, INT) +-- (point, resolution) +RETURNS BIGINT +STABLE +AS $$ + SELECT @@RS_SCHEMA@@.QUADBIN_FROMGEOGPOINT($1, $2) +$$ LANGUAGE sql; diff --git a/clouds/redshift/modules/test/quadbin/test_QUADBIN_FROMGEOGPOINT.py b/clouds/redshift/modules/test/quadbin/test_QUADBIN_FROMGEOGPOINT.py index 0c16b71f2..eccd396a7 100644 --- a/clouds/redshift/modules/test/quadbin/test_QUADBIN_FROMGEOGPOINT.py +++ b/clouds/redshift/modules/test/quadbin/test_QUADBIN_FROMGEOGPOINT.py @@ -8,3 +8,12 @@ def test_quadbin_fromgeogpoint(): assert len(result[0]) == 1 assert result[0][0] == 5209574053332910079 + + +def test_quadbin_fromgeopoint(): + result = run_query( + 'SELECT @@RS_SCHEMA@@.QUADBIN_FROMGEOPOINT(ST_POINT(40.4168, -3.7038),4)' + ) + + assert len(result[0]) == 1 + assert result[0][0] == 5209574053332910079 \ No newline at end of file diff --git a/clouds/redshift/version b/clouds/redshift/version index 524cb5524..45a1b3f44 100644 --- a/clouds/redshift/version +++ b/clouds/redshift/version @@ -1 +1 @@ -1.1.1 +1.1.2 diff --git a/clouds/snowflake/CHANGELOG.md b/clouds/snowflake/CHANGELOG.md index cd3735e94..f0e703b58 100644 --- a/clouds/snowflake/CHANGELOG.md +++ b/clouds/snowflake/CHANGELOG.md @@ -4,6 +4,10 @@ CARTO Analytics Toolbox Core for Snowflake. All notable commits to this project will be documented in this file. +## [1.2.6] - 2024-10-28 + +- chore(h3,quadbin): added "geo" aliases for certain functions (#526) + ## [1.2.5] - 2024-09-23 - feat: added warehouse option for SF (#524) diff --git a/clouds/snowflake/modules/doc/h3/H3_FROMGEOGPOINT.md b/clouds/snowflake/modules/doc/h3/H3_FROMGEOGPOINT.md index 73ac27d77..c4cf090db 100644 --- a/clouds/snowflake/modules/doc/h3/H3_FROMGEOGPOINT.md +++ b/clouds/snowflake/modules/doc/h3/H3_FROMGEOGPOINT.md @@ -6,7 +6,7 @@ H3_FROMGEOGPOINT(point, resolution) **Description** -Returns the H3 cell index that the point belongs to in the required `resolution`. It will return `null` on error (invalid geography type or resolution out of bounds). +Returns the H3 cell index that the point belongs to in the requested `resolution`. It will return `null` on error (invalid geography type or resolution out of bounds). This function is an alias for `H3_FROMGEOPOINT`. * `point`: `GEOGRAPHY` point to get the H3 cell from. * `resolution`: `INT` number between 0 and 15 with the [H3 resolution](https://h3geo.org/docs/core-library/restable). diff --git a/clouds/snowflake/modules/doc/h3/H3_POLYFILL_TABLE.md b/clouds/snowflake/modules/doc/h3/H3_POLYFILL_TABLE.md index 4378802bf..60009de19 100644 --- a/clouds/snowflake/modules/doc/h3/H3_POLYFILL_TABLE.md +++ b/clouds/snowflake/modules/doc/h3/H3_POLYFILL_TABLE.md @@ -6,7 +6,7 @@ H3_POLYFILL_TABLE(input_query, resolution, mode, output_table) **Description** -Returns a table with the H3 cell indexes contained in the given geography at a given level of detail. Containment is determined by the mode: center, intersects, contains. All the attributes except the geography will be included in the output table, clustered by the h3 column. +Returns a table with the H3 cell indexes contained in the given geography at a requested resolution. Containment is determined by the mode: center, intersects, contains. All the attributes except the geography will be included in the output table, clustered by the h3 column. * `input_query`: `STRING` input data to polyfill. It must contain a column `geom` with the shape to cover. Additionally, other columns can be included. * `resolution`: `INT` level of detail. The value must be between 0 and 15 ([H3 resolution table](https://h3geo.org/docs/core-library/restable)). diff --git a/clouds/snowflake/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md b/clouds/snowflake/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md index 55add4864..ef1c01cc2 100644 --- a/clouds/snowflake/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md +++ b/clouds/snowflake/modules/doc/quadbin/QUADBIN_FROMGEOGPOINT.md @@ -6,7 +6,7 @@ QUADBIN_FROMGEOGPOINT(point, resolution) **Description** -Returns the Quadbin of a given point at a given level of detail. +Returns the Quadbin of a given point at a requested resolution. This function is an alias for `QUADBIN_FROMGEOPOINT`. * `point`: `GEOGRAPHY` point to get the Quadbin from. * `resolution`: `INT` level of detail or zoom. diff --git a/clouds/snowflake/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md b/clouds/snowflake/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md index d6e28cf3c..b57334cb3 100644 --- a/clouds/snowflake/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md +++ b/clouds/snowflake/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md @@ -6,7 +6,7 @@ QUADBIN_FROMLONGLAT(longitude, latitude, resolution) **Description** -Returns the Quadbin representation of a point for a given level of detail and geographic coordinates. +Returns the Quadbin representation of a point for a requested resolution and geographic coordinates. * `longitude`: `FLOAT64` longitude (WGS84) of the point. * `latitude`: `FLOAT64` latitude (WGS84) of the point. diff --git a/clouds/snowflake/modules/doc/quadbin/QUADBIN_POLYFILL.md b/clouds/snowflake/modules/doc/quadbin/QUADBIN_POLYFILL.md index 18f57a0e9..f8e54f0aa 100644 --- a/clouds/snowflake/modules/doc/quadbin/QUADBIN_POLYFILL.md +++ b/clouds/snowflake/modules/doc/quadbin/QUADBIN_POLYFILL.md @@ -6,7 +6,7 @@ QUADBIN_POLYFILL(geography, resolution) **Description** -Returns an array of Quadbins that intersect with the given geography at a given level of detail. +Returns an array of Quadbins that intersect with the given geography at a requested resolution. * `geography`: `GEOGRAPHY` geography to extract the Quadbins from. * `resolution`: `INT` level of detail or zoom. diff --git a/clouds/snowflake/modules/doc/s2/S2_FROMGEOGPOINT.md b/clouds/snowflake/modules/doc/s2/S2_FROMGEOGPOINT.md index aeb25feae..16d3bf577 100644 --- a/clouds/snowflake/modules/doc/s2/S2_FROMGEOGPOINT.md +++ b/clouds/snowflake/modules/doc/s2/S2_FROMGEOGPOINT.md @@ -6,7 +6,7 @@ S2_FROMGEOGPOINT(point, resolution) **Description** -Returns the S2 cell ID of a given point at a given level of detail. +Returns the S2 cell ID of a given point at a requested resolution. * `point`: `GEOGRAPHY` point to get the ID from. * `resolution`: `INT` level of detail or zoom. diff --git a/clouds/snowflake/modules/sql/h3/H3_FROMGEOGPOINT.sql b/clouds/snowflake/modules/sql/h3/H3_FROMGEOGPOINT.sql index 069551dd8..49a2bb512 100644 --- a/clouds/snowflake/modules/sql/h3/H3_FROMGEOGPOINT.sql +++ b/clouds/snowflake/modules/sql/h3/H3_FROMGEOGPOINT.sql @@ -11,3 +11,11 @@ AS $$ H3_POINT_TO_CELL_STRING(GEOG, RESOLUTION), NULL) $$; + +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.H3_FROMGEOPOINT +(geo GEOGRAPHY, resolution INT) +RETURNS STRING +IMMUTABLE +AS $$ + @@SF_SCHEMA@@.H3_FROMGEOGPOINT(geo, resolution) +$$; diff --git a/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql b/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql index b130ee2a6..4b6efa3c3 100644 --- a/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql +++ b/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql @@ -1,6 +1,6 @@ ----------------------------- --- Copyright (C) 2022 CARTO ----------------------------- +-------------------------------- +-- Copyright (C) 2022-2024 CARTO +-------------------------------- CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.QUADBIN_FROMGEOGPOINT (point GEOGRAPHY, resolution INT) @@ -17,3 +17,11 @@ IMMUTABLE AS $$ @@SF_SCHEMA@@._QUADBIN_FROMLONGLAT(ST_X(point), ST_Y(point), resolution) $$; + +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.QUADBIN_FROMGEOPOINT +(point GEOGRAPHY, resolution INT) +RETURNS BIGINT +IMMUTABLE +AS $$ + @@SF_SCHEMA@@._QUADBIN_FROMGEOGPOINT(point, resolution) +$$; diff --git a/clouds/snowflake/modules/test/h3/H3_FROMGEOGPOINT.spec.js b/clouds/snowflake/modules/test/h3/H3_FROMGEOGPOINT.test.js similarity index 62% rename from clouds/snowflake/modules/test/h3/H3_FROMGEOGPOINT.spec.js rename to clouds/snowflake/modules/test/h3/H3_FROMGEOGPOINT.test.js index 1864f6f9a..a7f87c809 100644 --- a/clouds/snowflake/modules/test/h3/H3_FROMGEOGPOINT.spec.js +++ b/clouds/snowflake/modules/test/h3/H3_FROMGEOGPOINT.test.js @@ -53,4 +53,37 @@ test('H3_FROMGEOGPOINT returns NULL with non POINT geographies', async () => { null, null ]); +}); + +test('H3_FROMGEOPOINT returns the proper INT64', async () => { + const query = ` + WITH inputs AS + ( + SELECT 1 AS id, ST_POINT(-122.0553238, 37.3615593) as geom, 5 as resolution UNION ALL + SELECT 2 AS id, ST_POINT(-164.991559, 30.943387) as geom, 5 as resolution UNION ALL + SELECT 3 AS id, ST_POINT(71.52790329909925, 46.04189431883772) as geom, 15 as resolution UNION ALL + + -- null inputs + SELECT 4 AS id, TRY_TO_GEOGRAPHY(NULL) AS geom, 5 as resolution UNION ALL + SELECT 5 AS id, ST_POINT(-122.0553238, 37.3615593) as geom, -1 as resolution UNION ALL + SELECT 6 AS id, ST_POINT(-122.0553238, 37.3615593) as geom, 20 as resolution UNION ALL + SELECT 7 AS id, ST_POINT(-122.0553238, 37.3615593) as geom, NULL as resolution + ) + SELECT + CAST(H3_FROMGEOPOINT(geom, resolution) AS STRING) as h3_id + FROM inputs + ORDER BY id ASC + `; + + const rows = await runQuery(query); + expect(rows.length).toEqual(7); + expect(rows.map((r) => r.H3_ID)).toEqual([ + '85283473fffffff', + '8547732ffffffff', + '8f2000000000000', + null, + null, + null, + null + ]); }); \ No newline at end of file diff --git a/clouds/snowflake/modules/test/h3/H3_FROMLONGLAT.spec.js b/clouds/snowflake/modules/test/h3/H3_FROMLONGLAT.test.js similarity index 100% rename from clouds/snowflake/modules/test/h3/H3_FROMLONGLAT.spec.js rename to clouds/snowflake/modules/test/h3/H3_FROMLONGLAT.test.js diff --git a/clouds/snowflake/modules/test/quadbin/QUADBIN_FROMGEOGPOINT.test.js b/clouds/snowflake/modules/test/quadbin/QUADBIN_FROMGEOGPOINT.test.js index dc65b4adb..b90e2efd2 100644 --- a/clouds/snowflake/modules/test/quadbin/QUADBIN_FROMGEOGPOINT.test.js +++ b/clouds/snowflake/modules/test/quadbin/QUADBIN_FROMGEOGPOINT.test.js @@ -5,4 +5,11 @@ test('QUADBIN_FROMGEOGPOINT should work', async () => { const rows = await runQuery(query); expect(rows.length).toEqual(1); expect(rows[0].OUTPUT).toEqual('5209574053332910079'); +}); + +test('QUADBIN_FROMGEOPOINT should work', async () => { + const query = 'SELECT CAST(QUADBIN_FROMGEOPOINT(ST_POINT(40.4168, -3.7038), 4) AS STRING) AS OUTPUT'; + const rows = await runQuery(query); + expect(rows.length).toEqual(1); + expect(rows[0].OUTPUT).toEqual('5209574053332910079'); }); \ No newline at end of file diff --git a/clouds/snowflake/version b/clouds/snowflake/version index c813fe116..3c43790f5 100644 --- a/clouds/snowflake/version +++ b/clouds/snowflake/version @@ -1 +1 @@ -1.2.5 +1.2.6