-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
191 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- pending: sqlite3 ANY_VALUES is not available. | ||
|
||
CREATE TEMP TABLE vals (i INT64); | ||
INSERT INTO vals VALUES (1), (1); | ||
|
||
CREATE OR REPLACE TABLE __result1 AS | ||
SELECT ANY_VALUE(i) AS any_value FROM vals; | ||
|
||
CREATE OR REPLACE TABLE __expected1 ( | ||
any_value INT64, | ||
); | ||
INSERT INTO __expected1 VALUES | ||
(1); |
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,15 @@ | ||
-- pending: snowflake Use APPROX_PERCENTILE instead of APPROX_QUANTILES (complicated) | ||
-- pending: sqlite3 No APPROX_QUANTILES function | ||
|
||
CREATE TEMP TABLE quantile_data (x INT64); | ||
INSERT INTO quantile_data VALUES (1), (2), (3), (4), (5); | ||
|
||
CREATE OR REPLACE TABLE __result1 AS | ||
SELECT APPROX_QUANTILES(x, 2) AS approx_quantiles | ||
FROM quantile_data; | ||
|
||
CREATE OR REPLACE TABLE __expected1 ( | ||
approx_quantiles ARRAY<INT64>, | ||
); | ||
INSERT INTO __expected1 VALUES | ||
([1, 3, 5]); |
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,14 @@ | ||
-- pending: snowflake COUNTIF can be rewritten portably by transpiler | ||
-- pending: sqlite3 COUNTIF Can be rewritten portably by transpiler | ||
|
||
CREATE TEMP TABLE vals (i INT64); | ||
INSERT INTO vals VALUES (1), (2), (2), (3), (NULL); | ||
|
||
CREATE OR REPLACE TABLE __result1 AS | ||
SELECT COUNTIF(i = 2) AS is2 FROM vals; | ||
|
||
CREATE OR REPLACE TABLE __expected1 ( | ||
is2 INT64, | ||
); | ||
INSERT INTO __expected1 VALUES | ||
(2); |
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,11 @@ | ||
-- pending: sqlite3 EXP is not available | ||
|
||
CREATE OR REPLACE TABLE __result1 AS | ||
SELECT | ||
EXP(0.0) AS exp_zero; | ||
|
||
CREATE OR REPLACE TABLE __expected1 ( | ||
exp_zero FLOAT64, | ||
); | ||
INSERT INTO __expected1 VALUES | ||
(1.0); |
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,11 @@ | ||
-- pending: sqlite3 Needs external function. | ||
|
||
CREATE OR REPLACE TABLE __result1 AS | ||
SELECT | ||
LENGTH(generate_uuid()) AS uuid_length; | ||
|
||
CREATE OR REPLACE TABLE __expected1 ( | ||
uuid_length INT64, | ||
); | ||
INSERT INTO __expected1 VALUES | ||
(36); |
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,19 @@ | ||
-- pending: sqlite3 GREATEST, LEAST are not available | ||
-- | ||
-- GREATEST, LEAST | ||
|
||
CREATE OR REPLACE TABLE __result1 AS | ||
SELECT | ||
GREATEST(1, 2, 3) AS greatest, | ||
GREATEST(1, NULL, 3) AS greatest_null, | ||
LEAST(1, 2, 3) AS least, | ||
LEAST(1, NULL, 3) AS least_null; | ||
|
||
CREATE OR REPLACE TABLE __expected1 ( | ||
greatest INT64, | ||
greatest_null INT64, | ||
least INT64, | ||
least_null INT64, | ||
); | ||
INSERT INTO __expected1 VALUES | ||
(3, NULL, 1, NULL); |
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,11 @@ | ||
-- pending: sqlite3 BigQuery RAND returns [0.0, 1.0), SQLite3 RANDOM() returns int | ||
|
||
CREATE OR REPLACE TABLE __result1 AS | ||
SELECT | ||
RAND() BETWEEN 0.0 AND 1.0 AS rand_in_range; | ||
|
||
CREATE OR REPLACE TABLE __expected1 ( | ||
rand_in_range BOOL, | ||
); | ||
INSERT INTO __expected1 VALUES | ||
(TRUE); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- pending: sqlite3 FIRST_VALUE, LAST_VALUE seem to require frames to work? | ||
|
||
-- FIRST_VALUE, LAST_VALUE | ||
|
||
-- A fixture table for testing window functions. | ||
CREATE TEMP TABLE groceries ( | ||
item STRING, | ||
category STRING, | ||
price FLOAT64, | ||
); | ||
INSERT INTO groceries VALUES | ||
('apple', 'fruit', 1.00), | ||
('banana', 'fruit', 1.50), | ||
('carrot', 'vegetable', 0.75), | ||
('eggplant', 'vegetable', 1.25), | ||
('sugar', 'baking', 0.50), | ||
('flour', 'baking', 0.25), | ||
('salt', 'baking', 0.75); | ||
|
||
CREATE OR REPLACE TABLE __result1 AS | ||
SELECT | ||
item, | ||
FIRST_VALUE(item) OVER (PARTITION BY category ORDER BY price) AS cheapest_alternative, | ||
LAST_VALUE(item) OVER (PARTITION BY category ORDER BY price) AS most_expensive_alternative, | ||
FROM groceries; | ||
|
||
CREATE OR REPLACE TABLE __expected1 ( | ||
item STRING, | ||
cheapest_alternative STRING, | ||
most_expensive_alternative STRING, | ||
); | ||
INSERT INTO __expected1 VALUES | ||
('apple', 'apple', 'banana'), | ||
('banana', 'apple', 'banana'), | ||
('carrot', 'carrot', 'eggplant'), | ||
('eggplant', 'carrot', 'eggplant'), | ||
('flour', 'flour', 'salt'), | ||
('sugar', 'flour', 'salt'), | ||
('salt', 'flour', 'salt'); |
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,19 @@ | ||
-- LAG | ||
|
||
CREATE TEMP TABLE fruits (idx INT64, fruit_name STRING); | ||
INSERT INTO fruits VALUES (1, 'apple'), (2, 'banana'), (3, 'cherry'); | ||
|
||
CREATE OR REPLACE TABLE __result1 AS | ||
SELECT | ||
fruit_name, | ||
LAG(fruit_name) OVER (ORDER BY idx) AS previous_fruit | ||
FROM fruits; | ||
|
||
CREATE OR REPLACE TABLE __expected1 ( | ||
fruit_name STRING, | ||
previous_fruit STRING, | ||
); | ||
INSERT INTO __expected1 VALUES | ||
('apple', NULL), | ||
('banana', 'apple'), | ||
('cherry', 'banana'); |