From 773b3d282b19f2e3d21e78a8ff93901c9f5dbaa2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 27 Dec 2022 16:24:25 +0100 Subject: [PATCH] Release version 2022-12 (#374) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jesús Arroyo Torrens Co-authored-by: Javier Goizueta --- CHANGELOG.md | 12 + clouds/bigquery/CHANGELOG.md | 450 +----------------- clouds/bigquery/CHANGELOG.old.md | 438 +++++++++++++++++ .../modules/doc/h3/H3_INT_TOSTRING.md | 24 + .../modules/doc/h3/H3_STRING_TOINT.md | 24 + .../doc/quadbin/QUADBIN_FROMQUADKEY.md | 24 + .../modules/doc/quadbin/QUADBIN_TOQUADKEY.md | 24 + .../sql/quadbin/QUADBIN_FROMQUADKEY.sql | 25 + .../modules/sql/quadbin/QUADBIN_TOQUADKEY.sql | 15 + .../test/quadbin/QUADBIN_FROMQUADKEY.test.js | 13 + .../test/quadbin/QUADBIN_TOQUADKEY.test.js | 13 + clouds/bigquery/version | 2 +- clouds/databricks/CHANGELOG.md | 255 +--------- clouds/databricks/CHANGELOG.old.md | 244 ++++++++++ clouds/databricks/version | 2 +- clouds/postgres/CHANGELOG.md | 38 +- clouds/postgres/CHANGELOG.old.md | 27 ++ .../doc/quadbin/QUADBIN_FROMQUADKEY.md | 22 + .../modules/doc/quadbin/QUADBIN_TOQUADKEY.md | 22 + .../sql/quadbin/QUADBIN_FROMQUADKEY.sql | 45 ++ .../modules/sql/quadbin/QUADBIN_TOQUADKEY.sql | 49 ++ .../test/quadbin/test_QUADBIN_FROMQUADKEY.py | 17 + .../test/quadbin/test_QUADBIN_TOQUADKEY.py | 17 + clouds/postgres/version | 2 +- clouds/redshift/CHANGELOG.md | 228 +-------- clouds/redshift/CHANGELOG.old.md | 217 +++++++++ .../doc/quadbin/QUADBIN_FROMQUADKEY.md | 22 + .../modules/doc/quadbin/QUADBIN_RESOLUTION.md | 2 +- .../modules/doc/quadbin/QUADBIN_TOQUADKEY.md | 22 + .../sql/quadbin/QUADBIN_FROMQUADKEY.sql | 19 + .../modules/sql/quadbin/QUADBIN_TOQUADKEY.sql | 15 + .../test/quadbin/test_QUADBIN_FROMQUADKEY.py | 17 + .../test/quadbin/test_QUADBIN_TOQUADKEY.py | 17 + clouds/redshift/version | 2 +- clouds/snowflake/CHANGELOG.md | 340 +------------ clouds/snowflake/CHANGELOG.old.md | 326 +++++++++++++ clouds/snowflake/common/VERSION.sql | 2 +- .../libraries/javascript/libs/h3_boundary.js | 18 +- .../modules/doc/h3/H3_INT_TOSTRING.md | 22 + .../modules/doc/h3/H3_STRING_TOINT.md | 22 + .../doc/processing/ST_DELAUNAYLINES.md | 2 +- .../modules/doc/processing/ST_VORONOILINES.md | 2 +- .../doc/quadbin/QUADBIN_FROMQUADKEY.md | 22 + .../modules/doc/quadbin/QUADBIN_TOQUADKEY.md | 22 + .../snowflake/modules/sql/h3/H3_BOUNDARY.sql | 8 +- .../modules/sql/h3/H3_INT_TOSTRING.sql | 2 +- .../modules/sql/h3/H3_STRING_TOINT.sql | 2 +- .../modules/sql/quadbin/QUADBIN_BBOX.sql | 2 +- .../modules/sql/quadbin/QUADBIN_CENTER.sql | 2 +- .../sql/quadbin/QUADBIN_FROMGEOGPOINT.sql | 2 +- .../sql/quadbin/QUADBIN_FROMLONGLAT.sql | 2 +- .../sql/quadbin/QUADBIN_FROMQUADKEY.sql | 26 + .../modules/sql/quadbin/QUADBIN_FROMZXY.sql | 2 +- .../modules/sql/quadbin/QUADBIN_ISVALID.sql | 2 +- .../modules/sql/quadbin/QUADBIN_KRING.sql | 2 +- .../sql/quadbin/QUADBIN_KRING_DISTANCES.sql | 2 +- .../sql/quadbin/QUADBIN_RESOLUTION.sql | 2 +- .../modules/sql/quadbin/QUADBIN_SIBLING.sql | 2 +- .../sql/quadbin/QUADBIN_TOCHILDREN.sql | 2 +- .../modules/sql/quadbin/QUADBIN_TOPARENT.sql | 2 +- .../modules/sql/quadbin/QUADBIN_TOQUADKEY.sql | 24 + .../modules/test/h3/H3_BOUNDARY.test.js | 12 +- .../test/quadbin/QUADBIN_FROMQUADKEY.test.js | 13 + .../test/quadbin/QUADBIN_TOQUADKEY.test.js | 13 + clouds/snowflake/version | 2 +- 65 files changed, 1943 insertions(+), 1326 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 clouds/bigquery/CHANGELOG.old.md create mode 100644 clouds/bigquery/modules/doc/h3/H3_INT_TOSTRING.md create mode 100644 clouds/bigquery/modules/doc/h3/H3_STRING_TOINT.md create mode 100644 clouds/bigquery/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md create mode 100644 clouds/bigquery/modules/doc/quadbin/QUADBIN_TOQUADKEY.md create mode 100644 clouds/bigquery/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql create mode 100644 clouds/bigquery/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql create mode 100644 clouds/bigquery/modules/test/quadbin/QUADBIN_FROMQUADKEY.test.js create mode 100644 clouds/bigquery/modules/test/quadbin/QUADBIN_TOQUADKEY.test.js create mode 100644 clouds/databricks/CHANGELOG.old.md create mode 100644 clouds/postgres/CHANGELOG.old.md create mode 100644 clouds/postgres/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md create mode 100644 clouds/postgres/modules/doc/quadbin/QUADBIN_TOQUADKEY.md create mode 100644 clouds/postgres/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql create mode 100644 clouds/postgres/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql create mode 100644 clouds/postgres/modules/test/quadbin/test_QUADBIN_FROMQUADKEY.py create mode 100644 clouds/postgres/modules/test/quadbin/test_QUADBIN_TOQUADKEY.py create mode 100644 clouds/redshift/CHANGELOG.old.md create mode 100644 clouds/redshift/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md create mode 100644 clouds/redshift/modules/doc/quadbin/QUADBIN_TOQUADKEY.md create mode 100644 clouds/redshift/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql create mode 100644 clouds/redshift/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql create mode 100644 clouds/redshift/modules/test/quadbin/test_QUADBIN_FROMQUADKEY.py create mode 100644 clouds/redshift/modules/test/quadbin/test_QUADBIN_TOQUADKEY.py create mode 100644 clouds/snowflake/CHANGELOG.old.md create mode 100644 clouds/snowflake/modules/doc/h3/H3_INT_TOSTRING.md create mode 100644 clouds/snowflake/modules/doc/h3/H3_STRING_TOINT.md create mode 100644 clouds/snowflake/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md create mode 100644 clouds/snowflake/modules/doc/quadbin/QUADBIN_TOQUADKEY.md create mode 100644 clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql create mode 100644 clouds/snowflake/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql create mode 100644 clouds/snowflake/modules/test/quadbin/QUADBIN_FROMQUADKEY.test.js create mode 100644 clouds/snowflake/modules/test/quadbin/QUADBIN_TOQUADKEY.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..fb338c1e4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# Changelog + +CARTO Analytics Toolbox Core. + +All notable commits to this project will be documented in this file. + +## 2022-12-27 + +- docs(bq,sf|h3): add H3 INT/STRING functions reference (#369) +- feat(bq,sf,rs,pg|quadbin): add quadbin/quadkey conversion functions (#370) +- fix(sf|h3): H3_BOUNDARY by removing duplicated points (#371) +- fix(sf): add missing SECURE tag to share ATC functions (#372) diff --git a/clouds/bigquery/CHANGELOG.md b/clouds/bigquery/CHANGELOG.md index 3e737159c..5956549ef 100644 --- a/clouds/bigquery/CHANGELOG.md +++ b/clouds/bigquery/CHANGELOG.md @@ -2,451 +2,9 @@ CARTO Analytics Toolbox Core for BigQuery. -All notable changes to this project will be documented in this file. +All notable commits to this project will be documented in this file. -The format is inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [0.2.0] - 2022-12-27 -## [0.1.0] - 2022-11 - -### All modules - -#### New - -- Create release workflows - -#### Improvement - -- Adapt to Semver - -## [2022.11.08] - 2022-11-08 - -### Module h3 - -#### Improvement - -- Add linestrings and points support to function H3_POLYFILL. - -## [2022.10.28] - 2022-10-28 - -### Module s2 - -#### New - -- Add S2_RESOLUTION function. -- Add S2_TOCHILDREN function. - -## [2022.10.28] - 2022-10-26 - -### Module transformations - -#### Fix - -- Fix ST_BUFFER crashing with geographies close to the poles. - -## [2022.10.24] - 2022-10-24 - -### Module processing - -#### Fix - -- Prevent error in ST_VORONOIPOLYGONS, ST_VORONOILINES, ST_VORONOIPOLYGONS, ST_DELAUNAYLINES when points where too close together by rounding input coordinates to 5 decimal places. - -## [2022.10.07] - 2022-10-07 - -### Module clustering - -#### New - -- Move ST_CLUSTERKMEANS function to core. - -### Module random - -#### New - -- Move ST_GENERATEPOINTS function to core. - -## [2022.09.15] - 2022-09-15 - -### Module s2 - -#### New - -- Add S2_CENTER function. - -## [2022.08.09] - 2022-08-09 - -### Module h3 - -#### Fix - -- Apply make_valid in H3_BOUNDARY. - -## [2022.07.07] - 2022-07-07 - -### Module h3 - -#### Fix - -- Correctly handle large polygons in H3_POLYFILL. -- Fixed wrong uppercase for quadbin and h3 tile ids - -## [2022.06.23] - 2022-06-23 - -### Module quadbin - -#### New - -- Add QUADBIN_BBOX function. -- Add QUADBIN_BOUNDARY function. -- Add QUADBIN_CENTER function. -- Add QUADBIN_FROMGEOGPOINT function. -- Add QUADBIN_FROMLONGLAT function. -- Add QUADBIN_FROMZXY function. -- Add QUADBIN_ISVALID function. -- Add QUADBIN_KRING function. -- Add QUADBIN_KRING_DISTANCES function. -- Add QUADBIN_POLYFILL function. -- Add QUADBIN_RESOLUTION function. -- Add QUADBIN_SIBLING function. -- Add QUADBIN_TOCHILDREN function. -- Add QUADBIN_TOPARENT function. -- Add QUADBIN_TOZXY function. - -## [2022.03.21] - 2022-03-21 - -### Module transformations - -#### Improvement - -- ST_CONCAVEHULL now allows arrays with one/two points as input. - -## [2022.02.15] - 2022-02-15 - -### Module h3 - -#### New - -- Add H3_CENTER function. -- Add H3_RESOLUTION function. - -## [2021.12.16] - 2021-12-16 - -### Module accessors - -#### Improvement - -- Deployment schema "carto" instead of "accessors". - -#### Removed - -- Remove VERSION function. - -### Module constructors - -#### Improvement - -- Deployment schema "carto" instead of "constructors". - -#### Removed - -- Remove VERSION function. - -### Module geohash - -#### Improvement - -- Deployment schema "carto" instead of "geohash". - -#### Removed - -- Remove VERSION function. - -### Module h3 - -#### Improvement - -- Deployment schema "carto" instead of "h3". -- Rename ST_ASH3 function to H3_FROMGEOGPOINT. -- Rename LONGLAT_ASH3 function to H3_FROMLONGLAT. -- Rename ST_ASH3_POLYFILL function to H3_POLYFILL. -- Rename ST_BOUNDARY function to H3_BOUNDARY. -- Rename ISVALID function to H3_ISVALID. -- Rename COMPACT function to H3_COMPACT. -- Rename UNCOMPACT function to H3_UNCOMPACT. -- Rename TOPARENT function to H3_TOPARENT. -- Rename TOCHILDREN function to H3_TOCHILDREN. -- Rename ISPENTAGON function to H3_ISPENTAGON. -- Rename DISTANCE function to H3_DISTANCE. -- Rename KRING function to H3_KRING. -- Rename KRING_DISTANCES function to H3_KRING_DISTANCES. -- Rename HEXRING function to H3_HEXRING. - -#### Removed - -- Remove VERSION function. - -### Module measurements - -#### Improvement - -- Deployment schema "carto" instead of "measurements". - -#### Removed - -- Remove ST_ANGLE, already present in Bigquery. -- Remove VERSION function. - -### Module placekey - -#### Improvement - -- Deployment schema "carto" instead of "placekey". -- Rename H3_ASPLACEKEY function to PLACEKEY_FROMH3. -- Rename PLACEKEY_ASH3 function to PLACEKEY_TOH3. -- Rename ISVALID function to PLACEKEY_ISVALID. - -#### Removed - -- Remove VERSION function. - -### Module processing - -#### Improvement - -- Deployment schema "carto" instead of "processing". - -#### Removed - -- Remove VERSION function. - -### Module s2 - -#### Improvement - -- Deployment schema "carto" instead of "s2". -- Rename ID_FROMHILBERTQUADKEY function to S2_FROMHILBERTQUADKEY. -- Rename HILBERTQUADKEY_FROMID function to S2_TOHILBERTQUADKEY. -- Rename LONGLAT_ASID function to S2_FROMLONGLAT. -- Rename ST_ASID function to S2_FROMGEOGPOINT. -- Rename ID_FROMTOKEN function to S2_FROMTOKEN. -- Rename TOKEN_FROMID function to S2_TOTOKEN. -- Rename ID_FROMUINT64REPR function to S2_FROMUINT64REPR. -- Rename UINT64REPR_FROMID function to S2_TOUINT64REPR. -- Rename ST_BOUNDARY function to S2_BOUNDARY. - -#### Removed - -- Remove VERSION function. - -### Module transformations - -#### Improvement - -- Deployment schema "carto" instead of "transformations". - -#### Removed - -- Remove VERSION function. - -## [2021.09.23] - 2021-09-23 - -### Module s2 - -#### Improvement - -- Rename functions ID_FROMUINT64REPR, UINT64REPR_FROMID to follow convention. - -## [2021.09.22] - 2021-09-22 - -### Module h3 - -#### Improvement - -- Review HEXRING, KRING functions. -- Change KRING_INDEXED to KRING_DISTANCES. - -## [2021.09.14] - 2021-09-14 - -### Module s2 - -#### Fix - -- Avoid keeping planar shape in spherical coordinates in ST_BOUNDARY. - -## [2021.08.24] - 2021-08-24 - -### Module h3 - -#### Fix - -- Support GEOMETRYCOLLECTION from ST_ASH3_POLYFILL. - -## [2021.08.04] - 2021-08-04 - -### Module h3 - -#### New - -- Add KRING_INDEXED function. - -## [2021.07.30] - 2021-07-30 - -### Module geohash - -#### New - -- Create geohash module. -- Add VERSION function. -- Add ST_BOUNDARY function. - -## [2021.06.01] - 2021-06-01 - -### Module s2 - -#### New - -- Add TOKEN_FROMID function. -- Add ID_FROMTOKEN function. -- Add ID_FROM_UINT64REPR function. -- Add UINT64REPR_FROM_ID function. - -## [2021.05.04] - 2021-05-04 - -### Module accessors - -#### New - -- Create accessors module. -- Add ST_ENVELOPE function. -- Add VERSION function. - -### Module processing - -#### New - -- Create processing module. -- Add ST_VORONOIPOLYGONS function. -- Add ST_VORONOILINES function. -- Add ST_DELAUNAYPOLYGONS function. -- Add ST_DELAUNAYLINES function. -- Add ST_POLYGONIZE function. -- Add VERSION function. - -### Module transformations - -#### New - -- Add ST_CONCAVEHULL function. - -## [2021.04.29] - 2021-04-29 - -### Module constructors - -#### New - -- Add ST_BEZIERSPLINE function. -- Add ST_MAKEELLIPSE function. - -### Module measurements - -#### New - -- Create measurements module. -- Add ST_ANGLE function. -- Add ST_AZIMUTH function. -- Add ST_MINKOWSKIDISTANCE function. - -### Module transformations - -#### New - -- Rename module to transformations. -- Add ST_CENTERMEAN function. -- Add ST_CENTERMEDIAN function. -- Add ST_CENTEROFMASS function. -- Add ST_DESTINATION function. -- Add ST_GREATCIRCLE function. -- Add ST_LINE_INTERPOLATE_POINT function. - -## [2021.04.28] - 2021-04-28 - -### Module constructors - -#### New - -- Create constructors module. -- Add ST_MAKEENVELOPE function. -- Add ST_TILEENVELOPE function. -- Add VERSION function. - -## [2021.04.16] - 2021-04-16 - -### Module transformations - -#### New - -- Create transformation module. -- Add ST_BUFFER function. -- Add VERSION function. - -## [2021.04.09] - 2021-04-09 - -### Module h3 - -#### Improvement - -- Use hexadecimal as default type instead of int for h3 indexes. - -#### Fix - -- Fix ST_BOUNDARY generating error when not able to parse geometry. - -### Module placekey - -#### Improvement - -- Placekey conversions works with hexadecimal h3 indexes instead of int. - -## [2021.03.31] - 2021-03-31 - -### Module h3 - -#### New - -- Create h3 module. -- Add ST_ASH3 function. -- Add LONGLAT_ASH3 function. -- Add ST_ASH3_POLYFILL function. -- Add ST_BOUNDARY function. -- Add ISVALID function. -- Add COMPACT function. -- Add UNCOMPACT function. -- Add TOPARENT function. -- Add TOCHILDREN function. -- Add ISPENTAGON function. -- Add DISTANCE function. -- Add KRING function. -- Add HEXRING function. -- Add VERSION function. - -### Module placekey - -#### New - -- Create placekey module. -- Add H3_ASPLACEKEY function. -- Add PLACEKEY_ASH3 function. -- Add ISVALID function. -- Add VERSION function. - -### Module s2 - -#### New - -- Create s2 module. -- Add ID_FROMHILBERTQUADKEY function. -- Add HILBERTQUADKEY_FROMID function. -- Add LONGLAT_ASID function. -- Add ST_ASID function. -- Add ST_BOUNDARY function. -- Add VERSION function. +- docs(h3): add H3 INT/STRING functions reference (#369) +- feat(quadbin): add quadbin/quadkey conversion functions (#370) diff --git a/clouds/bigquery/CHANGELOG.old.md b/clouds/bigquery/CHANGELOG.old.md new file mode 100644 index 000000000..4c7a2fff9 --- /dev/null +++ b/clouds/bigquery/CHANGELOG.old.md @@ -0,0 +1,438 @@ +# Changelog [old] + +CARTO Analytics Toolbox Core for BigQuery. + +The format is inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + +## [2022.11.08] - 2022-11-08 + +### Module h3 + +#### Improvement + +- Add linestrings and points support to function H3_POLYFILL. + +## [2022.10.28] - 2022-10-28 + +### Module s2 + +#### Feature + +- Add S2_RESOLUTION function. +- Add S2_TOCHILDREN function. + +## [2022.10.28] - 2022-10-26 + +### Module transformations + +#### Fix + +- Fix ST_BUFFER crashing with geographies close to the poles. + +## [2022.10.24] - 2022-10-24 + +### Module processing + +#### Fix + +- Prevent error in ST_VORONOIPOLYGONS, ST_VORONOILINES, ST_VORONOIPOLYGONS, ST_DELAUNAYLINES when points where too close together by rounding input coordinates to 5 decimal places. + +## [2022.10.07] - 2022-10-07 + +### Module clustering + +#### Feature + +- Move ST_CLUSTERKMEANS function to core. + +### Module random + +#### Feature + +- Move ST_GENERATEPOINTS function to core. + +## [2022.09.15] - 2022-09-15 + +### Module s2 + +#### Feature + +- Add S2_CENTER function. + +## [2022.08.09] - 2022-08-09 + +### Module h3 + +#### Fix + +- Apply make_valid in H3_BOUNDARY. + +## [2022.07.07] - 2022-07-07 + +### Module h3 + +#### Fix + +- Correctly handle large polygons in H3_POLYFILL. +- Fixed wrong uppercase for quadbin and h3 tile ids + +## [2022.06.23] - 2022-06-23 + +### Module quadbin + +#### Feature + +- Add QUADBIN_BBOX function. +- Add QUADBIN_BOUNDARY function. +- Add QUADBIN_CENTER function. +- Add QUADBIN_FROMGEOGPOINT function. +- Add QUADBIN_FROMLONGLAT function. +- Add QUADBIN_FROMZXY function. +- Add QUADBIN_ISVALID function. +- Add QUADBIN_KRING function. +- Add QUADBIN_KRING_DISTANCES function. +- Add QUADBIN_POLYFILL function. +- Add QUADBIN_RESOLUTION function. +- Add QUADBIN_SIBLING function. +- Add QUADBIN_TOCHILDREN function. +- Add QUADBIN_TOPARENT function. +- Add QUADBIN_TOZXY function. + +## [2022.03.21] - 2022-03-21 + +### Module transformations + +#### Improvement + +- ST_CONCAVEHULL now allows arrays with one/two points as input. + +## [2022.02.15] - 2022-02-15 + +### Module h3 + +#### Feature + +- Add H3_CENTER function. +- Add H3_RESOLUTION function. + +## [2021.12.16] - 2021-12-16 + +### Module accessors + +#### Improvement + +- Deployment schema "carto" instead of "accessors". + +#### Removed + +- Remove VERSION function. + +### Module constructors + +#### Improvement + +- Deployment schema "carto" instead of "constructors". + +#### Removed + +- Remove VERSION function. + +### Module geohash + +#### Improvement + +- Deployment schema "carto" instead of "geohash". + +#### Removed + +- Remove VERSION function. + +### Module h3 + +#### Improvement + +- Deployment schema "carto" instead of "h3". +- Rename ST_ASH3 function to H3_FROMGEOGPOINT. +- Rename LONGLAT_ASH3 function to H3_FROMLONGLAT. +- Rename ST_ASH3_POLYFILL function to H3_POLYFILL. +- Rename ST_BOUNDARY function to H3_BOUNDARY. +- Rename ISVALID function to H3_ISVALID. +- Rename COMPACT function to H3_COMPACT. +- Rename UNCOMPACT function to H3_UNCOMPACT. +- Rename TOPARENT function to H3_TOPARENT. +- Rename TOCHILDREN function to H3_TOCHILDREN. +- Rename ISPENTAGON function to H3_ISPENTAGON. +- Rename DISTANCE function to H3_DISTANCE. +- Rename KRING function to H3_KRING. +- Rename KRING_DISTANCES function to H3_KRING_DISTANCES. +- Rename HEXRING function to H3_HEXRING. + +#### Removed + +- Remove VERSION function. + +### Module measurements + +#### Improvement + +- Deployment schema "carto" instead of "measurements". + +#### Removed + +- Remove ST_ANGLE, already present in Bigquery. +- Remove VERSION function. + +### Module placekey + +#### Improvement + +- Deployment schema "carto" instead of "placekey". +- Rename H3_ASPLACEKEY function to PLACEKEY_FROMH3. +- Rename PLACEKEY_ASH3 function to PLACEKEY_TOH3. +- Rename ISVALID function to PLACEKEY_ISVALID. + +#### Removed + +- Remove VERSION function. + +### Module processing + +#### Improvement + +- Deployment schema "carto" instead of "processing". + +#### Removed + +- Remove VERSION function. + +### Module s2 + +#### Improvement + +- Deployment schema "carto" instead of "s2". +- Rename ID_FROMHILBERTQUADKEY function to S2_FROMHILBERTQUADKEY. +- Rename HILBERTQUADKEY_FROMID function to S2_TOHILBERTQUADKEY. +- Rename LONGLAT_ASID function to S2_FROMLONGLAT. +- Rename ST_ASID function to S2_FROMGEOGPOINT. +- Rename ID_FROMTOKEN function to S2_FROMTOKEN. +- Rename TOKEN_FROMID function to S2_TOTOKEN. +- Rename ID_FROMUINT64REPR function to S2_FROMUINT64REPR. +- Rename UINT64REPR_FROMID function to S2_TOUINT64REPR. +- Rename ST_BOUNDARY function to S2_BOUNDARY. + +#### Removed + +- Remove VERSION function. + +### Module transformations + +#### Improvement + +- Deployment schema "carto" instead of "transformations". + +#### Removed + +- Remove VERSION function. + +## [2021.09.23] - 2021-09-23 + +### Module s2 + +#### Improvement + +- Rename functions ID_FROMUINT64REPR, UINT64REPR_FROMID to follow convention. + +## [2021.09.22] - 2021-09-22 + +### Module h3 + +#### Improvement + +- Review HEXRING, KRING functions. +- Change KRING_INDEXED to KRING_DISTANCES. + +## [2021.09.14] - 2021-09-14 + +### Module s2 + +#### Fix + +- Avoid keeping planar shape in spherical coordinates in ST_BOUNDARY. + +## [2021.08.24] - 2021-08-24 + +### Module h3 + +#### Fix + +- Support GEOMETRYCOLLECTION from ST_ASH3_POLYFILL. + +## [2021.08.04] - 2021-08-04 + +### Module h3 + +#### Feature + +- Add KRING_INDEXED function. + +## [2021.07.30] - 2021-07-30 + +### Module geohash + +#### Feature + +- Create geohash module. +- Add VERSION function. +- Add ST_BOUNDARY function. + +## [2021.06.01] - 2021-06-01 + +### Module s2 + +#### Feature + +- Add TOKEN_FROMID function. +- Add ID_FROMTOKEN function. +- Add ID_FROM_UINT64REPR function. +- Add UINT64REPR_FROM_ID function. + +## [2021.05.04] - 2021-05-04 + +### Module accessors + +#### Feature + +- Create accessors module. +- Add ST_ENVELOPE function. +- Add VERSION function. + +### Module processing + +#### Feature + +- Create processing module. +- Add ST_VORONOIPOLYGONS function. +- Add ST_VORONOILINES function. +- Add ST_DELAUNAYPOLYGONS function. +- Add ST_DELAUNAYLINES function. +- Add ST_POLYGONIZE function. +- Add VERSION function. + +### Module transformations + +#### Feature + +- Add ST_CONCAVEHULL function. + +## [2021.04.29] - 2021-04-29 + +### Module constructors + +#### Feature + +- Add ST_BEZIERSPLINE function. +- Add ST_MAKEELLIPSE function. + +### Module measurements + +#### Feature + +- Create measurements module. +- Add ST_ANGLE function. +- Add ST_AZIMUTH function. +- Add ST_MINKOWSKIDISTANCE function. + +### Module transformations + +#### Feature + +- Rename module to transformations. +- Add ST_CENTERMEAN function. +- Add ST_CENTERMEDIAN function. +- Add ST_CENTEROFMASS function. +- Add ST_DESTINATION function. +- Add ST_GREATCIRCLE function. +- Add ST_LINE_INTERPOLATE_POINT function. + +## [2021.04.28] - 2021-04-28 + +### Module constructors + +#### Feature + +- Create constructors module. +- Add ST_MAKEENVELOPE function. +- Add ST_TILEENVELOPE function. +- Add VERSION function. + +## [2021.04.16] - 2021-04-16 + +### Module transformations + +#### Feature + +- Create transformation module. +- Add ST_BUFFER function. +- Add VERSION function. + +## [2021.04.09] - 2021-04-09 + +### Module h3 + +#### Improvement + +- Use hexadecimal as default type instead of int for h3 indexes. + +#### Fix + +- Fix ST_BOUNDARY generating error when not able to parse geometry. + +### Module placekey + +#### Improvement + +- Placekey conversions works with hexadecimal h3 indexes instead of int. + +## [2021.03.31] - 2021-03-31 + +### Module h3 + +#### Feature + +- Create h3 module. +- Add ST_ASH3 function. +- Add LONGLAT_ASH3 function. +- Add ST_ASH3_POLYFILL function. +- Add ST_BOUNDARY function. +- Add ISVALID function. +- Add COMPACT function. +- Add UNCOMPACT function. +- Add TOPARENT function. +- Add TOCHILDREN function. +- Add ISPENTAGON function. +- Add DISTANCE function. +- Add KRING function. +- Add HEXRING function. +- Add VERSION function. + +### Module placekey + +#### Feature + +- Create placekey module. +- Add H3_ASPLACEKEY function. +- Add PLACEKEY_ASH3 function. +- Add ISVALID function. +- Add VERSION function. + +### Module s2 + +#### Feature + +- Create s2 module. +- Add ID_FROMHILBERTQUADKEY function. +- Add HILBERTQUADKEY_FROMID function. +- Add LONGLAT_ASID function. +- Add ST_ASID function. +- Add ST_BOUNDARY function. +- Add VERSION function. diff --git a/clouds/bigquery/modules/doc/h3/H3_INT_TOSTRING.md b/clouds/bigquery/modules/doc/h3/H3_INT_TOSTRING.md new file mode 100644 index 000000000..ec953eaef --- /dev/null +++ b/clouds/bigquery/modules/doc/h3/H3_INT_TOSTRING.md @@ -0,0 +1,24 @@ +### H3_INT_TOSTRING + +{{% bannerNote type="code" %}} +carto.H3_INT_TOSTRING(index) +{{%/ bannerNote %}} + +**Description** + +Converts the integer representation of the H3 index to the string representation. + +* `index`: `INT64` The H3 cell index. + +**Return type** + +`STRING` + +{{% customSelector %}} +**Example** +{{%/ customSelector %}} + +```sql +SELECT `carto-os`.carto.H3_INT_TOSTRING(596645165859340287); +-- 847b59dffffffff +``` diff --git a/clouds/bigquery/modules/doc/h3/H3_STRING_TOINT.md b/clouds/bigquery/modules/doc/h3/H3_STRING_TOINT.md new file mode 100644 index 000000000..60af499a1 --- /dev/null +++ b/clouds/bigquery/modules/doc/h3/H3_STRING_TOINT.md @@ -0,0 +1,24 @@ +### H3_STRING_TOINT + +{{% bannerNote type="code" %}} +carto.H3_STRING_TOINT(index) +{{%/ bannerNote %}} + +**Description** + +Converts the string representation of the H3 index to the integer representation. + +* `index`: `STRING` The H3 cell index. + +**Return type** + +`INT64` + +{{% customSelector %}} +**Example** +{{%/ customSelector %}} + +```sql +SELECT `carto-os`.carto.H3_STRING_TOINT('847b59dffffffff'); +-- 596645165859340287 +``` diff --git a/clouds/bigquery/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md b/clouds/bigquery/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md new file mode 100644 index 000000000..f1e0fc8d1 --- /dev/null +++ b/clouds/bigquery/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md @@ -0,0 +1,24 @@ +### QUADBIN_FROMQUADKEY + +{{% bannerNote type="code" %}} +carto.QUADBIN_FROMQUADKEY(quadkey) +{{%/ bannerNote %}} + +**Description** + +Compute a quadbin index from a quadkey. + +* `quadkey`: `STRING` Quadkey representation of the index. + +**Return type** + +`INT64` + +{{% customSelector %}} +**Example** +{{%/ customSelector %}} + +```sql +SELECT `carto-os`.carto.QUADBIN_FROMQUADKEY('0231001222'); +-- 5233974874938015743 +``` diff --git a/clouds/bigquery/modules/doc/quadbin/QUADBIN_TOQUADKEY.md b/clouds/bigquery/modules/doc/quadbin/QUADBIN_TOQUADKEY.md new file mode 100644 index 000000000..f4ceec9fe --- /dev/null +++ b/clouds/bigquery/modules/doc/quadbin/QUADBIN_TOQUADKEY.md @@ -0,0 +1,24 @@ +### QUADBIN_TOQUADKEY + +{{% bannerNote type="code" %}} +carto.QUADBIN_TOQUADKEY(quadbin) +{{%/ bannerNote %}} + +**Description** + +Compute a quadkey from a quadbin index. + +* `quadbin`: `INT64` Quadbin index. + +**Return type** + +`STRING` + +{{% customSelector %}} +**Example** +{{%/ customSelector %}} + +```sql +SELECT `carto-os`.carto.QUADBIN_TOQUADKEY(5233974874938015743); +-- '0231001222' +``` diff --git a/clouds/bigquery/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql b/clouds/bigquery/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql new file mode 100644 index 000000000..dabc2efab --- /dev/null +++ b/clouds/bigquery/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql @@ -0,0 +1,25 @@ +---------------------------- +-- Copyright (C) 2022 CARTO +---------------------------- + +CREATE OR REPLACE FUNCTION `@@BQ_DATASET@@.__QUADBIN_FROMQUADKEY` +(quadkey STRING) +RETURNS STRING +DETERMINISTIC +LANGUAGE js +AS """ + const z = BigInt(quadkey.length); + const xy = BigInt(parseInt(quadkey, 4) || 0); + return (0x4000000000000000n | + (1n << 59n) | + (z << 52n) | + (xy << (52n - z*2n)) | + (0xFFFFFFFFFFFFFn >> (z*2n))).toString(); +"""; + +CREATE OR REPLACE FUNCTION `@@BQ_DATASET@@.QUADBIN_FROMQUADKEY` +(quadkey STRING) +RETURNS INT64 +AS ( + CAST(`@@BQ_DATASET@@.__QUADBIN_FROMQUADKEY`(quadkey) AS INT64) +); diff --git a/clouds/bigquery/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql b/clouds/bigquery/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql new file mode 100644 index 000000000..8040370e8 --- /dev/null +++ b/clouds/bigquery/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql @@ -0,0 +1,15 @@ +---------------------------- +-- Copyright (C) 2022 CARTO +---------------------------- + +CREATE OR REPLACE FUNCTION `@@BQ_DATASET@@.QUADBIN_TOQUADKEY` +(quadbin INT64) +RETURNS STRING +DETERMINISTIC +LANGUAGE js +AS """ + const q = BigInt(quadbin); + const z = (q >> 52n) & 0x1Fn; + const xy = (q & 0xFFFFFFFFFFFFFn) >> (52n - z*2n); + return (z == 0) ? '' : xy.toString(4).padStart(Number(z), '0'); +"""; diff --git a/clouds/bigquery/modules/test/quadbin/QUADBIN_FROMQUADKEY.test.js b/clouds/bigquery/modules/test/quadbin/QUADBIN_FROMQUADKEY.test.js new file mode 100644 index 000000000..cc4481553 --- /dev/null +++ b/clouds/bigquery/modules/test/quadbin/QUADBIN_FROMQUADKEY.test.js @@ -0,0 +1,13 @@ +const { runQuery } = require('../../../common/test-utils'); + +test('QUADBIN_FROMQUADKEY should work', async () => { + const query = `SELECT [ + CAST(\`@@BQ_DATASET@@.QUADBIN_FROMQUADKEY\`('') AS STRING), + CAST(\`@@BQ_DATASET@@.QUADBIN_FROMQUADKEY\`('0') AS STRING), + CAST(\`@@BQ_DATASET@@.QUADBIN_FROMQUADKEY\`('13020310') AS STRING), + CAST(\`@@BQ_DATASET@@.QUADBIN_FROMQUADKEY\`('0231001222') AS STRING) + ] AS output`; + const rows = await runQuery(query); + expect(rows.length).toEqual(1); + expect(rows[0].output).toEqual(['5192650370358181887', '5193776270265024511', '5226184719091105791', '5233974874938015743']); +}); \ No newline at end of file diff --git a/clouds/bigquery/modules/test/quadbin/QUADBIN_TOQUADKEY.test.js b/clouds/bigquery/modules/test/quadbin/QUADBIN_TOQUADKEY.test.js new file mode 100644 index 000000000..10175c062 --- /dev/null +++ b/clouds/bigquery/modules/test/quadbin/QUADBIN_TOQUADKEY.test.js @@ -0,0 +1,13 @@ +const { runQuery } = require('../../../common/test-utils'); + +test('QUADBIN_TOQUADKEY should work', async () => { + const query = `SELECT [ + \`@@BQ_DATASET@@.QUADBIN_TOQUADKEY\`(5192650370358181887), + \`@@BQ_DATASET@@.QUADBIN_TOQUADKEY\`(5193776270265024511), + \`@@BQ_DATASET@@.QUADBIN_TOQUADKEY\`(5226184719091105791), + \`@@BQ_DATASET@@.QUADBIN_TOQUADKEY\`(5233974874938015743) + ] AS output`; + const rows = await runQuery(query); + expect(rows.length).toEqual(1); + expect(rows[0].output).toEqual(['', '0', '13020310', '0231001222']); +}); \ No newline at end of file diff --git a/clouds/bigquery/version b/clouds/bigquery/version index 6c6aa7cb0..0ea3a944b 100644 --- a/clouds/bigquery/version +++ b/clouds/bigquery/version @@ -1 +1 @@ -0.1.0 \ No newline at end of file +0.2.0 diff --git a/clouds/databricks/CHANGELOG.md b/clouds/databricks/CHANGELOG.md index d59b4dedb..f797ff8dc 100644 --- a/clouds/databricks/CHANGELOG.md +++ b/clouds/databricks/CHANGELOG.md @@ -2,257 +2,6 @@ CARTO Analytics Toolbox Core for Databricks. -All notable changes to this project will be documented in this file. +All notable commits to this project will be documented in this file. -The format is inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - -## [0.1.0] - 2022-11 - -### All modules - -#### New - -- Create release workflows - -#### Improvement - -- Adapt to Semver - -## [2022.10.19] - 2022-10-19 - -### All modules - -#### New - -- Tasks to build installation packages - -#### Improvement - -- Versioning uses YYYY.MM.DD format based on date now - -## [2022.09.21] - 2022-09-21 - -### All modules - -#### New - -- Add VERSION_CORE function - -### Accessors - -#### Improvement - -- Change type returned by ST_X and ST_Y to Double - -## [2022.09.20] - 2022-09-20 - -### All modules - -#### Improvement - -- Set default compression codec to snappy - -## [2022.09.16] - 2022-09-16 - -### All modules - -#### New - -- Add headers to functions that didn't have -- Add make rule to publis artifact in local and sonatype -- Add make rule to check and create headers - -#### Improvement - -- change makefiles and sbt file to prepare the at advance - -### Module parsers - -### Fixed - -- Fix the parser tests that had old user function names - -## [2022.09.15] - 2022-09-15 - -### All modules - -#### Improvement - -- The XY precission of the TWKBWriter is set to 5. - -### Module formatters - -#### Fix - -- Fix the doc of the transformers functions ST_ASLATLONTEXT and ST_ASTEXT. - -## [2022.09.06] - 2022-09-06 - -### Module accessors - -#### Fix - -- Fix the bug in ST_COORDDIM that was adding z coordinate to geometries. - -### Module indexing - -#### Fix - -- Fix the cast ClassCastException in ST_GEOMREPROJECT. - -## [2022.09.01] - 2022-09-01 - -### All modules - -#### Improvement - -- Refactor databricks cloud to adapt it to the new cloud structure - -## [2022.08.29] - 2022-08-29 - -### Module indexing - -#### New - -- Add ST_CRSFROMTEXT function. -- Add ST_EXTENTFROMGEOM function. -- Add ST_EXTENTTOGEOM function. -- Add ST_GEOMREPROJECT function. -- Add ST_MAKEEXTENT function. -- Add ST_PARTITIONCENTROID function. -- Add ST_Z2LATLON function. - -### Module formatters - -#### New - -- Add ST_ASTWKB function. - -### Module parsers - -#### New - -- Add ST_GEOMFROMWKT function. - -### Module predicates - -#### New - -- Add ST_COVERS function. - -### Module transformations - -#### New - -- Add ST_BUFFERPOINT function. -- Add ST_DIFFERENCE function. -- Add ST_SIMPLIFY function. - -## [2022.08.19] - 2022-08-19 - -### Module accessors - -#### New - -- Add ST_COORDDIM function. -- Add ST_DIMENSION function. -- Add ST_ENVELOPE function. -- Add ST_GEOMETRYN function. -- Add ST_ISCLOSED function. -- Add ST_ISCOLLECTION function. -- Add ST_ISEMPTY function. -- Add ST_ISGEOMFIELD function. -- Add ST_ISRING function. -- Add ST_ISSIMPLE function. -- Add ST_ISVALID function. -- Add ST_NUMGEOMETRIES function. -- Add ST_NUMPOINTS function. -- Add ST_POINTN function. -- Add ST_Y function. -- Add ST_X function. - -### Module constructors - -#### New - -- Add ST_MAKEBBOX function. -- Add ST_MAKEBOX2D function. -- Add ST_MAKELINE function. -- Add ST_MAKEPOINT function. -- Add ST_MAKEPOINTM function. -- Add ST_MAKEPOLYGON function. -- Add ST_POINT function. - -### Module formatters - -#### New - -- Add ST_ASBINARY function. -- Add ST_ASGEOHASH function. -- Add ST_ASGEOJSON function. -- Add ST_ASLATLONTEXT function. -- Add ST_ASTEXT function. -- Add ST_BYTEARRAY function. -- Add ST_CASTTOGEOMETRY function. -- Add ST_CASTTOLINESTRING function. -- Add ST_CASTTOPOINT function. -- Add ST_CASTTOPOLYGON function. - -### Module measurements - -#### New - -- Add ST_AREA function. -- Add ST_DISTANCE function. -- Add ST_DISTANCESPHERE function. -- Add ST_LENGTH function. -- Add ST_LENGTHSPHERE function. - -### Module parsers - -#### New - -- Add ST_BOX2DFROMGEOHASH function. -- Add ST_GEOMETRYFROMTEXT function. -- Add ST_GEOMFROMGEOHASH function. -- Add ST_GEOMFROMGEOJSON function. -- Add ST_GEOMFROMWKB function. -- Add ST_GEOMFROMWKT function. -- Add ST_LINEFROMTEXT function. -- Add ST_MLINEFROMTEXT function. -- Add ST_MPOINTFROMTEXT function. -- Add ST_MPOLYFROMTEXT function. -- Add ST_POINTFROMGEOHASH function. -- Add ST_POINTFROMTEXT function. -- Add ST_POINTFROMWKB function. -- Add ST_POLYGONFROMTEXT function. - -### Module predicates - -#### New - -- Add ST_CONTAINS function. -- Add ST_CROSSES function. -- Add ST_DISJOINT function. -- Add ST_EQUALS function. -- Add ST_INTERSECTS function. -- Add ST_OVERLAPS function. -- Add ST_RELATE function. -- Add ST_RELATEBOOL function. -- Add ST_TOUCHES function. -- Add ST_WITHIN function. - -### Module transformations - -#### New - -- Add ST_ANTIMERIDIANSAFEGEOM function. -- Add ST_BOUNDARY function. -- Add ST_CENTROID function. -- Add ST_CLOSESTPOINT function. -- Add ST_CONVEXHULL function. -- Add ST_EXTERIORRING function. -- Add ST_IDLSAFEGEOM function. -- Add ST_INTERIORRINGN function. -- Add ST_INTERSECTION function. -- Add ST_TRANSLATE function. +## [0.1.1] diff --git a/clouds/databricks/CHANGELOG.old.md b/clouds/databricks/CHANGELOG.old.md new file mode 100644 index 000000000..02d399a46 --- /dev/null +++ b/clouds/databricks/CHANGELOG.old.md @@ -0,0 +1,244 @@ +# Changelog [old] + +CARTO Analytics Toolbox Core for Databricks. + +The format is inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + +## [2022.10.19] - 2022-10-19 + +### All modules + +#### Feature + +- Tasks to build installation packages + +#### Improvement + +- Versioning uses YYYY.MM.DD format based on date now + +## [2022.09.21] - 2022-09-21 + +### All modules + +#### Feature + +- Add VERSION_CORE function + +### Accessors + +#### Improvement + +- Change type returned by ST_X and ST_Y to Double + +## [2022.09.20] - 2022-09-20 + +### All modules + +#### Improvement + +- Set default compression codec to snappy + +## [2022.09.16] - 2022-09-16 + +### All modules + +#### Feature + +- Add headers to functions that didn't have +- Add make rule to publis artifact in local and sonatype +- Add make rule to check and create headers + +#### Improvement + +- change makefiles and sbt file to prepare the at advance + +### Module parsers + +### Fixed + +- Fix the parser tests that had old user function names + +## [2022.09.15] - 2022-09-15 + +### All modules + +#### Improvement + +- The XY precission of the TWKBWriter is set to 5. + +### Module formatters + +#### Fix + +- Fix the doc of the transformers functions ST_ASLATLONTEXT and ST_ASTEXT. + +## [2022.09.06] - 2022-09-06 + +### Module accessors + +#### Fix + +- Fix the bug in ST_COORDDIM that was adding z coordinate to geometries. + +### Module indexing + +#### Fix + +- Fix the cast ClassCastException in ST_GEOMREPROJECT. + +## [2022.09.01] - 2022-09-01 + +### All modules + +#### Improvement + +- Refactor databricks cloud to adapt it to the new cloud structure + +## [2022.08.29] - 2022-08-29 + +### Module indexing + +#### Feature + +- Add ST_CRSFROMTEXT function. +- Add ST_EXTENTFROMGEOM function. +- Add ST_EXTENTTOGEOM function. +- Add ST_GEOMREPROJECT function. +- Add ST_MAKEEXTENT function. +- Add ST_PARTITIONCENTROID function. +- Add ST_Z2LATLON function. + +### Module formatters + +#### Feature + +- Add ST_ASTWKB function. + +### Module parsers + +#### Feature + +- Add ST_GEOMFROMWKT function. + +### Module predicates + +#### Feature + +- Add ST_COVERS function. + +### Module transformations + +#### Feature + +- Add ST_BUFFERPOINT function. +- Add ST_DIFFERENCE function. +- Add ST_SIMPLIFY function. + +## [2022.08.19] - 2022-08-19 + +### Module accessors + +#### Feature + +- Add ST_COORDDIM function. +- Add ST_DIMENSION function. +- Add ST_ENVELOPE function. +- Add ST_GEOMETRYN function. +- Add ST_ISCLOSED function. +- Add ST_ISCOLLECTION function. +- Add ST_ISEMPTY function. +- Add ST_ISGEOMFIELD function. +- Add ST_ISRING function. +- Add ST_ISSIMPLE function. +- Add ST_ISVALID function. +- Add ST_NUMGEOMETRIES function. +- Add ST_NUMPOINTS function. +- Add ST_POINTN function. +- Add ST_Y function. +- Add ST_X function. + +### Module constructors + +#### Feature + +- Add ST_MAKEBBOX function. +- Add ST_MAKEBOX2D function. +- Add ST_MAKELINE function. +- Add ST_MAKEPOINT function. +- Add ST_MAKEPOINTM function. +- Add ST_MAKEPOLYGON function. +- Add ST_POINT function. + +### Module formatters + +#### Feature + +- Add ST_ASBINARY function. +- Add ST_ASGEOHASH function. +- Add ST_ASGEOJSON function. +- Add ST_ASLATLONTEXT function. +- Add ST_ASTEXT function. +- Add ST_BYTEARRAY function. +- Add ST_CASTTOGEOMETRY function. +- Add ST_CASTTOLINESTRING function. +- Add ST_CASTTOPOINT function. +- Add ST_CASTTOPOLYGON function. + +### Module measurements + +#### Feature + +- Add ST_AREA function. +- Add ST_DISTANCE function. +- Add ST_DISTANCESPHERE function. +- Add ST_LENGTH function. +- Add ST_LENGTHSPHERE function. + +### Module parsers + +#### Feature + +- Add ST_BOX2DFROMGEOHASH function. +- Add ST_GEOMETRYFROMTEXT function. +- Add ST_GEOMFROMGEOHASH function. +- Add ST_GEOMFROMGEOJSON function. +- Add ST_GEOMFROMWKB function. +- Add ST_GEOMFROMWKT function. +- Add ST_LINEFROMTEXT function. +- Add ST_MLINEFROMTEXT function. +- Add ST_MPOINTFROMTEXT function. +- Add ST_MPOLYFROMTEXT function. +- Add ST_POINTFROMGEOHASH function. +- Add ST_POINTFROMTEXT function. +- Add ST_POINTFROMWKB function. +- Add ST_POLYGONFROMTEXT function. + +### Module predicates + +#### Feature + +- Add ST_CONTAINS function. +- Add ST_CROSSES function. +- Add ST_DISJOINT function. +- Add ST_EQUALS function. +- Add ST_INTERSECTS function. +- Add ST_OVERLAPS function. +- Add ST_RELATE function. +- Add ST_RELATEBOOL function. +- Add ST_TOUCHES function. +- Add ST_WITHIN function. + +### Module transformations + +#### Feature + +- Add ST_ANTIMERIDIANSAFEGEOM function. +- Add ST_BOUNDARY function. +- Add ST_CENTROID function. +- Add ST_CLOSESTPOINT function. +- Add ST_CONVEXHULL function. +- Add ST_EXTERIORRING function. +- Add ST_IDLSAFEGEOM function. +- Add ST_INTERIORRINGN function. +- Add ST_INTERSECTION function. +- Add ST_TRANSLATE function. diff --git a/clouds/databricks/version b/clouds/databricks/version index 6c6aa7cb0..17e51c385 100644 --- a/clouds/databricks/version +++ b/clouds/databricks/version @@ -1 +1 @@ -0.1.0 \ No newline at end of file +0.1.1 diff --git a/clouds/postgres/CHANGELOG.md b/clouds/postgres/CHANGELOG.md index 8bf44dcde..b236f98f7 100644 --- a/clouds/postgres/CHANGELOG.md +++ b/clouds/postgres/CHANGELOG.md @@ -2,40 +2,8 @@ CARTO Analytics Toolbox Core for Postgres. -All notable changes to this project will be documented in this file. +All notable commits to this project will be documented in this file. -The format is inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [0.2.0] - 2022-12-27 -## [0.1.0] - 2022-11 - -### All modules - -#### New - -- Create release workflows - -#### Improvement - -- Adapt to Semver - -## [2022.06.24] - 2022-06-24 - -### Module quadbin - -#### New - -- Add QUADBIN_BBOX function. -- Add QUADBIN_BOUNDARY function. -- Add QUADBIN_CENTER function. -- Add QUADBIN_FROMGEOGPOINT function. -- Add QUADBIN_FROMLONGLAT function. -- Add QUADBIN_FROMZXY function. -- Add QUADBIN_ISVALID function. -- Add QUADBIN_KRING function. -- Add QUADBIN_KRING_DISTANCES function. -- Add QUADBIN_POLYFILL function. -- Add QUADBIN_RESOLUTION function. -- Add QUADBIN_SIBLING function. -- Add QUADBIN_TOCHILDREN function. -- Add QUADBIN_TOPARENT function. -- Add QUADBIN_TOZXY function. +- feat(quadbin): add quadbin/quadkey conversion functions (#370) diff --git a/clouds/postgres/CHANGELOG.old.md b/clouds/postgres/CHANGELOG.old.md new file mode 100644 index 000000000..f4b6e14ef --- /dev/null +++ b/clouds/postgres/CHANGELOG.old.md @@ -0,0 +1,27 @@ +# Changelog [old] + +CARTO Analytics Toolbox Core for Postgres. + +The format is inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + +## [2022.06.24] - 2022-06-24 + +### Module quadbin + +#### Feature + +- Add QUADBIN_BBOX function. +- Add QUADBIN_BOUNDARY function. +- Add QUADBIN_CENTER function. +- Add QUADBIN_FROMGEOGPOINT function. +- Add QUADBIN_FROMLONGLAT function. +- Add QUADBIN_FROMZXY function. +- Add QUADBIN_ISVALID function. +- Add QUADBIN_KRING function. +- Add QUADBIN_KRING_DISTANCES function. +- Add QUADBIN_POLYFILL function. +- Add QUADBIN_RESOLUTION function. +- Add QUADBIN_SIBLING function. +- Add QUADBIN_TOCHILDREN function. +- Add QUADBIN_TOPARENT function. +- Add QUADBIN_TOZXY function. diff --git a/clouds/postgres/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md b/clouds/postgres/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md new file mode 100644 index 000000000..1dea88a34 --- /dev/null +++ b/clouds/postgres/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md @@ -0,0 +1,22 @@ +### QUADBIN_FROMQUADKEY + +{{% bannerNote type="code" %}} +carto.QUADBIN_FROMQUADKEY(quadkey) +{{%/ bannerNote %}} + +**Description** + +Compute a quadbin index from a quadkey. + +* `quadkey`: `TEXT` Quadkey representation of the index. + +**Return type** + +`BIGINT` + +**Example** + +```sql +SELECT carto.QUADBIN_FROMQUADKEY('0231001222'); +-- 5233974874938015743 +``` diff --git a/clouds/postgres/modules/doc/quadbin/QUADBIN_TOQUADKEY.md b/clouds/postgres/modules/doc/quadbin/QUADBIN_TOQUADKEY.md new file mode 100644 index 000000000..c4c99101f --- /dev/null +++ b/clouds/postgres/modules/doc/quadbin/QUADBIN_TOQUADKEY.md @@ -0,0 +1,22 @@ +### QUADBIN_TOQUADKEY + +{{% bannerNote type="code" %}} +carto.QUADBIN_TOQUADKEY(quadbin) +{{%/ bannerNote %}} + +**Description** + +Compute a quadkey from a quadbin index. + +* `quadbin`: `BIGINT` Quadbin index. + +**Return type** + +`TEXT` + +**Example** + +```sql +SELECT carto.QUADBIN_TOQUADKEY(5233974874938015743); +-- '0231001222' +``` diff --git a/clouds/postgres/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql b/clouds/postgres/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql new file mode 100644 index 000000000..553eb2665 --- /dev/null +++ b/clouds/postgres/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql @@ -0,0 +1,45 @@ +---------------------------- +-- Copyright (C) 2022 CARTO +---------------------------- + +CREATE OR REPLACE FUNCTION @@PG_SCHEMA@@.__CONV_BASE4_BASE10( + s TEXT +) +RETURNS BIGINT AS +$$ +DECLARE + result BIGINT = 0; + digit INT; + power INT = 1; + i INT; +BEGIN + FOR i IN 1 .. length(s) LOOP + digit = substr(s, length(s) - i + 1, 1)::INT; + result = result + digit * power; + power = power * 4; + END LOOP; + RETURN result; +END; +$$ +LANGUAGE plpgsql IMMUTABLE PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION @@PG_SCHEMA@@.QUADBIN_FROMQUADKEY( + quadkey TEXT +) +RETURNS BIGINT +AS +$BODY$ + WITH __inter AS ( + SELECT + LENGTH(quadkey) AS z, + @@PG_SCHEMA@@.__CONV_BASE4_BASE10(quadkey) AS xy + ) + SELECT + 4611686018427387904 + | (1::BIGINT << 59) + | (z::BIGINT << 52) + | (xy::BIGINT << (52 - (z << 1))) + | (4503599627370495 >> (z << 1)) + FROM __inter; +$BODY$ +LANGUAGE sql IMMUTABLE PARALLEL SAFE; diff --git a/clouds/postgres/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql b/clouds/postgres/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql new file mode 100644 index 000000000..7a708bcc9 --- /dev/null +++ b/clouds/postgres/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql @@ -0,0 +1,49 @@ +---------------------------- +-- Copyright (C) 2022 CARTO +---------------------------- + +CREATE OR REPLACE FUNCTION @@PG_SCHEMA@@.__CONV_BASE10_BASE4( + i BIGINT +) +RETURNS TEXT AS +$$ +DECLARE + result TEXT = ''; + digit INT; +BEGIN + WHILE i > 0 LOOP + digit = i % 4; + result = digit::TEXT || result; + i = i / 4; + END LOOP; + RETURN result; +END; +$$ +LANGUAGE plpgsql IMMUTABLE PARALLEL SAFE; + + +CREATE OR REPLACE FUNCTION @@PG_SCHEMA@@.QUADBIN_TOQUADKEY( + quadbin BIGINT +) +RETURNS TEXT +AS +$BODY$ + WITH __z AS ( + SELECT + ((quadbin >> 52) & 31)::INT AS z + ), + __xy AS ( + SELECT + z, + ((quadbin & 4503599627370495) >> (52 - z * 2)) AS xy + FROM __z + ) + SELECT + CASE + WHEN z = 0 THEN '' + ELSE + LPAD(@@PG_SCHEMA@@.__CONV_BASE10_BASE4(xy), z, '0') + END + FROM __xy; +$BODY$ +LANGUAGE sql IMMUTABLE PARALLEL SAFE; diff --git a/clouds/postgres/modules/test/quadbin/test_QUADBIN_FROMQUADKEY.py b/clouds/postgres/modules/test/quadbin/test_QUADBIN_FROMQUADKEY.py new file mode 100644 index 000000000..13437778e --- /dev/null +++ b/clouds/postgres/modules/test/quadbin/test_QUADBIN_FROMQUADKEY.py @@ -0,0 +1,17 @@ +import pytest +from test_utils import run_query + +input = [ + # quadkey, quadbin + ('', 5192650370358181887), + ('0', 5193776270265024511), + ('13020310', 5226184719091105791), + ('0231001222', 5233974874938015743), +] + + +@pytest.mark.parametrize('quadkey, quadbin', input) +def test_quadbin_fromquadkey(quadkey, quadbin): + result = run_query(f"SELECT @@PG_SCHEMA@@.QUADBIN_FROMQUADKEY('{quadkey}')") + assert len(result[0]) == 1 + assert result[0][0] == quadbin diff --git a/clouds/postgres/modules/test/quadbin/test_QUADBIN_TOQUADKEY.py b/clouds/postgres/modules/test/quadbin/test_QUADBIN_TOQUADKEY.py new file mode 100644 index 000000000..4cc784ed9 --- /dev/null +++ b/clouds/postgres/modules/test/quadbin/test_QUADBIN_TOQUADKEY.py @@ -0,0 +1,17 @@ +import pytest +from test_utils import run_query + +input = [ + # quadkey, quadbin + ('', 5192650370358181887), + ('0', 5193776270265024511), + ('13020310', 5226184719091105791), + ('0231001222', 5233974874938015743), +] + + +@pytest.mark.parametrize('quadkey, quadbin', input) +def test_quadbin_toquadkey(quadkey, quadbin): + result = run_query(f'SELECT @@PG_SCHEMA@@.QUADBIN_TOQUADKEY({quadbin})') + assert len(result[0]) == 1 + assert result[0][0] == quadkey diff --git a/clouds/postgres/version b/clouds/postgres/version index 6c6aa7cb0..0ea3a944b 100644 --- a/clouds/postgres/version +++ b/clouds/postgres/version @@ -1 +1 @@ -0.1.0 \ No newline at end of file +0.2.0 diff --git a/clouds/redshift/CHANGELOG.md b/clouds/redshift/CHANGELOG.md index dfa2431fa..02ce8b1f8 100644 --- a/clouds/redshift/CHANGELOG.md +++ b/clouds/redshift/CHANGELOG.md @@ -2,230 +2,8 @@ CARTO Analytics Toolbox Core for Redshift. -All notable changes to this project will be documented in this file. +All notable commits to this project will be documented in this file. -The format is inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [0.2.0] - 2022-12-27 -## [0.1.0] - 2022-11 - -### All modules - -#### New - -- Create release workflows - -#### Improvement - -- Adapt to Semver - -## [2022.10.07] - 2022-10-07 - -### Module clustering - -#### New - -- Move ST_CLUSTERKMEANS function to core. -- Move CREATE_CLUSTERKMEANS procedure to core. - -### Module random - -#### New - -- Move ST_GENERATEPOINTS function to core. - -## [2022.08.19] - 2022-08-19 - -### Module s2 - -#### Fix - -- Fix S2_BOUNDARY inverted coordinates. - -## [2022.07.14] - 2022-07-14 - -### Module quadbin - -#### Improvement - -- Update functions volatility. -- QUADBIN_FROMZXY accepting BIGINTs as params instead of INTs. - -## [2022.07.08] - 2022-07-08 - -### Module quadbin - -#### Improvement - -- Release SQL version of QUADBIN_TOZXY. - -## [2022.06.24] - 2022-06-24 - -### Module quadbin - -#### New - -- Add QUADBIN_BBOX function. -- Add QUADBIN_BOUNDARY function. -- Add QUADBIN_CENTER function. -- Add QUADBIN_FROMGEOGPOINT function. -- Add QUADBIN_FROMLONGLAT function. -- Add QUADBIN_FROMZXY function. -- Add QUADBIN_ISVALID function. -- Add QUADBIN_KRING function. -- Add QUADBIN_KRING_DISTANCES function. -- Add QUADBIN_POLYFILL function. -- Add QUADBIN_RESOLUTION function. -- Add QUADBIN_SIBLING function. -- Add QUADBIN_TOCHILDREN function. -- Add QUADBIN_TOPARENT function. -- Add QUADBIN_TOZXY function. - -## [2021.12.16] - 2021-12-16 - -### Module transformations - -#### Fix - -- Refactor of internal __ST_GEOMFROMGEOJSON function to avoid UDFs nestig Redshift limitations - -## [2021.12.10] - 2021-12-10 - -### Module constructors - -#### Improvement - -- Deployment schema "carto" instead of "constructors". - -#### Removed - -- Remove VERSION function. - -### Module placekey - -#### Improvement - -- Deployment schema "carto" instead of "placekey". -- Rename H3_ASPLACEKEY function to PLACEKEY_FROMH3. -- Rename PLACEKEY_ASH3 function to PLACEKEY_TOH3. -- Rename ISVALID function to PLACEKEY_ISVALID. - -#### Removed - -- Remove VERSION function. - -### Module processing - -#### Improvement - -- Deployment schema "carto" instead of "processing". - -#### Removed - -- Remove VERSION function. - -### Module s2 - -#### Improvement - -- Deployment schema "carto" instead of "s2". -- Rename HILBERTQUADKEY_FROMID function to S2_TOHILBERTQUADKEY. -- Rename ID_FROMHILBERTQUADKEY function to S2_FROMHILBERTQUADKEY. -- Rename ID_FROMTOKEN function to S2_FROMTOKEN. -- Rename ID_FROMUINT64REPR function to S2_FROMUINT64REPR. -- Rename LONGLAT_ASID function to S2_FROMLONGLAT. -- Rename RESOLUTION function to S2_RESOLUTION. -- Rename ST_ASID function to S2_FROMGEOGPOINT. -- Rename ST_ASID_POLYFILL_BBOX function to S2_POLYFILL_BBOX. -- Rename ST_BOUNDARY function to S2_BOUNDARY. -- Rename TOCHILDREN function to S2_TOCHILDREN. -- Rename TOKEN_FROMID function to S2_TOTOKEN. -- Rename TOPARENT function to S2_TOPARENT. -- Rename UINT64REPR_FROMID function to S2_TOUINT64REPR. - -#### Removed - -- Remove VERSION function. - -### Module transformations - -#### Improvement - -- Deployment schema "carto" instead of "transformations". - -#### Removed - -- Remove VERSION function. - -## [2021.10.06] - 2021-10-06 - -### Module processing - -#### New - -- Create processing module. -- Add VERSION function. -- Add ST_POLYGONIZE function. -- Add ST_DELAUNAYLINES function. -- Add ST_DELAUNAYPOLYGONS function. -- Add ST_VORONOILINES function. -- Add ST_VORONOIPOLYGONS function. - -### Module transformations - -#### New - -- Create transformations module. -- Add VERSION function. -- Add ST_CENTERMEAN function. -- Add ST_CENTROID function. -- Add ST_CENTEROFMASS function -- Add ST_CENTERMEDIAN function -- Add ST_GREATCIRCLE function -- Add ST_DESTINATION function - -## [2021.09.23] - 2021-09-23 - -### Module s2 - -#### New - -- Create s2 module. -- Add HILBERTQUADKEY_FROMID function. -- Add ID_FROMHILBERTQUADKEY function. -- Add ID_FROMTOKEN function. -- Add ID_FROMUINT64REPR function. -- Add LONGLAT_ASID function. -- Add RESOLUTION function. -- Add ST_ASID function. -- Add ST_ASID_POLYFILL_BBOX function. -- Add ST_BOUNDARY function. -- Add TOCHILDREN function. -- Add TOKEN_FROMID function. -- Add TOPARENT function. -- Add UINT64REPR_FROMID function. -- Add VERSION function. - -## [2021.09.17] - 2021-09-17 - -### Module constructors - -#### New - -- Create constructors module. -- Add ST_BEZIERSPLINE function. -- Add ST_MAKEELLIPSE function. -- Add ST_MAKEENVELOPE function. -- Add ST_TILEENVELOPE function. -- Add VERSION function. - -## [2021.09.07] - 2021-09-07 - -### Module placekey - -#### New - -- Create placekey module. -- Add H3_ASPLACEKEY function. -- Add PLACEKEY_ASH3 function. -- Add ISVALID function. -- Add VERSION function. +- feat(quadbin): add quadbin/quadkey conversion functions (#370) diff --git a/clouds/redshift/CHANGELOG.old.md b/clouds/redshift/CHANGELOG.old.md new file mode 100644 index 000000000..b7a32ccdb --- /dev/null +++ b/clouds/redshift/CHANGELOG.old.md @@ -0,0 +1,217 @@ +# Changelog [old] + +CARTO Analytics Toolbox Core for Redshift. + +The format is inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + +## [2022.10.07] - 2022-10-07 + +### Module clustering + +#### Feature + +- Move ST_CLUSTERKMEANS function to core. +- Move CREATE_CLUSTERKMEANS procedure to core. + +### Module random + +#### Feature + +- Move ST_GENERATEPOINTS function to core. + +## [2022.08.19] - 2022-08-19 + +### Module s2 + +#### Fix + +- Fix S2_BOUNDARY inverted coordinates. + +## [2022.07.14] - 2022-07-14 + +### Module quadbin + +#### Improvement + +- Update functions volatility. +- QUADBIN_FROMZXY accepting BIGINTs as params instead of INTs. + +## [2022.07.08] - 2022-07-08 + +### Module quadbin + +#### Improvement + +- Release SQL version of QUADBIN_TOZXY. + +## [2022.06.24] - 2022-06-24 + +### Module quadbin + +#### Feature + +- Add QUADBIN_BBOX function. +- Add QUADBIN_BOUNDARY function. +- Add QUADBIN_CENTER function. +- Add QUADBIN_FROMGEOGPOINT function. +- Add QUADBIN_FROMLONGLAT function. +- Add QUADBIN_FROMZXY function. +- Add QUADBIN_ISVALID function. +- Add QUADBIN_KRING function. +- Add QUADBIN_KRING_DISTANCES function. +- Add QUADBIN_POLYFILL function. +- Add QUADBIN_RESOLUTION function. +- Add QUADBIN_SIBLING function. +- Add QUADBIN_TOCHILDREN function. +- Add QUADBIN_TOPARENT function. +- Add QUADBIN_TOZXY function. + +## [2021.12.16] - 2021-12-16 + +### Module transformations + +#### Fix + +- Refactor of internal __ST_GEOMFROMGEOJSON function to avoid UDFs nestig Redshift limitations + +## [2021.12.10] - 2021-12-10 + +### Module constructors + +#### Improvement + +- Deployment schema "carto" instead of "constructors". + +#### Removed + +- Remove VERSION function. + +### Module placekey + +#### Improvement + +- Deployment schema "carto" instead of "placekey". +- Rename H3_ASPLACEKEY function to PLACEKEY_FROMH3. +- Rename PLACEKEY_ASH3 function to PLACEKEY_TOH3. +- Rename ISVALID function to PLACEKEY_ISVALID. + +#### Removed + +- Remove VERSION function. + +### Module processing + +#### Improvement + +- Deployment schema "carto" instead of "processing". + +#### Removed + +- Remove VERSION function. + +### Module s2 + +#### Improvement + +- Deployment schema "carto" instead of "s2". +- Rename HILBERTQUADKEY_FROMID function to S2_TOHILBERTQUADKEY. +- Rename ID_FROMHILBERTQUADKEY function to S2_FROMHILBERTQUADKEY. +- Rename ID_FROMTOKEN function to S2_FROMTOKEN. +- Rename ID_FROMUINT64REPR function to S2_FROMUINT64REPR. +- Rename LONGLAT_ASID function to S2_FROMLONGLAT. +- Rename RESOLUTION function to S2_RESOLUTION. +- Rename ST_ASID function to S2_FROMGEOGPOINT. +- Rename ST_ASID_POLYFILL_BBOX function to S2_POLYFILL_BBOX. +- Rename ST_BOUNDARY function to S2_BOUNDARY. +- Rename TOCHILDREN function to S2_TOCHILDREN. +- Rename TOKEN_FROMID function to S2_TOTOKEN. +- Rename TOPARENT function to S2_TOPARENT. +- Rename UINT64REPR_FROMID function to S2_TOUINT64REPR. + +#### Removed + +- Remove VERSION function. + +### Module transformations + +#### Improvement + +- Deployment schema "carto" instead of "transformations". + +#### Removed + +- Remove VERSION function. + +## [2021.10.06] - 2021-10-06 + +### Module processing + +#### Feature + +- Create processing module. +- Add VERSION function. +- Add ST_POLYGONIZE function. +- Add ST_DELAUNAYLINES function. +- Add ST_DELAUNAYPOLYGONS function. +- Add ST_VORONOILINES function. +- Add ST_VORONOIPOLYGONS function. + +### Module transformations + +#### Feature + +- Create transformations module. +- Add VERSION function. +- Add ST_CENTERMEAN function. +- Add ST_CENTROID function. +- Add ST_CENTEROFMASS function +- Add ST_CENTERMEDIAN function +- Add ST_GREATCIRCLE function +- Add ST_DESTINATION function + +## [2021.09.23] - 2021-09-23 + +### Module s2 + +#### Feature + +- Create s2 module. +- Add HILBERTQUADKEY_FROMID function. +- Add ID_FROMHILBERTQUADKEY function. +- Add ID_FROMTOKEN function. +- Add ID_FROMUINT64REPR function. +- Add LONGLAT_ASID function. +- Add RESOLUTION function. +- Add ST_ASID function. +- Add ST_ASID_POLYFILL_BBOX function. +- Add ST_BOUNDARY function. +- Add TOCHILDREN function. +- Add TOKEN_FROMID function. +- Add TOPARENT function. +- Add UINT64REPR_FROMID function. +- Add VERSION function. + +## [2021.09.17] - 2021-09-17 + +### Module constructors + +#### Feature + +- Create constructors module. +- Add ST_BEZIERSPLINE function. +- Add ST_MAKEELLIPSE function. +- Add ST_MAKEENVELOPE function. +- Add ST_TILEENVELOPE function. +- Add VERSION function. + +## [2021.09.07] - 2021-09-07 + +### Module placekey + +#### Feature + +- Create placekey module. +- Add H3_ASPLACEKEY function. +- Add PLACEKEY_ASH3 function. +- Add ISVALID function. +- Add VERSION function. diff --git a/clouds/redshift/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md b/clouds/redshift/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md new file mode 100644 index 000000000..a6b9aae89 --- /dev/null +++ b/clouds/redshift/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md @@ -0,0 +1,22 @@ +### QUADBIN_FROMQUADKEY + +{{% bannerNote type="code" %}} +carto.QUADBIN_FROMQUADKEY(quadkey) +{{%/ bannerNote %}} + +**Description** + +Compute a quadbin index from a quadkey. + +* `quadkey`: `VARCHAR(MAX)` Quadkey representation of the index. + +**Return type** + +`BIGINT` + +**Example** + +```sql +SELECT carto.QUADBIN_FROMQUADKEY('0231001222'); +-- 5233974874938015743 +``` diff --git a/clouds/redshift/modules/doc/quadbin/QUADBIN_RESOLUTION.md b/clouds/redshift/modules/doc/quadbin/QUADBIN_RESOLUTION.md index ee4585228..9fb4ff9f0 100644 --- a/clouds/redshift/modules/doc/quadbin/QUADBIN_RESOLUTION.md +++ b/clouds/redshift/modules/doc/quadbin/QUADBIN_RESOLUTION.md @@ -8,7 +8,7 @@ carto.QUADBIN_RESOLUTION(quadbin) Returns the resolution of the input Quadbin. -* `quadbin`: `INT64` Quadbin from which to get the resolution. +* `quadbin`: `BIGINT` Quadbin from which to get the resolution. **Return type** diff --git a/clouds/redshift/modules/doc/quadbin/QUADBIN_TOQUADKEY.md b/clouds/redshift/modules/doc/quadbin/QUADBIN_TOQUADKEY.md new file mode 100644 index 000000000..63f8f7e3c --- /dev/null +++ b/clouds/redshift/modules/doc/quadbin/QUADBIN_TOQUADKEY.md @@ -0,0 +1,22 @@ +### QUADBIN_TOQUADKEY + +{{% bannerNote type="code" %}} +carto.QUADBIN_TOQUADKEY(quadbin) +{{%/ bannerNote %}} + +**Description** + +Compute a quadkey from a quadbin index. + +* `quadbin`: `BIGINT` Quadbin index. + +**Return type** + +`VARCHAR(MAX)` + +**Example** + +```sql +SELECT carto.QUADBIN_TOQUADKEY(5233974874938015743); +-- '0231001222' +``` diff --git a/clouds/redshift/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql b/clouds/redshift/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql new file mode 100644 index 000000000..6fa2e4b35 --- /dev/null +++ b/clouds/redshift/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql @@ -0,0 +1,19 @@ +---------------------------- +-- Copyright (C) 2022 CARTO +---------------------------- + +CREATE OR REPLACE FUNCTION @@RS_SCHEMA@@.QUADBIN_FROMQUADKEY +(quadkey VARCHAR(MAX)) +RETURNS BIGINT +IMMUTABLE +AS $$ + z = len(quadkey) + xy = int(quadkey or '0', 4) + return ( + 0x4000000000000000 | + (1 << 59) | + (z << 52) | + (xy << (52 - z * 2)) | + (0xFFFFFFFFFFFFF >> (z * 2)) + ) +$$ LANGUAGE plpythonu; diff --git a/clouds/redshift/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql b/clouds/redshift/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql new file mode 100644 index 000000000..ed8e607e9 --- /dev/null +++ b/clouds/redshift/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql @@ -0,0 +1,15 @@ +---------------------------- +-- Copyright (C) 2022 CARTO +---------------------------- + +CREATE OR REPLACE FUNCTION @@RS_SCHEMA@@.QUADBIN_TOQUADKEY +(quadbin BIGINT) +RETURNS VARCHAR(MAX) +IMMUTABLE +AS $$ + from numpy import base_repr + q = quadbin + z = (q >> 52) & (0x1F) + xy = (q & 0xFFFFFFFFFFFFF) >> (52 - z * 2) + return base_repr(xy, 4).zfill(z) if z != 0 else '' +$$ LANGUAGE plpythonu; diff --git a/clouds/redshift/modules/test/quadbin/test_QUADBIN_FROMQUADKEY.py b/clouds/redshift/modules/test/quadbin/test_QUADBIN_FROMQUADKEY.py new file mode 100644 index 000000000..4a9553701 --- /dev/null +++ b/clouds/redshift/modules/test/quadbin/test_QUADBIN_FROMQUADKEY.py @@ -0,0 +1,17 @@ +import pytest +from test_utils import run_query + +input = [ + # quadkey, quadbin + ('', 5192650370358181887), + ('0', 5193776270265024511), + ('13020310', 5226184719091105791), + ('0231001222', 5233974874938015743), +] + + +@pytest.mark.parametrize('quadkey, quadbin', input) +def test_quadbin_fromquadkey(quadkey, quadbin): + result = run_query(f"SELECT @@RS_SCHEMA@@.QUADBIN_FROMQUADKEY('{quadkey}')") + assert len(result[0]) == 1 + assert result[0][0] == quadbin diff --git a/clouds/redshift/modules/test/quadbin/test_QUADBIN_TOQUADKEY.py b/clouds/redshift/modules/test/quadbin/test_QUADBIN_TOQUADKEY.py new file mode 100644 index 000000000..11dda2f1d --- /dev/null +++ b/clouds/redshift/modules/test/quadbin/test_QUADBIN_TOQUADKEY.py @@ -0,0 +1,17 @@ +import pytest +from test_utils import run_query + +input = [ + # quadkey, quadbin + ('', 5192650370358181887), + ('0', 5193776270265024511), + ('13020310', 5226184719091105791), + ('0231001222', 5233974874938015743), +] + + +@pytest.mark.parametrize('quadkey, quadbin', input) +def test_quadbin_toquadkey(quadkey, quadbin): + result = run_query(f'SELECT @@RS_SCHEMA@@.QUADBIN_TOQUADKEY({quadbin})') + assert len(result[0]) == 1 + assert result[0][0] == quadkey diff --git a/clouds/redshift/version b/clouds/redshift/version index 6c6aa7cb0..0ea3a944b 100644 --- a/clouds/redshift/version +++ b/clouds/redshift/version @@ -1 +1 @@ -0.1.0 \ No newline at end of file +0.2.0 diff --git a/clouds/snowflake/CHANGELOG.md b/clouds/snowflake/CHANGELOG.md index 20f734060..5c689eef1 100644 --- a/clouds/snowflake/CHANGELOG.md +++ b/clouds/snowflake/CHANGELOG.md @@ -2,339 +2,11 @@ CARTO Analytics Toolbox Core for Snowflake. -All notable changes to this project will be documented in this file. +All notable commits to this project will be documented in this file. -The format is inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [0.2.0] - 2022-12-27 -## [0.1.0] - 2022-11 - -### All modules - -#### New - -- Create release workflows - -#### Improvement - -- Adapt to Semver - -## [2022.10.24] - 2022-10-24 - -### Module processing - -#### Fix - -- Prevent error in ST_VORONOIPOLYGONS, ST_VORONOILINES, ST_VORONOIPOLYGONS, ST_DELAUNAYLINES when points where too close together by rounding input coordinates to 5 decimal places - -## [2022.10.07] - 2022-10-07 - -### Module clustering - -#### New - -- Move ST_CLUSTERKMEANS function to core. - -### Module random - -#### New - -- Move ST_GENERATEPOINTS function to core. - -## [2022.07.07] - 2022-07-07 - -### Module h3 - -#### Fix - -- Correctly handle large polygons in H3_POLYFILL. -- Fixed wrong uppercase for quadbin and h3 tile ids - -## [2022.06.24] - 2022-06-24 - -### Module quadbin - -#### New - -- Add QUADBIN_BBOX function. -- Add QUADBIN_BOUNDARY function. -- Add QUADBIN_CENTER function. -- Add QUADBIN_FROMGEOGPOINT function. -- Add QUADBIN_FROMLONGLAT function. -- Add QUADBIN_FROMZXY function. -- Add QUADBIN_ISVALID function. -- Add QUADBIN_KRING function. -- Add QUADBIN_KRING_DISTANCES function. -- Add QUADBIN_POLYFILL function. -- Add QUADBIN_RESOLUTION function. -- Add QUADBIN_SIBLINGS function. -- Add QUADBIN_TOCHILDREN function. -- Add QUADBIN_TOPARENT function. -- Add QUADBIN_TOZXY function. - -## [2022.04.07] - 2022-04-07 - -### Module transformations - -#### New - -- Add ST_BUFFER function. - -## [2022.03.21] - 2022-03-21 - -### Module transformations - -#### Improvement - -- ST_CONCAVEHULL now allows arrays with one/two points as input. - -## [2021.12.03] - 2021-12-03 - -### Module accessors - -#### Improvement - -- Deployment schema "carto" instead of "accessors". -- Rename ST_ENVELOPE function to ST_ENVELOPE_ARR. - -#### Removed - -- Remove VERSION function. - -### Module constructors - -#### Improvement - -- Deployment schema "carto" instead of "constructors". - -#### Removed - -- Remove VERSION function. - -### Module h3 - -#### Improvement - -- Deployment schema "carto" instead of "h3". -- Rename ST_ASH3 function to H3_FROMGEOGPOINT. -- Rename LONGLAT_ASH3 function to H3_FROMLONGLAT. -- Rename ST_ASH3_POLYFILL function to H3_POLYFILL. -- Rename ST_BOUNDARY function to H3_BOUNDARY. -- Rename ISVALID function to H3_ISVALID. -- Rename COMPACT function to H3_COMPACT. -- Rename UNCOMPACT function to H3_UNCOMPACT. -- Rename TOPARENT function to H3_TOPARENT. -- Rename TOCHILDREN function to H3_TOCHILDREN. -- Rename ISPENTAGON function to H3_ISPENTAGON. -- Rename DISTANCE function to H3_DISTANCE. -- Rename KRING function to H3_KRING. -- Rename KRING_DISTANCES function to H3_KRING_DISTANCES. -- Rename HEXRING function to H3_HEXRING. - -#### Removed - -- Remove VERSION function. - -### Module measurements - -#### Improvement - -- Deployment schema "carto" instead of "measurements". - -#### Removed - -- Remove ST_ANGLE, already present in Snowflake. -- Remove ST_AZIMUTH, already present in Snowflake. -- Remove VERSION function. - -### Module placekey - -#### Improvement - -- Deployment schema "carto" instead of "placekey". -- Rename H3_ASPLACEKEY function to PLACEKEY_FROMH3. -- Rename PLACEKEY_ASH3 function to PLACEKEY_TOH3. -- Rename ISVALID function to PLACEKEY_ISVALID. - -#### Removed - -- Remove VERSION function. - -### Module processing - -#### Improvement - -- Deployment schema "carto" instead of "processing". - -#### Removed - -- Remove VERSION function. - -### Module s2 - -#### Improvement - -- Deployment schema "carto" instead of "s2". -- Rename ID_FROMHILBERTQUADKEY function to S2_FROMHILBERTQUADKEY. -- Rename HILBERTQUADKEY_FROMID function to S2_TOHILBERTQUADKEY. -- Rename LONGLAT_ASID function to S2_FROMLONGLAT. -- Rename ST_ASID function to S2_FROMGEOGPOINT. -- Rename ST_BOUNDARY function to S2_BOUNDARY. - -#### Removed - -- Remove VERSION function. - -### Module transformations - -#### Improvement - -- Deployment schema "carto" instead of "transformations". - -#### Removed - -- Remove VERSION function. - -## [2021.09.22] - 2021-09-22 - -### Module h3 - -#### New - -- Add KRING_DISTANCES function. - -#### Improvement - -- Review HEXRING, KRING functions. - -## [2021.09.14] - 2021-09-14 - -### Module s2 - -#### Changes - -- Compute ST_BOUNDARY from WKT. - -## [2021.08.24] - 2021-08-24 - -### Module h3 - -#### Fix - -- Support GEOMETRYCOLLECTION from ST_ASH3_POLYFILL. - -## [2021.06.02] - 2021-06-02 - -### Module h3 - -#### Improvement - -- Reduce bundle size for every function. - -## [2021.05.26] - 2021-05-26 - -### Module processing - -#### New - -- Create processing module. -- Add ST_VORONOIPOLYGONS function. -- Add ST_VORONOILINES function. -- Add ST_DELAUNAYPOLYGONS function. -- Add ST_DELAUNAYLINES function. -- Add ST_POLYGONIZE function. -- Add VERSION function. - -## [2021.05.21] - 2021-05-21 - -### Module accessors - -#### New - -- Create accessors module. -- Add ST_ENVELOPE function. -- Add VERSION function. - -## [2021.05.20] - 2021-05-20 - -### Module constructors - -#### New - -- Create constructors module. -- Add ST_BEZIERSPLINE function. -- Add ST_MAKEELLIPSE function. -- Add ST_MAKEENVELOPE function. -- Add ST_TILEENVELOPE function. -- Add VERSION function. - -### Module measurements - -#### New - -- Create measurements module. -- Add ST_ANGLE function. -- Add ST_AZIMUTH function. -- Add ST_MINKOWSKIDISTANCE function. -- Add VERSION function. - -### Module transformations - -#### New - -- Create transformations module. -- Add ST_CENTERMEAN function. -- Add ST_CENTERMEDIAN function. -- Add ST_CENTEROFMASS function. -- Add ST_CONCAVEHULL function. -- Add ST_DESTINATION function. -- Add ST_GREATCIRCLE function. -- Add ST_LINE_INTERPOLATE_POINT function. -- Add VERSION function. - -## [2021.04.16] - 2021-04-16 - -### Module placekey - -#### New - -- Create placekey module. -- Add H3_ASPLACEKEY function. -- Add PLACEKEY_ASH3 function. -- Add ISVALID function. -- Add VERSION function. - -## [2021.04.12] - 2021-04-12 - -### Module s2 - -#### New - -- Create s2 module. -- Add ID_FROMHILBERTQUADKEY function. -- Add HILBERTQUADKEY_FROMID function. -- Add LONGLAT_ASID function. -- Add ST_ASID function. -- Add ST_BOUNDARY function. -- Add VERSION function. - -## [2021.04.07] - 2021-04-07 - -### Module h3 - -#### New - -- Create h3 module. -- Add ST_ASH3 function. -- Add LONGLAT_ASH3 function. -- Add ST_ASH3_POLYFILL function. -- Add ST_BOUNDARY function. -- Add ISVALID function. -- Add COMPACT function. -- Add UNCOMPACT function. -- Add TOPARENT function. -- Add TOCHILDREN function. -- Add ISPENTAGON function. -- Add DISTANCE function. -- Add KRING function. -- Add HEXRING function. -- Add VERSION function. +- docs(h3): add H3 INT/STRING functions reference (#369) +- feat(quadbin): add quadbin/quadkey conversion functions (#370) +- fix(h3): H3_BOUNDARY by removing duplicated points (#371) +- fix: add missing SECURE tag to share ATC functions (#372) diff --git a/clouds/snowflake/CHANGELOG.old.md b/clouds/snowflake/CHANGELOG.old.md new file mode 100644 index 000000000..d32ca2d39 --- /dev/null +++ b/clouds/snowflake/CHANGELOG.old.md @@ -0,0 +1,326 @@ +# Changelog [old] + +CARTO Analytics Toolbox Core for Snowflake. + +The format is inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + +## [2022.10.24] - 2022-10-24 + +### Module processing + +#### Fix + +- Prevent error in ST_VORONOIPOLYGONS, ST_VORONOILINES, ST_VORONOIPOLYGONS, ST_DELAUNAYLINES when points where too close together by rounding input coordinates to 5 decimal places + +## [2022.10.07] - 2022-10-07 + +### Module clustering + +#### Feature + +- Move ST_CLUSTERKMEANS function to core. + +### Module random + +#### Feature + +- Move ST_GENERATEPOINTS function to core. + +## [2022.07.07] - 2022-07-07 + +### Module h3 + +#### Fix + +- Correctly handle large polygons in H3_POLYFILL. +- Fixed wrong uppercase for quadbin and h3 tile ids + +## [2022.06.24] - 2022-06-24 + +### Module quadbin + +#### Feature + +- Add QUADBIN_BBOX function. +- Add QUADBIN_BOUNDARY function. +- Add QUADBIN_CENTER function. +- Add QUADBIN_FROMGEOGPOINT function. +- Add QUADBIN_FROMLONGLAT function. +- Add QUADBIN_FROMZXY function. +- Add QUADBIN_ISVALID function. +- Add QUADBIN_KRING function. +- Add QUADBIN_KRING_DISTANCES function. +- Add QUADBIN_POLYFILL function. +- Add QUADBIN_RESOLUTION function. +- Add QUADBIN_SIBLINGS function. +- Add QUADBIN_TOCHILDREN function. +- Add QUADBIN_TOPARENT function. +- Add QUADBIN_TOZXY function. + +## [2022.04.07] - 2022-04-07 + +### Module transformations + +#### Feature + +- Add ST_BUFFER function. + +## [2022.03.21] - 2022-03-21 + +### Module transformations + +#### Improvement + +- ST_CONCAVEHULL now allows arrays with one/two points as input. + +## [2021.12.03] - 2021-12-03 + +### Module accessors + +#### Improvement + +- Deployment schema "carto" instead of "accessors". +- Rename ST_ENVELOPE function to ST_ENVELOPE_ARR. + +#### Removed + +- Remove VERSION function. + +### Module constructors + +#### Improvement + +- Deployment schema "carto" instead of "constructors". + +#### Removed + +- Remove VERSION function. + +### Module h3 + +#### Improvement + +- Deployment schema "carto" instead of "h3". +- Rename ST_ASH3 function to H3_FROMGEOGPOINT. +- Rename LONGLAT_ASH3 function to H3_FROMLONGLAT. +- Rename ST_ASH3_POLYFILL function to H3_POLYFILL. +- Rename ST_BOUNDARY function to H3_BOUNDARY. +- Rename ISVALID function to H3_ISVALID. +- Rename COMPACT function to H3_COMPACT. +- Rename UNCOMPACT function to H3_UNCOMPACT. +- Rename TOPARENT function to H3_TOPARENT. +- Rename TOCHILDREN function to H3_TOCHILDREN. +- Rename ISPENTAGON function to H3_ISPENTAGON. +- Rename DISTANCE function to H3_DISTANCE. +- Rename KRING function to H3_KRING. +- Rename KRING_DISTANCES function to H3_KRING_DISTANCES. +- Rename HEXRING function to H3_HEXRING. + +#### Removed + +- Remove VERSION function. + +### Module measurements + +#### Improvement + +- Deployment schema "carto" instead of "measurements". + +#### Removed + +- Remove ST_ANGLE, already present in Snowflake. +- Remove ST_AZIMUTH, already present in Snowflake. +- Remove VERSION function. + +### Module placekey + +#### Improvement + +- Deployment schema "carto" instead of "placekey". +- Rename H3_ASPLACEKEY function to PLACEKEY_FROMH3. +- Rename PLACEKEY_ASH3 function to PLACEKEY_TOH3. +- Rename ISVALID function to PLACEKEY_ISVALID. + +#### Removed + +- Remove VERSION function. + +### Module processing + +#### Improvement + +- Deployment schema "carto" instead of "processing". + +#### Removed + +- Remove VERSION function. + +### Module s2 + +#### Improvement + +- Deployment schema "carto" instead of "s2". +- Rename ID_FROMHILBERTQUADKEY function to S2_FROMHILBERTQUADKEY. +- Rename HILBERTQUADKEY_FROMID function to S2_TOHILBERTQUADKEY. +- Rename LONGLAT_ASID function to S2_FROMLONGLAT. +- Rename ST_ASID function to S2_FROMGEOGPOINT. +- Rename ST_BOUNDARY function to S2_BOUNDARY. + +#### Removed + +- Remove VERSION function. + +### Module transformations + +#### Improvement + +- Deployment schema "carto" instead of "transformations". + +#### Removed + +- Remove VERSION function. + +## [2021.09.22] - 2021-09-22 + +### Module h3 + +#### Feature + +- Add KRING_DISTANCES function. + +#### Improvement + +- Review HEXRING, KRING functions. + +## [2021.09.14] - 2021-09-14 + +### Module s2 + +#### Changes + +- Compute ST_BOUNDARY from WKT. + +## [2021.08.24] - 2021-08-24 + +### Module h3 + +#### Fix + +- Support GEOMETRYCOLLECTION from ST_ASH3_POLYFILL. + +## [2021.06.02] - 2021-06-02 + +### Module h3 + +#### Improvement + +- Reduce bundle size for every function. + +## [2021.05.26] - 2021-05-26 + +### Module processing + +#### Feature + +- Create processing module. +- Add ST_VORONOIPOLYGONS function. +- Add ST_VORONOILINES function. +- Add ST_DELAUNAYPOLYGONS function. +- Add ST_DELAUNAYLINES function. +- Add ST_POLYGONIZE function. +- Add VERSION function. + +## [2021.05.21] - 2021-05-21 + +### Module accessors + +#### Feature + +- Create accessors module. +- Add ST_ENVELOPE function. +- Add VERSION function. + +## [2021.05.20] - 2021-05-20 + +### Module constructors + +#### Feature + +- Create constructors module. +- Add ST_BEZIERSPLINE function. +- Add ST_MAKEELLIPSE function. +- Add ST_MAKEENVELOPE function. +- Add ST_TILEENVELOPE function. +- Add VERSION function. + +### Module measurements + +#### Feature + +- Create measurements module. +- Add ST_ANGLE function. +- Add ST_AZIMUTH function. +- Add ST_MINKOWSKIDISTANCE function. +- Add VERSION function. + +### Module transformations + +#### Feature + +- Create transformations module. +- Add ST_CENTERMEAN function. +- Add ST_CENTERMEDIAN function. +- Add ST_CENTEROFMASS function. +- Add ST_CONCAVEHULL function. +- Add ST_DESTINATION function. +- Add ST_GREATCIRCLE function. +- Add ST_LINE_INTERPOLATE_POINT function. +- Add VERSION function. + +## [2021.04.16] - 2021-04-16 + +### Module placekey + +#### Feature + +- Create placekey module. +- Add H3_ASPLACEKEY function. +- Add PLACEKEY_ASH3 function. +- Add ISVALID function. +- Add VERSION function. + +## [2021.04.12] - 2021-04-12 + +### Module s2 + +#### Feature + +- Create s2 module. +- Add ID_FROMHILBERTQUADKEY function. +- Add HILBERTQUADKEY_FROMID function. +- Add LONGLAT_ASID function. +- Add ST_ASID function. +- Add ST_BOUNDARY function. +- Add VERSION function. + +## [2021.04.07] - 2021-04-07 + +### Module h3 + +#### Feature + +- Create h3 module. +- Add ST_ASH3 function. +- Add LONGLAT_ASH3 function. +- Add ST_ASH3_POLYFILL function. +- Add ST_BOUNDARY function. +- Add ISVALID function. +- Add COMPACT function. +- Add UNCOMPACT function. +- Add TOPARENT function. +- Add TOCHILDREN function. +- Add ISPENTAGON function. +- Add DISTANCE function. +- Add KRING function. +- Add HEXRING function. +- Add VERSION function. diff --git a/clouds/snowflake/common/VERSION.sql b/clouds/snowflake/common/VERSION.sql index bbe2295c7..dc826ae40 100644 --- a/clouds/snowflake/common/VERSION.sql +++ b/clouds/snowflake/common/VERSION.sql @@ -1,5 +1,5 @@ -CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.@@SF_VERSION_FUNCTION@@ +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.@@SF_VERSION_FUNCTION@@ () RETURNS STRING IMMUTABLE diff --git a/clouds/snowflake/libraries/javascript/libs/h3_boundary.js b/clouds/snowflake/libraries/javascript/libs/h3_boundary.js index 8c0f2796f..6add8b606 100644 --- a/clouds/snowflake/libraries/javascript/libs/h3_boundary.js +++ b/clouds/snowflake/libraries/javascript/libs/h3_boundary.js @@ -1,6 +1,22 @@ import { h3IsValid, h3ToGeoBoundary } from '../src/h3/h3_boundary/h3core_custom'; +function removeNextDuplicates (coordinates) { + const precision = 0.0000000000001; + const uniqueCoordinates = []; + + for (let i = 0; i < coordinates.length; i++) { + if (i == coordinates.length - 1 || + (Math.abs(coordinates[i][0] - coordinates[i+1][0]) > precision && + Math.abs(coordinates[i][1] - coordinates[i+1][1]) > precision)) { + uniqueCoordinates.push(coordinates[i]) + } + } + + return uniqueCoordinates; +} + export default { h3IsValid, - h3ToGeoBoundary + h3ToGeoBoundary, + removeNextDuplicates }; \ No newline at end of file diff --git a/clouds/snowflake/modules/doc/h3/H3_INT_TOSTRING.md b/clouds/snowflake/modules/doc/h3/H3_INT_TOSTRING.md new file mode 100644 index 000000000..b76d83944 --- /dev/null +++ b/clouds/snowflake/modules/doc/h3/H3_INT_TOSTRING.md @@ -0,0 +1,22 @@ +### H3_INT_TOSTRING + +{{% bannerNote type="code" %}} +carto.H3_INT_TOSTRING(index) +{{%/ bannerNote %}} + +**Description** + +Converts the integer representation of the H3 index to the string representation. + +* `index`: `INT` The H3 cell index. + +**Return type** + +`STRING` + +**Example** + +```sql +SELECT carto.H3_INT_TOSTRING(596645165859340287); +-- 847b59dffffffff +``` diff --git a/clouds/snowflake/modules/doc/h3/H3_STRING_TOINT.md b/clouds/snowflake/modules/doc/h3/H3_STRING_TOINT.md new file mode 100644 index 000000000..3f6528276 --- /dev/null +++ b/clouds/snowflake/modules/doc/h3/H3_STRING_TOINT.md @@ -0,0 +1,22 @@ +### H3_STRING_TOINT + +{{% bannerNote type="code" %}} +carto.H3_STRING_TOINT(index) +{{%/ bannerNote %}} + +**Description** + +Converts the string representation of the H3 index to the integer representation. + +* `index`: `STRING` The H3 cell index. + +**Return type** + +`INT` + +**Example** + +```sql +SELECT carto.H3_STRING_TOINT('847b59dffffffff'); +-- 596645165859340287 +``` diff --git a/clouds/snowflake/modules/doc/processing/ST_DELAUNAYLINES.md b/clouds/snowflake/modules/doc/processing/ST_DELAUNAYLINES.md index 655bc1d02..039bfd02f 100644 --- a/clouds/snowflake/modules/doc/processing/ST_DELAUNAYLINES.md +++ b/clouds/snowflake/modules/doc/processing/ST_DELAUNAYLINES.md @@ -47,4 +47,4 @@ SELECT carto.ST_DELAUNAYLINES( -- [ -- "{\"coordinates\":[[4.18293,43.63475],[4.183,43.63471],[4.18295,43.63479],[4.18293,43.63475]],\"type\":\"LineString\"}" -- ] -``` \ No newline at end of file +``` diff --git a/clouds/snowflake/modules/doc/processing/ST_VORONOILINES.md b/clouds/snowflake/modules/doc/processing/ST_VORONOILINES.md index a2840cad2..dcf0b8fe2 100644 --- a/clouds/snowflake/modules/doc/processing/ST_VORONOILINES.md +++ b/clouds/snowflake/modules/doc/processing/ST_VORONOILINES.md @@ -65,4 +65,4 @@ SELECT carto.ST_VORONOILINES( -- "{\"type\":\"LineString\",\"coordinates\":[[4.183,43.634765625],[4.182,43.63414062499997],[4.182,43.635],[4.183,43.635],[4.183,43.634765625]]}", -- "{\"type\":\"LineString\",\"coordinates\":[[4.182,43.63414062499997],[4.183,43.634765625],[4.183,43.634],[4.182,43.634],[4.182,43.63414062499997]]}" -- ] -``` \ No newline at end of file +``` diff --git a/clouds/snowflake/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md b/clouds/snowflake/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md new file mode 100644 index 000000000..b2c47d600 --- /dev/null +++ b/clouds/snowflake/modules/doc/quadbin/QUADBIN_FROMQUADKEY.md @@ -0,0 +1,22 @@ +### QUADBIN_FROMQUADKEY + +{{% bannerNote type="code" %}} +carto.QUADBIN_FROMQUADKEY(quadkey) +{{%/ bannerNote %}} + +**Description** + +Compute a quadbin index from a quadkey. + +* `quadkey`: `STRING` Quadkey representation of the index. + +**Return type** + +`BIGINT` + +**Example** + +```sql +SELECT carto.QUADBIN_FROMQUADKEY('0231001222'); +-- 5233974874938015743 +``` diff --git a/clouds/snowflake/modules/doc/quadbin/QUADBIN_TOQUADKEY.md b/clouds/snowflake/modules/doc/quadbin/QUADBIN_TOQUADKEY.md new file mode 100644 index 000000000..cc3b75697 --- /dev/null +++ b/clouds/snowflake/modules/doc/quadbin/QUADBIN_TOQUADKEY.md @@ -0,0 +1,22 @@ +### QUADBIN_TOQUADKEY + +{{% bannerNote type="code" %}} +carto.QUADBIN_TOQUADKEY(quadbin) +{{%/ bannerNote %}} + +**Description** + +Compute a quadkey from a quadbin index. + +* `quadbin`: `BIGINT` Quadbin index. + +**Return type** + +`STRING` + +**Example** + +```sql +SELECT carto.QUADBIN_TOQUADKEY(5233974874938015743); +-- '0231001222' +``` diff --git a/clouds/snowflake/modules/sql/h3/H3_BOUNDARY.sql b/clouds/snowflake/modules/sql/h3/H3_BOUNDARY.sql index 87b11ba78..8eac89bce 100644 --- a/clouds/snowflake/modules/sql/h3/H3_BOUNDARY.sql +++ b/clouds/snowflake/modules/sql/h3/H3_BOUNDARY.sql @@ -19,12 +19,8 @@ AS $$ } const coords = h3BoundaryLib.h3ToGeoBoundary(INDEX, true); - let output = `POLYGON((`; - for (let i = 0; i < coords.length - 1; i++) { - output += coords[i][0] + ` ` + coords[i][1] + `,`; - } - output += coords[coords.length - 1][0] + ` ` + coords[coords.length - 1][1] + `))`; - return output; + const uniqueCoords = h3BoundaryLib.removeNextDuplicates(coords); + return `POLYGON((${uniqueCoords.map(c => `${c[0]} ${c[1]}`).join(',')}))`; $$; CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.H3_BOUNDARY diff --git a/clouds/snowflake/modules/sql/h3/H3_INT_TOSTRING.sql b/clouds/snowflake/modules/sql/h3/H3_INT_TOSTRING.sql index 81d6856dd..8069709ce 100644 --- a/clouds/snowflake/modules/sql/h3/H3_INT_TOSTRING.sql +++ b/clouds/snowflake/modules/sql/h3/H3_INT_TOSTRING.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.H3_INT_TOSTRING +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.H3_INT_TOSTRING ( h3int INT ) diff --git a/clouds/snowflake/modules/sql/h3/H3_STRING_TOINT.sql b/clouds/snowflake/modules/sql/h3/H3_STRING_TOINT.sql index 9d80b26a6..1c1dcee08 100644 --- a/clouds/snowflake/modules/sql/h3/H3_STRING_TOINT.sql +++ b/clouds/snowflake/modules/sql/h3/H3_STRING_TOINT.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.H3_STRING_TOINT +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.H3_STRING_TOINT ( h3 STRING ) diff --git a/clouds/snowflake/modules/sql/quadbin/QUADBIN_BBOX.sql b/clouds/snowflake/modules/sql/quadbin/QUADBIN_BBOX.sql index f5a672c3c..546aab795 100644 --- a/clouds/snowflake/modules/sql/quadbin/QUADBIN_BBOX.sql +++ b/clouds/snowflake/modules/sql/quadbin/QUADBIN_BBOX.sql @@ -2,7 +2,7 @@ -- Copyright (C) 2022 CARTO ---------------------------- -CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@._QUADBIN_BBOX +CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@._QUADBIN_BBOX (index STRING) RETURNS ARRAY LANGUAGE JAVASCRIPT diff --git a/clouds/snowflake/modules/sql/quadbin/QUADBIN_CENTER.sql b/clouds/snowflake/modules/sql/quadbin/QUADBIN_CENTER.sql index 9ba1fdd9d..859fab7ee 100644 --- a/clouds/snowflake/modules/sql/quadbin/QUADBIN_CENTER.sql +++ b/clouds/snowflake/modules/sql/quadbin/QUADBIN_CENTER.sql @@ -2,7 +2,7 @@ -- Copyright (C) 2022 CARTO ---------------------------- -CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.QUADBIN_CENTER +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.QUADBIN_CENTER (quadbin BIGINT) RETURNS GEOGRAPHY IMMUTABLE diff --git a/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql b/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql index c5b7cd5bd..2917c5395 100644 --- a/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql +++ b/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMGEOGPOINT.sql @@ -2,7 +2,7 @@ -- Copyright (C) 2022 CARTO ---------------------------- -CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.QUADBIN_FROMGEOGPOINT +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.QUADBIN_FROMGEOGPOINT (point GEOGRAPHY, resolution INT) RETURNS BIGINT IMMUTABLE diff --git a/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMLONGLAT.sql b/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMLONGLAT.sql index b5e600e3a..0ee2eafcd 100644 --- a/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMLONGLAT.sql +++ b/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMLONGLAT.sql @@ -2,7 +2,7 @@ -- Copyright (C) 2022 CARTO ---------------------------- -CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.QUADBIN_FROMLONGLAT +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.QUADBIN_FROMLONGLAT (longitude FLOAT, latitude FLOAT, resolution INT) RETURNS BIGINT IMMUTABLE diff --git a/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql b/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql new file mode 100644 index 000000000..d8991f85a --- /dev/null +++ b/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMQUADKEY.sql @@ -0,0 +1,26 @@ +---------------------------- +-- Copyright (C) 2022 CARTO +---------------------------- + +CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@._QUADBIN_FROMQUADKEY +(quadkey STRING) +RETURNS STRING +LANGUAGE JAVASCRIPT +IMMUTABLE +AS $$ + const z = BigInt(QUADKEY.length); + const xy = BigInt(parseInt(QUADKEY, 4) || 0); + return (0x4000000000000000n | + (1n << 59n) | + (z << 52n) | + (xy << (52n - z*2n)) | + (0xFFFFFFFFFFFFFn >> (z*2n))).toString(); +$$; + +CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.QUADBIN_FROMQUADKEY +(quadkey STRING) +RETURNS BIGINT +IMMUTABLE +AS $$ + SELECT CAST(@@SF_SCHEMA@@._QUADBIN_FROMQUADKEY(QUADKEY) AS BIGINT) +$$; diff --git a/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMZXY.sql b/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMZXY.sql index 79b136179..008e1c29b 100644 --- a/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMZXY.sql +++ b/clouds/snowflake/modules/sql/quadbin/QUADBIN_FROMZXY.sql @@ -20,7 +20,7 @@ AS $$ return quadbinLib.tileToQuadbin(tile); $$; -CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.QUADBIN_FROMZXY +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.QUADBIN_FROMZXY (z INT, x INT, y INT) RETURNS BIGINT IMMUTABLE diff --git a/clouds/snowflake/modules/sql/quadbin/QUADBIN_ISVALID.sql b/clouds/snowflake/modules/sql/quadbin/QUADBIN_ISVALID.sql index da1c9e9aa..44747752c 100644 --- a/clouds/snowflake/modules/sql/quadbin/QUADBIN_ISVALID.sql +++ b/clouds/snowflake/modules/sql/quadbin/QUADBIN_ISVALID.sql @@ -2,7 +2,7 @@ -- Copyright (C) 2022 CARTO ---------------------------- -CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.QUADBIN_ISVALID +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.QUADBIN_ISVALID (quadbin BIGINT) RETURNS BOOLEAN IMMUTABLE diff --git a/clouds/snowflake/modules/sql/quadbin/QUADBIN_KRING.sql b/clouds/snowflake/modules/sql/quadbin/QUADBIN_KRING.sql index 1c0543ffa..6e4819ad6 100644 --- a/clouds/snowflake/modules/sql/quadbin/QUADBIN_KRING.sql +++ b/clouds/snowflake/modules/sql/quadbin/QUADBIN_KRING.sql @@ -9,7 +9,7 @@ -- 2. If the UDF returns the hex codification of the quadbin to be parsed in a SQL -- higher level by using the _QUADBIN_STRING_TOINT UDF a non-correlated query can be produced. -CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.QUADBIN_KRING +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.QUADBIN_KRING (origin BIGINT, size INT) RETURNS ARRAY IMMUTABLE diff --git a/clouds/snowflake/modules/sql/quadbin/QUADBIN_KRING_DISTANCES.sql b/clouds/snowflake/modules/sql/quadbin/QUADBIN_KRING_DISTANCES.sql index 80e5b5623..e75e7f9eb 100644 --- a/clouds/snowflake/modules/sql/quadbin/QUADBIN_KRING_DISTANCES.sql +++ b/clouds/snowflake/modules/sql/quadbin/QUADBIN_KRING_DISTANCES.sql @@ -9,7 +9,7 @@ -- 2. If the UDF returns the hex codification of the quadbin to be parsed in a SQL -- higher level by using the _QUADBIN_STRING_TOINT UDF a non-correlated query can be produced. -CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.QUADBIN_KRING_DISTANCES +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.QUADBIN_KRING_DISTANCES (origin BIGINT, size INT) RETURNS ARRAY IMMUTABLE diff --git a/clouds/snowflake/modules/sql/quadbin/QUADBIN_RESOLUTION.sql b/clouds/snowflake/modules/sql/quadbin/QUADBIN_RESOLUTION.sql index c69605305..2f31f02c9 100644 --- a/clouds/snowflake/modules/sql/quadbin/QUADBIN_RESOLUTION.sql +++ b/clouds/snowflake/modules/sql/quadbin/QUADBIN_RESOLUTION.sql @@ -2,7 +2,7 @@ -- Copyright (C) 2022 CARTO ---------------------------- -CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.QUADBIN_RESOLUTION +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.QUADBIN_RESOLUTION (quadbin BIGINT) RETURNS INT IMMUTABLE diff --git a/clouds/snowflake/modules/sql/quadbin/QUADBIN_SIBLING.sql b/clouds/snowflake/modules/sql/quadbin/QUADBIN_SIBLING.sql index 8e67192c3..c79ec79fd 100644 --- a/clouds/snowflake/modules/sql/quadbin/QUADBIN_SIBLING.sql +++ b/clouds/snowflake/modules/sql/quadbin/QUADBIN_SIBLING.sql @@ -4,7 +4,7 @@ -- FIXME: slow -CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.QUADBIN_SIBLING +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.QUADBIN_SIBLING (quadbin BIGINT, direction STRING) RETURNS INT IMMUTABLE diff --git a/clouds/snowflake/modules/sql/quadbin/QUADBIN_TOCHILDREN.sql b/clouds/snowflake/modules/sql/quadbin/QUADBIN_TOCHILDREN.sql index 99c806a7b..feef76cc2 100644 --- a/clouds/snowflake/modules/sql/quadbin/QUADBIN_TOCHILDREN.sql +++ b/clouds/snowflake/modules/sql/quadbin/QUADBIN_TOCHILDREN.sql @@ -47,7 +47,7 @@ AS $$ $$; -CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.QUADBIN_TOCHILDREN +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.QUADBIN_TOCHILDREN (quadbin BIGINT, resolution INT) RETURNS ARRAY IMMUTABLE diff --git a/clouds/snowflake/modules/sql/quadbin/QUADBIN_TOPARENT.sql b/clouds/snowflake/modules/sql/quadbin/QUADBIN_TOPARENT.sql index 017e58518..322e1ef33 100644 --- a/clouds/snowflake/modules/sql/quadbin/QUADBIN_TOPARENT.sql +++ b/clouds/snowflake/modules/sql/quadbin/QUADBIN_TOPARENT.sql @@ -2,7 +2,7 @@ -- Copyright (C) 2022 CARTO ---------------------------- -CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.QUADBIN_TOPARENT +CREATE OR REPLACE SECURE FUNCTION @@SF_SCHEMA@@.QUADBIN_TOPARENT (quadbin BIGINT, resolution INT) RETURNS BIGINT IMMUTABLE diff --git a/clouds/snowflake/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql b/clouds/snowflake/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql new file mode 100644 index 000000000..d418ae0d4 --- /dev/null +++ b/clouds/snowflake/modules/sql/quadbin/QUADBIN_TOQUADKEY.sql @@ -0,0 +1,24 @@ +---------------------------- +-- Copyright (C) 2022 CARTO +---------------------------- + +CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@._QUADBIN_TOQUADKEY +(quadbin STRING) +RETURNS STRING +LANGUAGE JAVASCRIPT +IMMUTABLE +AS $$ + const q = BigInt(QUADBIN); + const z = (q >> 52n) & 0x1Fn; + const xy = (q & 0xFFFFFFFFFFFFFn) >> (52n - z*2n); + return (z == 0) ? '' : xy.toString(4).padStart(Number(z), '0'); +$$; + + +CREATE OR REPLACE FUNCTION @@SF_SCHEMA@@.QUADBIN_TOQUADKEY +(quadbin BIGINT) +RETURNS STRING +IMMUTABLE +AS $$ + SELECT @@SF_SCHEMA@@._QUADBIN_TOQUADKEY(CAST(QUADBIN AS STRING)) +$$; diff --git a/clouds/snowflake/modules/test/h3/H3_BOUNDARY.test.js b/clouds/snowflake/modules/test/h3/H3_BOUNDARY.test.js index 52c30dcbe..d4c287a6e 100644 --- a/clouds/snowflake/modules/test/h3/H3_BOUNDARY.test.js +++ b/clouds/snowflake/modules/test/h3/H3_BOUNDARY.test.js @@ -20,12 +20,15 @@ test('Returns NULL with invalid parameters', async () => { expect(rows[1].BOUNDS).toEqual(null); }); -test('Returns NULL the expected geography', async () => { +test('Returns the expected geography', async () => { const query = ` WITH ids AS ( SELECT 1 AS id, '85283473fffffff' as hid, TO_GEOGRAPHY('POLYGON((-121.91508032705622 37.271355866731895, -121.86222328902487 37.35392645085226, -121.92354999630157 37.42834118609435, -122.03773496427027 37.42012867767778, -122.09042892904397 37.33755608435298, -122.02910130918998 37.26319797461824, -121.91508032705622 37.2713558667318959))') AS expected UNION ALL - SELECT 2 AS id, '81623ffffffffff' as hid, TO_GEOGRAPHY('POLYGON((55.94007484027041 12.754829243237465, 55.178175815407634 10.2969712998247, 55.25056228923789 9.092686031788569, 57.37516125699395 7.616228186063625, 58.549882762724735 7.302087248609305, 60.638711932789995 8.825639091130396, 61.315435771664646 9.83036925628956, 60.502253257733344 12.271971757766304, 59.732575088573185 13.216340916028171, 57.09422515125156 13.191260467897605, 55.94007484027041 12.754829243237465))') AS expected + SELECT 2 AS id, '81623ffffffffff' as hid, TO_GEOGRAPHY('POLYGON((55.94007484027041 12.754829243237465, 55.178175815407634 10.2969712998247, 55.25056228923789 9.092686031788569, 57.37516125699395 7.616228186063625, 58.549882762724735 7.302087248609305, 60.638711932789995 8.825639091130396, 61.315435771664646 9.83036925628956, 60.502253257733344 12.271971757766304, 59.732575088573185 13.216340916028171, 57.09422515125156 13.191260467897605, 55.94007484027041 12.754829243237465))') AS expected UNION ALL + SELECT 3 AS id, '870813269ffffff' as hid, TO_GEOGRAPHY('POLYGON((14.711648031146114 63.277882025346415,14.712440922705934 63.26861190442848,14.73446836421859 63.26494482126122,14.755709705688332 63.27054633635922,14.755317756693326 63.27518180749664,14.752695851168275 63.28064279423593,14.732891492101393 63.28348535730845,14.711648031146114 63.277882025346415))') AS expected UNION ALL + SELECT 4 AS id, '8708132c9ffffff' as hid, TO_GEOGRAPHY('POLYGON((14.980290407235753 63.17789340607063,14.981026086428166 63.16859620261361,15.002996154492914 63.164874810511954,15.024237224435646 63.17044909395252,15.0238738694539 63.175098100519314,15.021303345184416 63.18057404076462,15.001533688888705 63.183469499131554,14.980290407235753 63.17789340607063))') AS expected UNION ALL + SELECT 5 AS id, '870811a69ffffff' as hid, TO_GEOGRAPHY('POLYGON((12.802705201609877 63.95493262768267,12.8039094653455 63.94585303660034,12.826318075218023 63.94256790087345,12.84752999039057 63.948360878458764,12.846932424218958 63.95290112494493,12.843943874747696 63.95825430649401,12.82391855217846 63.960727463737385,12.802705201609877 63.95493262768267))') AS expected ) SELECT *, @@ -34,7 +37,10 @@ test('Returns NULL the expected geography', async () => { `; const rows = await runQuery(query); - expect(rows.length).toEqual(2); + expect(rows.length).toEqual(5); expect(rows[0].EXPECTED).toEqual(rows[0].BOUNDS); expect(rows[1].EXPECTED).toEqual(rows[1].BOUNDS); + expect(rows[2].EXPECTED).toEqual(rows[2].BOUNDS); + expect(rows[3].EXPECTED).toEqual(rows[3].BOUNDS); + expect(rows[4].EXPECTED).toEqual(rows[4].BOUNDS); }); \ No newline at end of file diff --git a/clouds/snowflake/modules/test/quadbin/QUADBIN_FROMQUADKEY.test.js b/clouds/snowflake/modules/test/quadbin/QUADBIN_FROMQUADKEY.test.js new file mode 100644 index 000000000..c3914e550 --- /dev/null +++ b/clouds/snowflake/modules/test/quadbin/QUADBIN_FROMQUADKEY.test.js @@ -0,0 +1,13 @@ +const { runQuery } = require('../../../common/test-utils'); + +test('QUADBIN_FROMQUADKEY should work', async () => { + const query = `SELECT [ + CAST(QUADBIN_FROMQUADKEY('') AS STRING), + CAST(QUADBIN_FROMQUADKEY('0') AS STRING), + CAST(QUADBIN_FROMQUADKEY('13020310') AS STRING), + CAST(QUADBIN_FROMQUADKEY('0231001222') AS STRING) + ] AS OUTPUT`; + const rows = await runQuery(query); + expect(rows.length).toEqual(1); + expect(rows[0].OUTPUT).toEqual(['5192650370358181887', '5193776270265024511', '5226184719091105791', '5233974874938015743']); +}); \ No newline at end of file diff --git a/clouds/snowflake/modules/test/quadbin/QUADBIN_TOQUADKEY.test.js b/clouds/snowflake/modules/test/quadbin/QUADBIN_TOQUADKEY.test.js new file mode 100644 index 000000000..6f08c51b9 --- /dev/null +++ b/clouds/snowflake/modules/test/quadbin/QUADBIN_TOQUADKEY.test.js @@ -0,0 +1,13 @@ +const { runQuery } = require('../../../common/test-utils'); + +test('QUADBIN_TOQUADKEY should work', async () => { + const query = `SELECT [ + QUADBIN_TOQUADKEY(5192650370358181887), + QUADBIN_TOQUADKEY(5193776270265024511), + QUADBIN_TOQUADKEY(5226184719091105791), + QUADBIN_TOQUADKEY(5233974874938015743) + ] AS OUTPUT`; + const rows = await runQuery(query); + expect(rows.length).toEqual(1); + expect(rows[0].OUTPUT).toEqual(['', '0', '13020310', '0231001222']); +}); \ No newline at end of file diff --git a/clouds/snowflake/version b/clouds/snowflake/version index 6c6aa7cb0..0ea3a944b 100644 --- a/clouds/snowflake/version +++ b/clouds/snowflake/version @@ -1 +1 @@ -0.1.0 \ No newline at end of file +0.2.0