-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sf|quadbin): QUADBIN_TOPARENT not working with views (#476)
- Loading branch information
1 parent
3f399b0
commit d31d3ed
Showing
7 changed files
with
180 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 17 additions & 1 deletion
18
clouds/snowflake/modules/test/quadbin/QUADBIN_TOPARENT.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,24 @@ | ||
const { runQuery } = require('../../../common/test-utils'); | ||
const { runQuery, deleteTable, deleteView } = require('../../../common/test-utils'); | ||
|
||
test('QUADBIN_TOPARENT should work', async () => { | ||
const query = 'SELECT CAST(QUADBIN_TOPARENT(5209574053332910079, 3) AS STRING) AS OUTPUT'; | ||
const rows = await runQuery(query); | ||
expect(rows.length).toEqual(1); | ||
expect(rows[0].OUTPUT).toEqual('5205105638077628415'); | ||
}); | ||
|
||
test('QUADBIN_TOPARENT should work with nested functions when readin data from views', async () => { | ||
const inputTable = '@@SF_SCHEMA@@.coords_sample'; | ||
const inputTableView = '@@SF_SCHEMA@@.test_quadbin_toparent_view'; | ||
|
||
query = `CREATE VIEW IF NOT EXISTS ${inputTableView} AS | ||
SELECT * FROM ${inputTable};`; | ||
await runQuery(query); | ||
|
||
query = `SELECT CAST(QUADBIN_TOPARENT(QUADBIN_FROMLONGLAT(long, lat, zoom), 6) AS STRING) AS OUTPUT | ||
FROM ${inputTableView};`; | ||
const rows = await runQuery(query); | ||
expect(rows.length).toEqual(120); | ||
|
||
deleteView(inputTableView); | ||
}); |
120 changes: 120 additions & 0 deletions
120
clouds/snowflake/modules/test/quadbin/fixtures/coords_sample.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
SELECT 9 AS zoom,-180.000000 as long,36.000000 as lat | ||
UNION ALL SELECT 8,-180.000000,54.000000 | ||
UNION ALL SELECT 9,-180.000000,54.000000 | ||
UNION ALL SELECT 7,-180.000000,18.000000 | ||
UNION ALL SELECT 8,-180.000000,18.000000 | ||
UNION ALL SELECT 8,-180.000000,72.000000 | ||
UNION ALL SELECT 9,-180.000000,72.000000 | ||
UNION ALL SELECT 7,-180.000000,54.000000 | ||
UNION ALL SELECT 7,-144.000000,18.000000 | ||
UNION ALL SELECT 8,-144.000000,18.000000 | ||
UNION ALL SELECT 8,-144.000000,36.000000 | ||
UNION ALL SELECT 8,-72.000000,54.000000 | ||
UNION ALL SELECT 9,-72.000000,54.000000 | ||
UNION ALL SELECT 7,-72.000000,72.000000 | ||
UNION ALL SELECT 7,-36.000000,18.000000 | ||
UNION ALL SELECT 9,0.000000,54.000000 | ||
UNION ALL SELECT 9,0.000000,72.000000 | ||
UNION ALL SELECT 7,-180.000000,36.000000 | ||
UNION ALL SELECT 8,-180.000000,36.000000 | ||
UNION ALL SELECT 7,-180.000000,72.000000 | ||
UNION ALL SELECT 9,-144.000000,18.000000 | ||
UNION ALL SELECT 7,-144.000000,36.000000 | ||
UNION ALL SELECT 9,-144.000000,54.000000 | ||
UNION ALL SELECT 7,-108.000000,72.000000 | ||
UNION ALL SELECT 9,-36.000000,18.000000 | ||
UNION ALL SELECT 7,144.000000,18.000000 | ||
UNION ALL SELECT 9,-180.000000,18.000000 | ||
UNION ALL SELECT 9,-144.000000,36.000000 | ||
UNION ALL SELECT 7,-144.000000,54.000000 | ||
UNION ALL SELECT 8,-144.000000,54.000000 | ||
UNION ALL SELECT 7,-108.000000,54.000000 | ||
UNION ALL SELECT 8,-108.000000,54.000000 | ||
UNION ALL SELECT 8,-108.000000,72.000000 | ||
UNION ALL SELECT 7,-72.000000,54.000000 | ||
UNION ALL SELECT 9,-72.000000,72.000000 | ||
UNION ALL SELECT 8,-36.000000,18.000000 | ||
UNION ALL SELECT 7,-36.000000,36.000000 | ||
UNION ALL SELECT 8,-36.000000,36.000000 | ||
UNION ALL SELECT 7,0.000000,54.000000 | ||
UNION ALL SELECT 8,0.000000,54.000000 | ||
UNION ALL SELECT 7,0.000000,72.000000 | ||
UNION ALL SELECT 8,36.000000,18.000000 | ||
UNION ALL SELECT 9,36.000000,18.000000 | ||
UNION ALL SELECT 7,72.000000,36.000000 | ||
UNION ALL SELECT 8,72.000000,36.000000 | ||
UNION ALL SELECT 9,0.000000,36.000000 | ||
UNION ALL SELECT 8,144.000000,18.000000 | ||
UNION ALL SELECT 9,144.000000,18.000000 | ||
UNION ALL SELECT 7,-144.000000,72.000000 | ||
UNION ALL SELECT 8,-144.000000,72.000000 | ||
UNION ALL SELECT 8,-108.000000,36.000000 | ||
UNION ALL SELECT 9,-108.000000,36.000000 | ||
UNION ALL SELECT 7,-72.000000,18.000000 | ||
UNION ALL SELECT 9,-72.000000,18.000000 | ||
UNION ALL SELECT 7,-72.000000,36.000000 | ||
UNION ALL SELECT 9,-72.000000,36.000000 | ||
UNION ALL SELECT 8,-36.000000,54.000000 | ||
UNION ALL SELECT 7,0.000000,18.000000 | ||
UNION ALL SELECT 8,0.000000,18.000000 | ||
UNION ALL SELECT 9,0.000000,18.000000 | ||
UNION ALL SELECT 8,36.000000,54.000000 | ||
UNION ALL SELECT 8,36.000000,72.000000 | ||
UNION ALL SELECT 7,72.000000,18.000000 | ||
UNION ALL SELECT 8,72.000000,18.000000 | ||
UNION ALL SELECT 7,108.000000,54.000000 | ||
UNION ALL SELECT 9,108.000000,54.000000 | ||
UNION ALL SELECT 7,144.000000,36.000000 | ||
UNION ALL SELECT 8,144.000000,36.000000 | ||
UNION ALL SELECT 9,144.000000,54.000000 | ||
UNION ALL SELECT 9,-36.000000,72.000000 | ||
UNION ALL SELECT 8,-72.000000,36.000000 | ||
UNION ALL SELECT 7,36.000000,72.000000 | ||
UNION ALL SELECT 8,108.000000,18.000000 | ||
UNION ALL SELECT 9,144.000000,72.000000 | ||
UNION ALL SELECT 7,108.000000,72.000000 | ||
UNION ALL SELECT 9,108.000000,72.000000 | ||
UNION ALL SELECT 9,-108.000000,54.000000 | ||
UNION ALL SELECT 9,-108.000000,72.000000 | ||
UNION ALL SELECT 7,0.000000,36.000000 | ||
UNION ALL SELECT 8,0.000000,36.000000 | ||
UNION ALL SELECT 8,0.000000,72.000000 | ||
UNION ALL SELECT 7,36.000000,18.000000 | ||
UNION ALL SELECT 7,36.000000,36.000000 | ||
UNION ALL SELECT 8,36.000000,36.000000 | ||
UNION ALL SELECT 9,36.000000,36.000000 | ||
UNION ALL SELECT 9,72.000000,36.000000 | ||
UNION ALL SELECT 9,-144.000000,72.000000 | ||
UNION ALL SELECT 7,-108.000000,36.000000 | ||
UNION ALL SELECT 8,-72.000000,18.000000 | ||
UNION ALL SELECT 7,-36.000000,54.000000 | ||
UNION ALL SELECT 9,-36.000000,54.000000 | ||
UNION ALL SELECT 9,36.000000,54.000000 | ||
UNION ALL SELECT 9,72.000000,18.000000 | ||
UNION ALL SELECT 7,72.000000,54.000000 | ||
UNION ALL SELECT 8,72.000000,54.000000 | ||
UNION ALL SELECT 9,72.000000,54.000000 | ||
UNION ALL SELECT 7,72.000000,72.000000 | ||
UNION ALL SELECT 9,108.000000,18.000000 | ||
UNION ALL SELECT 9,144.000000,36.000000 | ||
UNION ALL SELECT 7,144.000000,54.000000 | ||
UNION ALL SELECT 8,144.000000,54.000000 | ||
UNION ALL SELECT 8,144.000000,72.000000 | ||
UNION ALL SELECT 7,-108.000000,18.000000 | ||
UNION ALL SELECT 9,-108.000000,18.000000 | ||
UNION ALL SELECT 8,-36.000000,72.000000 | ||
UNION ALL SELECT 8,-72.000000,72.000000 | ||
UNION ALL SELECT 7,36.000000,54.000000 | ||
UNION ALL SELECT 9,72.000000,72.000000 | ||
UNION ALL SELECT 7,108.000000,18.000000 | ||
UNION ALL SELECT 8,108.000000,54.000000 | ||
UNION ALL SELECT 7,-36.000000,72.000000 | ||
UNION ALL SELECT 7,108.000000,36.000000 | ||
UNION ALL SELECT 9,108.000000,36.000000 | ||
UNION ALL SELECT 8,108.000000,72.000000 | ||
UNION ALL SELECT 9,-36.000000,36.000000 | ||
UNION ALL SELECT 9,36.000000,72.000000 | ||
UNION ALL SELECT 8,72.000000,72.000000 | ||
UNION ALL SELECT 8,-108.000000,18.000000 | ||
UNION ALL SELECT 8,108.000000,36.000000 | ||
UNION ALL SELECT 7,144.000000,72.000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const { createTable, deleteTable } = require('../../../../common/test-utils'); | ||
|
||
async function initializeTables () { | ||
await Promise.all([ | ||
createTable( | ||
'coords_sample', | ||
'./test/quadbin/fixtures/coords_sample.sql' | ||
) | ||
]); | ||
} | ||
|
||
module.exports = initializeTables; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const { deleteTable } = require('../../../../common/test-utils'); | ||
|
||
async function deleteTables () { | ||
await Promise.all([ | ||
deleteTable('coords_sample') | ||
]); | ||
} | ||
|
||
module.exports = deleteTables; |