Skip to content

Commit b5c43e1

Browse files
authored
release: 2024-05-21 (#510)
1 parent 703ca29 commit b5c43e1

File tree

22 files changed

+44
-123
lines changed

22 files changed

+44
-123
lines changed

.github/workflows/snowflake.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616

1717
env:
1818
NODE_VERSION: 18.16
19-
PYTHON3_VERSION: 3.8.10
19+
PYTHON3_VERSION: 3.8.18
2020
VIRTUALENV_VERSION: 20.21.1
2121
GCLOUD_VERSION: 290.0.1
2222

@@ -154,7 +154,6 @@ jobs:
154154
timeout-minutes: 10
155155
env:
156156
PACKAGE_BUCKET: gs://carto-analytics-toolbox-core/snowflake
157-
SF_DATABASE: 'carto'
158157
steps:
159158
- name: Checkout repo
160159
uses: actions/checkout@v2

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package-lock.json
2222
MANIFEST
2323
*.ipynb
2424
.pgpass
25+
.~lock.*
2526

2627
# IntelliJ
2728
.idea/

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ CARTO Analytics Toolbox Core.
44

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

7+
## 2024-05-21
8+
9+
- refactor(sf|h3): avoid memory limit exceeded in H3_POLYFILL_TABLE (#501)
10+
- docs(bq,sf,rs|constructors): fix ST_MAKEELLIPSE angle parameter explanation (#505)
11+
- chore(sf): update create-package and licenses year (#507)
12+
- chore(pg): DB Connection Error in tests when % character in PG_PASSWORD (#509)
13+
714
## 2024-04-18
815

916
- chore(sf|h3): reimplement basic h3 functions (#489)

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SPDX short identifier: BSD-3-Clause
22

3-
Copyright (c) 2021-2022, CARTO
3+
Copyright (c) 2021-2024, CARTO
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

clouds/bigquery/common/DROP_FUNCTIONS.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---------------------------------
2-
-- Copyright (C) 2021-2023 CARTO
2+
-- Copyright (C) 2021-2024 CARTO
33
---------------------------------
44

55
CREATE OR REPLACE PROCEDURE `@@BQ_DATASET@@.DROP_FUNCTIONS`()

clouds/bigquery/modules/doc/constructors/ST_MAKEELLIPSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Takes a Point and calculates the ellipse polygon given two semi-axes expressed i
1111
* `center`: `GEOGRAPHY` center point.
1212
* `xSemiAxis`: `FLOAT64` semi (major) axis of the ellipse along the x-axis.
1313
* `ySemiAxis`: `FLOAT64` semi (minor) axis of the ellipse along the y-axis.
14-
* `angle`: `FLOAT64`|`NULL` angle of rotation (along the vertical axis), from North in decimal degrees, positive clockwise. If `NULL` the default value `0` is used.
14+
* `angle`: `FLOAT64`|`NULL` angle of rotation (along the horizontal axis), from East in decimal degrees, positive clockwise. If `NULL` the default value `0` is used.
1515
* `units`: `STRING`|`NULL` units of length, the supported options are: miles, kilometers, and degrees. If `NULL`the default value `kilometers` is used.
1616
* `steps`: `INT64`|`NULL` number of steps. If `NULL` the default value `64` is used.
1717

clouds/postgres/common/DROP_FUNCTIONS.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---------------------------------
2-
-- Copyright (C) 2021-2023 CARTO
2+
-- Copyright (C) 2021-2024 CARTO
33
---------------------------------
44

55
CREATE OR REPLACE PROCEDURE @@PG_SCHEMA@@.__DROP_FUNCTIONS

clouds/postgres/common/test_utils/__init__.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pandas as pd
66
import psycopg2
77

8+
from urllib.parse import quote_plus
89
from shapely import wkt
910
from sqlalchemy import create_engine
1011

@@ -15,14 +16,21 @@
1516
'password': os.environ['PG_PASSWORD'],
1617
'port': 5432,
1718
}
19+
URL_PG_CONFIG = {
20+
'host': os.environ['PG_HOST'],
21+
'database': os.environ['PG_DATABASE'],
22+
'user': os.environ['PG_USER'],
23+
'password': quote_plus(os.environ['PG_PASSWORD']),
24+
'port': 5432,
25+
}
1826

1927
conn = psycopg2.connect(**PG_CONFIG)
2028
conn.autocommit = (
2129
True # Needed for running procedures since they must be out of a transaction
2230
)
2331

2432
connection_string = 'postgresql://{user}:{password}@{host}:{port}/{database}'.format(
25-
**PG_CONFIG
33+
**URL_PG_CONFIG
2634
)
2735
engine = create_engine(connection_string)
2836

clouds/redshift/common/DROP_FUNCTIONS.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---------------------------------
2-
-- Copyright (C) 2021-2023 CARTO
2+
-- Copyright (C) 2021-2024 CARTO
33
---------------------------------
44

55
CREATE OR REPLACE PROCEDURE @@RS_SCHEMA@@.__CREATE_DROP_TABLE

clouds/redshift/modules/doc/constructors/ST_MAKEELLIPSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Takes a Point as input and calculates the ellipse polygon given two semi-axes ex
1111
* `center`: `GEOMETRY` center point.
1212
* `xSemiAxis`: `FLOAT8` semi (major) axis of the ellipse along the x-axis.
1313
* `ySemiAxis`: `FLOAT8` semi (minor) axis of the ellipse along the y-axis.
14-
* `angle` (optional): `FLOAT8` angle of rotation (along the vertical axis), from North in decimal degrees, positive clockwise. If not specified, the default value of `0` will be used.
14+
* `angle` (optional): `FLOAT8` angle of rotation (along the horizontal axis), from East in decimal degrees, positive clockwise. If not specified, the default value of `0` will be used.
1515
* `units` (optional): `VARCHAR(10)` units of length. The supported options are: miles, kilometers, meters, and degrees. If not specified, `kilometers` will be used.
1616
* `steps` (optional): `INT` number of steps. If not specified, the default value of `64` will be used.
1717

clouds/snowflake/.~lock.results.csv#

-1
This file was deleted.

clouds/snowflake/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ CARTO Analytics Toolbox Core for Snowflake.
44

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

7+
## [1.2.3] - 2024-05-21
8+
9+
- refactor(h3): avoid memory limit exceeded in H3_POLYFILL_TABLE (#501)
10+
711
## [1.2.2] - 2024-04-18
812

913
- chore(h3): reimplement basic h3 functions (#489)

clouds/snowflake/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ clean-modules:
9696
$(MAKE) -C modules clean
9797

9898
create-package:
99-
$(MAKE) build production=1 dropfirst=1
99+
$(MAKE) build production=1 dropfirst=1 database=CARTO
100100

101101
rm -rf $(DIST_DIR)
102102
mkdir -p $(DIST_DIR)/$(PACKAGE_NAME)

clouds/snowflake/common/DROP_FUNCTIONS.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---------------------------------
2-
-- Copyright (C) 2021-2023 CARTO
2+
-- Copyright (C) 2021-2024 CARTO
33
---------------------------------
44

55
CREATE OR REPLACE PROCEDURE @@SF_SCHEMA@@._DROP_FUNCTIONS()

clouds/snowflake/common/Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ PYTHON3_VERSION = 3
44
VENV3_DIR ?= $(COMMON_DIR)/../venv3
55
VENV3_BIN = $(VENV3_DIR)/bin
66
NODE_MODULES_DEV = $(COMMON_DIR)/node_modules
7-
export SF_SCHEMA_DEFAULT = carto
7+
export SF_SCHEMA_DEFAULT = CARTO
88

99
ifneq (,$(wildcard $(ENV_DIR)/.env))
1010
include $(ENV_DIR)/.env
1111
export $(shell sed 's/=.*//' $(ENV_DIR)/.env)
1212
endif
1313

14+
ifdef database
15+
export SF_DATABASE = $(database)
16+
endif
17+
1418
ifeq ($(production),1)
1519
export SF_SCHEMA = $(SF_DATABASE).$(SF_SCHEMA_DEFAULT)
1620
export SF_UNQUALIFIED_SCHEMA = $(SF_SCHEMA_DEFAULT)

clouds/snowflake/modules/doc/constructors/ST_MAKEELLIPSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Takes a Point and calculates the ellipse polygon given two semi-axes expressed i
1111
* `center`: `GEOGRAPHY` center point.
1212
* `xSemiAxis`: `DOUBLE` semi (major) axis of the ellipse along the x-axis.
1313
* `ySemiAxis`: `DOUBLE` semi (minor) axis of the ellipse along the y-axis.
14-
* `angle` (optional): `DOUBLE` angle of rotation (along the vertical axis), from North in decimal degrees, positive clockwise. By default `angle` is `0`.
14+
* `angle` (optional): `DOUBLE` angle of rotation (along the horizontal axis), from East in decimal degrees, positive clockwise. By default `angle` is `0`.
1515
* `units` (optional): `STRING` units of length, the supported options are: miles, kilometers, and degrees. By default `units` is `kilometers`.
1616
* `steps` (optional): `INT` number of steps. By default `steps` is `64`.
1717

clouds/snowflake/modules/sql/h3/H3_POLYFILL_TABLE.sql

+7-16
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,14 @@ RETURNS STRING
1313
LANGUAGE SQL
1414
EXECUTE AS CALLER
1515
AS $$
16-
DECLARE
17-
column_names_csv STRING;
18-
polyfill_query STRING;
1916
BEGIN
17+
EXECUTE IMMEDIATE '
18+
CREATE OR REPLACE TABLE ' || output_table || ' CLUSTER BY (H3) AS
19+
WITH __input AS ( ' || input_query || ' )
20+
SELECT CAST(cell.value AS STRING) AS h3, i.* EXCLUDE(geom)
21+
FROM __input AS i, TABLE(FLATTEN(@@SF_SCHEMA@@.H3_POLYFILL(geom, ' || resolution || ', ''' || mode || '''))) AS cell;
22+
';
2023

21-
-- Validate
22-
EXECUTE IMMEDIATE 'SELECT * FROM (' || input_query || ') WHERE FALSE';
23-
24-
-- New table with correct columns
25-
EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE ' || output_table || ' CLUSTER BY (H3) AS SELECT * EXCLUDE geom, NULL as H3 FROM (' || input_query || ') WHERE FALSE';
26-
27-
column_names_csv := (SELECT LISTAGG(COLUMN_NAME, ',') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ILIKE :output_table AND TABLE_CATALOG=@@SF_SCHEMA@@._GET_DATABASE(:output_table) AND TABLE_SCHEMA=@@SF_SCHEMA@@._GET_SCHEMA(:output_table));
28-
29-
polyfill_query := 'INSERT INTO ' || output_table || ' (' || column_names_csv || ') SELECT ' || column_names_csv || ' FROM (WITH virtual_table AS (' || input_query || ') SELECT *, value as H3 FROM virtual_table, LATERAL FLATTEN(input => @@SF_SCHEMA@@.H3_POLYFILL(virtual_table.geom, ' || resolution || ',\'' || mode || '\')))';
30-
31-
EXECUTE IMMEDIATE polyfill_query;
32-
33-
RETURN 'Finished!';
24+
RETURN 'H3 Polyfill result added in table ' || output_table;
3425
END;
3526
$$;

clouds/snowflake/modules/sql/utils/_GET_DATABASE.sql

-22
This file was deleted.

clouds/snowflake/modules/sql/utils/_GET_SCHEMA.sql

-24
This file was deleted.

clouds/snowflake/modules/test/utils/GET_DATABASE.test.js

-24
This file was deleted.

clouds/snowflake/modules/test/utils/GET_SCHEMA.test.js

-22
This file was deleted.

clouds/snowflake/version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.2
1+
1.2.3

0 commit comments

Comments
 (0)