Skip to content

Commit

Permalink
update internal function used by st_tileenvelope
Browse files Browse the repository at this point in the history
  • Loading branch information
vdelacruzb committed Jan 9, 2024
1 parent 49ee221 commit 006c30d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions clouds/bigquery/modules/sql/constructors/ST_TILEENVELOPE.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ CREATE OR REPLACE FUNCTION `@@BQ_DATASET@@.ST_TILEENVELOPE`
(zoomLevel INT64, xTile INT64, yTile INT64)
RETURNS GEOGRAPHY
AS (
`@@BQ_DATASET@@.QUADINT_BOUNDARY`(
`@@BQ_DATASET@@.QUADINT_FROMZXY`(
`@@BQ_DATASET@@.QUADBIN_BOUNDARY`(
`@@BQ_DATASET@@.QUADBIN_FROMZXY`(
zoomlevel, xtile, ytile
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ test('ST_TILEENVELOPE should work', async () => {

test('ST_TILEENVELOPE should fail if any NULL argument', async () => {
const query = `
SELECT \`@@BQ_DATASET@@.ST_TILEENVELOPE\`(10, 384, null)
SELECT \`@@BQ_DATASET@@.ST_TILEENVELOPE\`(10, 384, null) AS geog
`;
await expect(runQuery(query)).rejects.toThrow();
const rows = await runQuery(query);
expect(rows.length).toEqual(1);
expect(rows[0].geog).toEqual(null);
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ test('ST_TILEENVELOPE should work', async () => {
expect(JSON.stringify(rows[0].GEOG3)).toEqual('{"coordinates":[[[-44.99998927116395,45.000002199069606],[-44.99998927116395,44.99999461263666],[-45,44.99999461263666],[-45,45.000002199069606],[-44.99998927116395,45.000002199069606]]],"type":"Polygon"}');
});

test('ST_TILEENVELOPE should fail if any NULL argument', async () => {
test('ST_TILEENVELOPE should return NULL if any NULL argument', async () => {
const query = `
SELECT ST_TILEENVELOPE(10, 384, null)
SELECT ST_TILEENVELOPE(10, 384, null) as geog
`;
await expect(runQuery(query)).rejects.toThrow();
const rows = await runQuery(query);
expect(rows.length).toEqual(1);
expect(rows[0].GEOG).toEqual(null);
});

0 comments on commit 006c30d

Please sign in to comment.