Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sf): deploy snowflake in CARTO.CARTO when releasing #535

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/snowflake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,39 @@ jobs:
cd clouds/snowflake
make deploy diff="$GIT_DIFF" production=1

deploy-internal-stable:
if: github.ref_name == 'stable'
needs: test
runs-on: ubuntu-20.04
timeout-minutes: 20
strategy:
matrix:
include:
- account: SF_ACCOUNT_CD
database: SF_DATABASE_STABLE_CD
user: SF_USER_CD
password: SF_PASSWORD_CD
role: SF_ROLE_CD
env:
SF_ACCOUNT: ${{ secrets[matrix.account] }}
SF_DATABASE: ${{ secrets[matrix.database] }}
SF_USER: ${{ secrets[matrix.user] }}
SF_PASSWORD: ${{ secrets[matrix.password] }}
SF_ROLE: ${{ secrets[matrix.role] }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Check diff
uses: technote-space/get-diff-action@v4
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Run deploy
run: |
cd clouds/snowflake
make deploy diff="$GIT_DIFF" production=1

deploy-internal-app:
if: github.ref_name == 'main'
needs: test
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ 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)
- chore(bq): increse jest timeout to 30000 (#525)
- docs(sf): add docs on how to update the analytics toolbox from a native app (#527)
- chore(sf): update python version on stored procedures from 3.8 to 3.9 (#528)

## 2024-08-22

- chore(rs): bump scipy from 0.12.0 to 0.12.1 in /clouds/redshift/libraries/python (#518)
- docs(sf): fix native apps installation doc (#519)
- fix(pg): lock numpy to v1.24.4 until pandas supports 2.X.X (#520)

## 2024-06-27

- chore(sf): refactor at snowflake native app to an installer (#512)
- chore(bq|quadbin): optimize polyfill (#513)

## 2024-05-21

- refactor(sf|h3): avoid memory limit exceeded in H3_POLYFILL_TABLE (#501)
Expand Down
9 changes: 9 additions & 0 deletions clouds/bigquery/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ 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)

## [1.2.2] - 2024-04-18

- docs(processing): update voronoi doc (#492)
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/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ test: check $(NODE_MODULES_DEV)
if [ ! -z "$$TESTS" ]; then \
GOOGLE_APPLICATION_CREDENTIALS=$(GOOGLE_APPLICATION_CREDENTIALS) \
PATH="$(NODE_MODULES_DEV)/.bin/:$(PATH)" \
jest --testTimeout=250000 $(BAIL) --verbose --slowTestThreshold=20 --maxConcurrency=10 $$TESTS \
jest --testTimeout=300000 $(BAIL) --verbose --slowTestThreshold=20 --maxConcurrency=10 $$TESTS \
--setupFilesAfterEnv "$(COMMON_DIR)/test-extend.js" || exit 1; \
OLD_TEST=$(TEST_DIR)/$$m/old-test; \
if [ -d $$OLD_TEST ]; then \
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
)
);
4 changes: 2 additions & 2 deletions clouds/bigquery/modules/sql/quadbin/QUADBIN_POLYFILL.sql
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ RETURNS INT64
AS ((
WITH __geog_area AS (
SELECT
508164597540055.75 AS q0_area,
ST_AREA(geog) AS geog_area,
COS(ST_Y(ST_CENTROID(geog)) * ACOS(-1) / 180) AS cos_geog_lat,
508164597540055.75 AS q0_area
COS(ST_Y(ST_CENTROID(geog)) * ACOS(-1) / 180) AS cos_geog_lat
)
-- compute the resolution of cells that match the geog area
SELECT IF(geog_area > 0 AND cos_geog_lat > 0,
Expand Down
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.2
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/common/python3_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ pandas==1.3.2
SQLAlchemy==1.4.23
mapbox-vector-tile==1.2.1
sqlfluff==1.3.1

numpy==1.24.4
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;
Loading
Loading