From 7596897c385f066f3b8617182d87ced030b9e1bd Mon Sep 17 00:00:00 2001 From: vdelacruzb Date: Thu, 23 Jan 2025 11:25:00 +0100 Subject: [PATCH] fix polyfill functions not working with holes --- clouds/bigquery/modules/sql/h3/H3_POLYFILL.sql | 5 ++++- clouds/bigquery/modules/sql/quadbin/QUADBIN_POLYFILL.sql | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/clouds/bigquery/modules/sql/h3/H3_POLYFILL.sql b/clouds/bigquery/modules/sql/h3/H3_POLYFILL.sql index c4c342476..581d39bc7 100644 --- a/clouds/bigquery/modules/sql/h3/H3_POLYFILL.sql +++ b/clouds/bigquery/modules/sql/h3/H3_POLYFILL.sql @@ -130,7 +130,10 @@ AS (( IF(resolution < 0 OR resolution > 15, ERROR('Invalid resolution, should be between 0 and 15'), ( WITH __bbox AS ( - SELECT ST_BOUNDINGBOX(geog) AS box + SELECT IF(ST_DIMENSION(geog) = 2, + ST_BOUNDINGBOX(`@@BQ_DATASET@@.ST_ENVELOPE`(ARRAY[geog])), + ST_BOUNDINGBOX(geog) + ) AS box ), __params AS ( SELECT diff --git a/clouds/bigquery/modules/sql/quadbin/QUADBIN_POLYFILL.sql b/clouds/bigquery/modules/sql/quadbin/QUADBIN_POLYFILL.sql index 9372273b8..6d53728d8 100644 --- a/clouds/bigquery/modules/sql/quadbin/QUADBIN_POLYFILL.sql +++ b/clouds/bigquery/modules/sql/quadbin/QUADBIN_POLYFILL.sql @@ -7,7 +7,10 @@ CREATE OR REPLACE FUNCTION `@@BQ_DATASET@@.__QUADBIN_POLYFILL_INIT` RETURNS ARRAY AS (( WITH __bbox AS ( - SELECT ST_BOUNDINGBOX(geog) AS box + SELECT IF(ST_DIMENSION(geog) = 2, + ST_BOUNDINGBOX(`@@BQ_DATASET@@.ST_ENVELOPE`(ARRAY[geog])), + ST_BOUNDINGBOX(geog) + ) AS box ), __params AS ( SELECT