Skip to content

Commit

Permalink
release: 2024-10-28 (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
vdelacruzb authored Oct 29, 2024
1 parent 109a961 commit 1ddd3ed
Show file tree
Hide file tree
Showing 51 changed files with 262 additions and 49 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions clouds/bigquery/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion clouds/bigquery/common/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion clouds/bigquery/modules/doc/h3/H3_FROMGEOGPOINT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion clouds/bigquery/modules/doc/h3/H3_POLYFILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
Expand Down
2 changes: 1 addition & 1 deletion clouds/bigquery/modules/doc/h3/H3_POLYFILL_MODE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
Expand Down
2 changes: 1 addition & 1 deletion clouds/bigquery/modules/doc/h3/H3_POLYFILL_TABLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion clouds/bigquery/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion clouds/bigquery/modules/doc/quadbin/QUADBIN_POLYFILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion clouds/bigquery/modules/doc/s2/S2_FROMGEOGPOINT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 12 additions & 3 deletions clouds/bigquery/modules/sql/h3/H3_FROMGEOGPOINT.sql
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
)
);
15 changes: 12 additions & 3 deletions clouds/bigquery/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
)
);
31 changes: 31 additions & 0 deletions clouds/bigquery/modules/test/h3/H3_FROMGEOGPOINT.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
]);
});
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
2 changes: 1 addition & 1 deletion clouds/bigquery/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.3
1.2.4
4 changes: 4 additions & 0 deletions clouds/postgres/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion clouds/postgres/modules/doc/h3/H3_FROMGEOGPOINT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion clouds/postgres/modules/doc/h3/H3_POLYFILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion clouds/postgres/modules/doc/quadbin/QUADBIN_FROMLONGLAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion clouds/postgres/modules/doc/quadbin/QUADBIN_POLYFILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 14 additions & 3 deletions clouds/postgres/modules/sql/h3/H3_FROMGEOGPOINT.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
----------------------------
-- Copyright (C) 2023 CARTO
----------------------------
--------------------------------
-- Copyright (C) 2023-2024 CARTO
--------------------------------

CREATE OR REPLACE FUNCTION @@PG_SCHEMA@@.H3_FROMGEOGPOINT(
geog GEOMETRY,
Expand All @@ -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;
17 changes: 14 additions & 3 deletions clouds/postgres/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
----------------------------
-- Copyright (C) 2022 CARTO
----------------------------
--------------------------------
-- Copyright (C) 2022-2024 CARTO
--------------------------------

CREATE OR REPLACE FUNCTION @@PG_SCHEMA@@.QUADBIN_FROMGEOGPOINT(
point GEOMETRY,
Expand All @@ -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;
31 changes: 31 additions & 0 deletions clouds/postgres/modules/test/h3/test_H3_FROMGEOGPOINT.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion clouds/postgres/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
1.3.1
4 changes: 4 additions & 0 deletions clouds/redshift/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 1ddd3ed

Please sign in to comment.