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

release: 2024-03-18 #487

Merged
merged 34 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9ffb54d
fix(rs,pg) run_script exit code on error (#450)
jgoizueta Oct 26, 2023
3d159b1
fix(bq) SETUP dependencies (#451)
jgoizueta Oct 27, 2023
3228eff
chore: add contrib notes about naming functions (#452)
jgoizueta Oct 27, 2023
a754b36
update dependency: bigquery to 7.3.0 (#453)
alberhander Nov 2, 2023
55e7b21
chore(bq): update bigquery timeouts
Jesus89 Nov 13, 2023
e5160fd
feat(sf): deploy analytics toolbox native app (#454)
vdelacruzb Dec 19, 2023
e95e430
chore(bq): increase tests timeout to 200000 (#455)
vdelacruzb Dec 20, 2023
e5ab01b
feat(bq,sf,rs,pg|quadbin): add function QUADBIN_DISTANCE (#457)
vdelacruzb Dec 28, 2023
4e7fcd5
fix(bq|h3): fix broken reference in H3_POLYFILL_TABLE (#458)
vdelacruzb Dec 28, 2023
745a99e
fix(bq|h3): fix broken reference in H3_POLYFILL_TABLE (#460)
vdelacruzb Dec 28, 2023
f16452b
chore(bq,sf,rs,pg): fix naming dedicated deployments for releases (#462)
vdelacruzb Dec 29, 2023
178cf92
fix(sf|quadbin): QUADBIN_FROMLONGLAT not clamping latitudes and retur…
vdelacruzb Dec 29, 2023
7b9961f
fix(rs|constructors,transformations): adjust SRID and use native ST_G…
vdelacruzb Dec 29, 2023
be4b5f1
chore(pg): fix typo naming dedicated deployments for releases (#464)
vdelacruzb Dec 29, 2023
6489119
chore(bq,sf,rs,pg): make remove drop functions instead of whole schem…
vdelacruzb Jan 11, 2024
b0a6e08
fix(bq,sf,rs,pg|quadbin): improve precision of long lat conversion ne…
jgoizueta Jan 11, 2024
f65e425
feat(bq|transformations): Point on surface functionality for BQ (#469)
vehrka Jan 12, 2024
793c888
feat(sf|transformations): Point on surface functionality for SF (#470)
vehrka Jan 12, 2024
4532b13
Merge release into main branch (#472)
github-actions[bot] Jan 19, 2024
68e904c
chore(sf): add additional tables to native apps (#473)
vdelacruzb Jan 23, 2024
3f399b0
docs(bs,sf,rs|transformations): fix ST_DESTINATION bearing parameter …
vdelacruzb Jan 25, 2024
d31d3ed
fix(sf|quadbin): QUADBIN_TOPARENT not working with views (#476)
vdelacruzb Feb 1, 2024
178dee6
docs(bq,sf,rs|constructors): fix angle parameter description in ST_MA…
vdelacruzb Feb 12, 2024
5fde517
fix(sf|random): ST_GENERATEPOINTS was not accepting column names (#480)
vdelacruzb Feb 13, 2024
a9c2118
Merge release into main branch (#482)
github-actions[bot] Feb 16, 2024
1ceefd5
fix(sf): CI and CD not working because of snowflake driver breaking c…
vdelacruzb Mar 4, 2024
59b52b6
fix(bq,sf,rs,pg): drop schemas when dedicateds gets released (#485)
vdelacruzb Mar 6, 2024
e521cb2
fix(bq|random): ST_GENERATEPOINTS returning exact name of points (#486)
vdelacruzb Mar 14, 2024
d34976f
chore(rs,pg): remove installer tool (#483)
vdelacruzb Mar 18, 2024
645a0a0
chore(deps): bump jinja2 from 3.1.2 to 3.1.3 in /clouds/databricks/co…
dependabot[bot] Mar 18, 2024
943aa39
update changelog
vdelacruzb Mar 18, 2024
96440a2
fix conflicts
vdelacruzb Mar 18, 2024
b0ca446
update concavehull doc
vdelacruzb Mar 18, 2024
d0c29ed
increase bq tests timeout
vdelacruzb Mar 18, 2024
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
15 changes: 14 additions & 1 deletion .github/workflows/redshift-ded.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ jobs:
uses: actions/checkout@v2
- name: Check diff
uses: technote-space/get-diff-action@v4
- name: Set RS_PREFIX for releases
if: startsWith(github.event.pull_request.head.ref, 'release/')
run: |
echo "RS_PREFIX=dedicated_release_${{ github.event.pull_request.number }}_" >> $GITHUB_ENV
- name: Set RS_PREFIX for hotfixes
if: startsWith(github.event.pull_request.head.ref, 'hotfix/')
run: |
echo "RS_PREFIX=dedicated_hotfix_${{ github.event.pull_request.number }}_" >> $GITHUB_ENV
- name: Set RS_PREFIX for the rest
if: |
!(startsWith(github.event.pull_request.head.ref, 'hotfix/')) &&
!(startsWith(github.event.pull_request.head.ref, 'release/'))
run: echo "RS_PREFIX=dedicated_${{ github.event.pull_request.number }}_" >> $GITHUB_ENV
- name: Setup node
uses: actions/setup-node@v1
with:
Expand Down Expand Up @@ -63,7 +76,7 @@ jobs:
if: github.event.action == 'synchronize' || github.event.action == 'labeled'
run: |
cd clouds/redshift
make deploy
make deploy dropfirst=1
- name: Run remove
id: remove
if: github.event.action == 'unlabeled' || github.event.action == 'closed'
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ CARTO Analytics Toolbox Core.

All notable commits to this project will be documented in this file.

## 2024-03-18

- fix(sf): CI and CD not working because of snowflake driver breaking changes (#484)
- fix(bq,sf,rs,pg): drop schemas when dedicateds gets released (#485)
- fix(bq|random): ST_GENERATEPOINTS returning exact name of points (#486)
- chore(rs,pg): remove installer tool (#483)
- chore(deps): bump jinja2 from 3.1.2 to 3.1.3 in /clouds/databricks/common (#468)

## 2024-02-15

- chore(sf): add additional tables to native apps (#473)
Expand Down
4 changes: 4 additions & 0 deletions clouds/bigquery/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ CARTO Analytics Toolbox Core for BigQuery.

All notable commits to this project will be documented in this file.

## [1.2.1] - 2024-03-18

- fix(random): ST_GENERATEPOINTS returning exact name of points (#486)

## [1.2.0] - 2024-01-17

- chore: increase tests timeout to 200000 (#455)
Expand Down
23 changes: 21 additions & 2 deletions clouds/bigquery/libraries/javascript/src/random.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
import { bbox } from '@turf/turf';
import { bbox, booleanPointInPolygon, randomPoint } from '@turf/turf';

function generateRandomPointsInPolygon (polygon, numPoints) {
const randomPoints = [];
while (randomPoints.length < numPoints) {
const point = randomPoint(1, { bbox: bbox(polygon) }).features[0];
if (booleanPointInPolygon(point, polygon)) {
randomPoints.push(JSON.stringify(point.geometry));
}
}
return randomPoints;
}

function generateRandomPointInPolygon (polygon) {
let point
do {
point = randomPoint(1, { bbox: bbox(polygon) }).features[0];
} while (!booleanPointInPolygon(point, polygon))
return JSON.stringify(point.geometry);
}

export default {
bbox
generateRandomPointsInPolygon
};
2 changes: 1 addition & 1 deletion clouds/bigquery/libraries/javascript/test/random.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const lib = require('../build/index');

test('random library defined', () => {
expect(lib.random.bbox).toBeDefined();
expect(lib.random.generateRandomPointsInPolygon).toBeDefined();
});
12 changes: 9 additions & 3 deletions clouds/bigquery/modules/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ include $(COMMON_DIR)/Makefile

.SILENT:

.PHONY: help lint build build-share deploy deploy-share test remove remove-share clean
.PHONY: help lint build build-share deploy deploy-share test remove remove-functions remove-share clean

help:
echo "Available targets: lint build deploy test remove clean"
echo "Available targets: lint build deploy test remove remove-functions clean"

lint: venv3 $(NODE_MODULES_DEV)
echo "Linting modules..."
Expand Down 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=200000 $(BAIL) --verbose --slowTestThreshold=20 --maxConcurrency=10 $$TESTS \
jest --testTimeout=250000 $(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 All @@ -101,6 +101,12 @@ remove: check
GOOGLE_APPLICATION_CREDENTIALS=$(GOOGLE_APPLICATION_CREDENTIALS) \
$(COMMON_DIR)/run-script.js $(COMMON_DIR)/DROP_FUNCTIONS.sql

remove-functions: check
echo "Removing functions..."
REPLACEMENTS=$(REPLACEMENTS)" "$(REPLACEMENTS_EXTRA) \
GOOGLE_APPLICATION_CREDENTIALS=$(GOOGLE_APPLICATION_CREDENTIALS) \
$(COMMON_DIR)/run-script.js $(COMMON_DIR)/DROP_FUNCTIONS.sql

clean:
echo "Cleaning modules..."
rm -rf $(BUILD_DIR) $(NODE_MODULES_DEV)
7 changes: 0 additions & 7 deletions clouds/bigquery/modules/doc/random/ST_GENERATEPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ Generates randomly placed points inside a polygon and returns them in an array o

The distribution of the generated points is spherically uniform (i.e. if the coordinates are interpreted as longitude and latitude on a sphere); this means that WGS84 coordinates will be only approximately uniformly distributed, since WGS84 is based on an ellipsoidal model.

````hint:warning
**warning**

It never generates more than the requested number of points, but there is a small chance of generating less points.

````

* `geog`: `GEOGRAPHY` a polygon; the random points generated will be inside this polygon.
* `npoints`: `INT64` number of points to generate.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ST_CONCAVEHULL(geog, maxEdge, units)
Takes a set of points and returns a concave hull Polygon or MultiPolygon. In case that a single or a couple of points are passed as input, the function will return that point or a segment respectively.

* `geog`: `ARRAY<GEOGRAPHY>` input points.
* `maxEdge`: `FLOAT64`|`NULL` the length (in 'units') of an edge necessary for part of the hull to become concave. If `NULL`the default value `infinity` is used.
* `maxEdge`: `FLOAT64`|`NULL` the maximum length allowed for an edge of the concave hull. Higher `maxEdge` values will produce more convex-like hulls. If `NULL`, the default value `infinity` is used and it would be equivalent to a Convex Hull.
* `units`: `STRING`|`NULL` units of length, the supported options are: miles, kilometers, degrees or radians. If `NULL`the default value `kilometers` is used.

**Return type**
Expand Down
81 changes: 15 additions & 66 deletions clouds/bigquery/modules/sql/random/ST_GENERATEPOINTS.sql
Original file line number Diff line number Diff line change
@@ -1,74 +1,23 @@
----------------------------
-- Copyright (C) 2021 CARTO
----------------------------
--------------------------------
-- Copyright (C) 2021-2024 CARTO
--------------------------------

CREATE OR REPLACE FUNCTION `@@BQ_DATASET@@.__ST_GENERATEPOINTS`
(geojson STRING, npoints INT64)
RETURNS ARRAY<STRING>
DETERMINISTIC
LANGUAGE js
OPTIONS (library = ["@@BQ_LIBRARY_BUCKET@@"])
AS """
return lib.random.generateRandomPointsInPolygon(JSON.parse(geojson), npoints);
""";

CREATE OR REPLACE FUNCTION `@@BQ_DATASET@@.ST_GENERATEPOINTS`
(geog GEOGRAPHY, npoints INT64)
RETURNS ARRAY<GEOGRAPHY>
AS (
(
WITH bbox AS (
-- compute the bounding box of the polygon
SELECT `@@BQ_DATASET@@.__BBOX_FROM_GEOJSON`(ST_ASGEOJSON(geog)) AS box
),

bbox_coords AS (
-- break down the bbox array into minx, miny, maxx, maxy
SELECT
box[ORDINAL(1)] AS minx,
box[ORDINAL(2)] AS miny,
box[ORDINAL(3)] AS maxx,
box[ORDINAL(4)] AS maxy
FROM bbox
),

bbox_data AS (
-- compute area of bbox and put some handy values here too
SELECT
minx,
miny,
maxx,
maxy,
1.2 AS k, -- security factor to make it more likely that at least npoints fall within the polygon
ST_AREA(
ST_MAKEPOLYGON(ST_MAKELINE([
ST_GEOGPOINT(minx, miny),
ST_GEOGPOINT(minx, maxy),
ST_GEOGPOINT(maxx, maxy),
ST_GEOGPOINT(maxx, miny),
ST_GEOGPOINT(minx, miny)
]))
) AS bbox_area
FROM bbox_coords
),

point_seeds AS (
-- generate enough values so that we will hopefully have at least npoints of them randomly placed inside geog
SELECT
GENERATE_ARRAY(1, CEIL(k * npoints * bbox_area / ST_AREA(geog))) AS i,
SIN(miny * ACOS(-1) / 180.0) AS minsin,
SIN(maxy * ACOS(-1) / 180.0) AS maxsin,
180.0 / ACOS(-1) AS radtodeg
FROM bbox_data
),

bbox_points AS (
-- compute the random points uniformly in the bbox;
SELECT ST_GEOGPOINT(minx + RAND() * (maxx - minx), radtodeg * ASIN(minsin + RAND() * (maxsin - minsin))) AS point
FROM bbox_coords, point_seeds, UNNEST(i)
),

poly_points AS (
-- now we need to select the points inside the polygon and number them, so we can limit
-- the end result to npoints (note that we can't have a dynamic LIMIT)
SELECT
point,
ROW_NUMBER() OVER () AS rn
FROM bbox_points
WHERE ST_WITHIN(point, geog)
)

-- finally select at most npoints and return them in an array
SELECT ARRAY(SELECT point FROM poly_points WHERE rn <= npoints)
SELECT ARRAY_AGG(ST_GEOGFROMGEOJSON(point))
FROM UNNEST(`@@BQ_DATASET@@.__ST_GENERATEPOINTS`(ST_ASGEOJSON(geog), npoints)) AS point
)
);
13 changes: 0 additions & 13 deletions clouds/bigquery/modules/sql/random/__BBOX_FROM_GEOJSON.sql

This file was deleted.

2 changes: 1 addition & 1 deletion clouds/bigquery/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.0
1.2.1
2 changes: 1 addition & 1 deletion clouds/databricks/common/requirements_create_it.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Jinja2==3.1.2
Jinja2==3.1.3
9 changes: 7 additions & 2 deletions clouds/postgres/modules/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ include $(COMMON_DIR)/Makefile

.SILENT:

.PHONY: help lint build deploy test remove clean
.PHONY: help lint build deploy test remove remove-functions clean

help:
echo "Available targets: lint build deploy test remove clean"
echo "Available targets: lint build deploy test remove remove-functions clean"

lint: venv3 $(NODE_MODULES_DEV)
echo "Linting modules..."
Expand Down Expand Up @@ -64,6 +64,11 @@ remove: venv3
REPLACEMENTS=$(REPLACEMENTS)" "$(REPLACEMENTS_EXTRA) \
$(VENV3_BIN)/python $(COMMON_DIR)/run_script.py $(COMMON_DIR)/DROP_FUNCTIONS.sql

remove-functions: venv3
echo "Removing functions..."
REPLACEMENTS=$(REPLACEMENTS)" "$(REPLACEMENTS_EXTRA) \
$(VENV3_BIN)/python $(COMMON_DIR)/run_script.py $(COMMON_DIR)/DROP_FUNCTIONS.sql

clean:
echo "Cleaning modules..."
rm -rf $(BUILD_DIR) $(VENV3_DIR) $(NODE_MODULES_DEV)
9 changes: 7 additions & 2 deletions clouds/redshift/modules/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ include $(COMMON_DIR)/Makefile

.SILENT:

.PHONY: help lint build deploy test remove clean
.PHONY: help lint build deploy test remove remove-functions clean

help:
echo "Available targets: lint build deploy test remove clean"
echo "Available targets: lint build deploy test remove remove-functions clean"

lint: venv3 $(NODE_MODULES_DEV)
echo "Linting modules..."
Expand Down Expand Up @@ -64,6 +64,11 @@ remove: venv3
REPLACEMENTS=$(REPLACEMENTS)" "$(REPLACEMENTS_EXTRA) \
$(VENV3_BIN)/python $(COMMON_DIR)/run_script.py $(COMMON_DIR)/DROP_FUNCTIONS.sql

remove-functions: venv3
echo "Removing functions..."
REPLACEMENTS=$(REPLACEMENTS)" "$(REPLACEMENTS_EXTRA) \
$(VENV3_BIN)/python $(COMMON_DIR)/run_script.py $(COMMON_DIR)/DROP_FUNCTIONS.sql

clean:
echo "Cleaning modules..."
rm -rf $(BUILD_DIR) $(VENV3_DIR) $(NODE_MODULES_DEV)
7 changes: 0 additions & 7 deletions clouds/redshift/modules/doc/random/ST_GENERATEPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ Generates randomly placed points inside a polygon and returns them in an array o

The distribution of the generated points is spherically uniform (i.e. if the coordinates are interpreted as longitude and latitude on a sphere); this means that WGS84 coordinates will be only approximately uniformly distributed, since WGS84 is based on an ellipsoidal model.

````hint:warning
**warning**

It never generates more than the requested number of points, but there is a small chance of generating less points.

````

* `geog`: `GEOMETRY` a polygon; the random points generated will be inside this polygon.
* `npoints`: `INT` number of points to generate.

Expand Down
2 changes: 1 addition & 1 deletion clouds/snowflake/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"rollup": "^2.47.0",
"rollup-plugin-bundle-size": "^1.0.3",
"rollup-plugin-terser": "^7.0.2",
"snowflake-sdk": "^1.6.6"
"snowflake-sdk": "1.9.3"
}
}
9 changes: 7 additions & 2 deletions clouds/snowflake/modules/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ include $(COMMON_DIR)/Makefile

.SILENT:

.PHONY: help lint build build-share build-native-app-setup-script deploy deploy-share test remove remove-share clean
.PHONY: help lint build build-share build-native-app-setup-script deploy deploy-share test remove remove-functions remove-share clean

help:
echo "Available targets: lint build deploy test remove clean"
echo "Available targets: lint build deploy test remove remove-functions clean"

lint: $(NODE_MODULES_DEV) venv3
echo "Linting modules..."
Expand Down Expand Up @@ -110,6 +110,11 @@ remove: $(NODE_MODULES_DEV)
REPLACEMENTS=$(REPLACEMENTS)" "$(REPLACEMENTS_EXTRA) \
$(COMMON_DIR)/run-script.js $(COMMON_DIR)/DROP_FUNCTIONS.sql

remove-functions: $(NODE_MODULES_DEV)
echo "Removing functions..."
REPLACEMENTS=$(REPLACEMENTS)" "$(REPLACEMENTS_EXTRA) \
$(COMMON_DIR)/run-script.js $(COMMON_DIR)/DROP_FUNCTIONS.sql

remove-share: $(NODE_MODULES_DEV)
echo "Removing share..."
$(COMMON_DIR)/run-query.js "DROP SHARE $(SF_SHARE);"
Expand Down
7 changes: 0 additions & 7 deletions clouds/snowflake/modules/doc/random/ST_GENERATEPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ Generates randomly placed points inside a polygon and returns them in an array o

The distribution of the generated points is spherically uniform (i.e. if the coordinates are interpreted as longitude and latitude on a sphere); this means that WGS84 coordinates will be only approximately uniformly distributed, since WGS84 is based on an ellipsoidal model.

````hint:warning
**warning**

It never generates more than the requested number of points, but there is a small chance of generating less points.

````

* `geog`: `GEOGRAPHY` a polygon; the random points generated will be inside this polygon.
* `npoints`: `INT` number of points to generate.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ST_CONCAVEHULL(geojsons [, maxEdge] [, units])
Takes a set of points and returns a concave hull Polygon or MultiPolygon. In case that a single or a couple of points are passed as input, the function will return that point or a segment respectively.

* `geojsons`: `ARRAY` array of features in GeoJSON format casted to STRING.
* `maxEdge` (optional): `DOUBLE` the length (in 'units') of an edge necessary for part of the hull to become concave. By default `maxEdge` is `infinity`.
* `maxEdge` (optional): `DOUBLE` the maximum length allowed for an edge of the concave hull. Higher `maxEdge` values will produce more convex-like hulls. If not provided, the default value `infinity` is used and it would be equivalent to a Convex Hull.
* `units` (optional): `STRING` units of length, the supported options are: miles, kilometers, degrees or radians. By default `units` is `kilometers`.

**Return type**
Expand Down
Loading
Loading