-
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.
Showing
16 changed files
with
201 additions
and
69 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
e2e/projects/snowflake-npm-features/models/data_types/variant.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 |
---|---|---|
@@ -1,5 +1,10 @@ | ||
SELECT | ||
CAST('1234567' AS VARIANT), | ||
CAST(1 AS VARIANT), | ||
CAST(1 AS VARIANT) + 1, | ||
CAST(1 AS VARIANT) - 1, | ||
CAST(1 AS VARIANT) * 1, | ||
CAST(1 AS VARIANT) / 1, | ||
CAST(1 AS VARIANT) % 1, | ||
-- TODO: fix casting array to variant | ||
-- CAST(STRTOK_TO_ARRAY('1 2') AS VARIANT)[0], |
3 changes: 3 additions & 0 deletions
3
e2e/projects/snowflake-npm-features/models/functions/aggregate/aggregate_without_from.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,3 @@ | ||
select | ||
count(*), | ||
count((select 1)) |
49 changes: 25 additions & 24 deletions
49
e2e/projects/snowflake-npm-features/models/functions/aggregate/approx_top_k.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 |
---|---|---|
@@ -1,25 +1,26 @@ | ||
WITH product_data AS ( | ||
SELECT 'Red' AS color | ||
UNION ALL | ||
SELECT 'Red' | ||
UNION ALL | ||
SELECT 'Green' | ||
UNION ALL | ||
SELECT 'Blue' | ||
UNION ALL | ||
SELECT 'Blue' | ||
UNION ALL | ||
SELECT 'Yellow' | ||
UNION ALL | ||
SELECT 'Red' | ||
UNION ALL | ||
SELECT 'Blue' | ||
UNION ALL | ||
SELECT 'Green' | ||
UNION ALL | ||
SELECT 'Yellow' | ||
WITH TestData AS ( | ||
SELECT 'A' AS Category, 10 AS Value UNION ALL | ||
SELECT 'A' AS Category, 15 AS Value UNION ALL | ||
SELECT 'A' AS Category, 20 AS Value UNION ALL | ||
SELECT 'B' AS Category, 5 AS Value UNION ALL | ||
SELECT 'B' AS Category, 25 AS Value UNION ALL | ||
SELECT 'C' AS Category, 30 AS Value | ||
), | ||
|
||
ApproxTopKData AS ( | ||
SELECT | ||
Category, | ||
Value, | ||
APPROX_TOP_K(Value, 2) AS TopK_Values | ||
FROM TestData | ||
GROUP BY Category, Value | ||
) | ||
-- Query using APPROX_TOP_K function | ||
SELECT color, frequency | ||
FROM APPROX_TOP_K(color, 3) OVER () | ||
FROM product_data; | ||
|
||
SELECT | ||
Category, | ||
Value, | ||
TopK_Values, | ||
ROW_NUMBER() OVER(PARTITION BY Category ORDER BY TopK_Values DESC) AS RankWithinCategory | ||
FROM ApproxTopKData | ||
WHERE ARRAY_CONTAINS(Value, TopK_Values) | ||
ORDER BY Category, RankWithinCategory; |
26 changes: 26 additions & 0 deletions
26
e2e/projects/snowflake-npm-features/models/functions/aggregate/approx_top_k2.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,26 @@ | ||
WITH TestData AS ( | ||
SELECT 'A' AS Category, 10 AS Value UNION ALL | ||
SELECT 'A' AS Category, 15 AS Value UNION ALL | ||
SELECT 'A' AS Category, 20 AS Value UNION ALL | ||
SELECT 'B' AS Category, 5 AS Value UNION ALL | ||
SELECT 'B' AS Category, 25 AS Value UNION ALL | ||
SELECT 'C' AS Category, 30 AS Value | ||
), | ||
|
||
ApproxTopKData AS ( | ||
SELECT | ||
Category, | ||
Value, | ||
APPROX_TOP_K(Value, 2) AS TopK_Values | ||
FROM TestData | ||
GROUP BY Category, Value | ||
) | ||
|
||
SELECT | ||
Category, | ||
Value, | ||
TopK_Values, | ||
ROW_NUMBER() OVER(PARTITION BY Category ORDER BY TopK_Values DESC) AS RankWithinCategory | ||
FROM ApproxTopKData | ||
WHERE ARRAY_CONTAINS(Value, TopK_Values) | ||
ORDER BY Category, RankWithinCategory; |
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
35 changes: 23 additions & 12 deletions
35
e2e/projects/snowflake-npm-features/models/functions/aggregate/grouping.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 |
---|---|---|
@@ -1,13 +1,24 @@ | ||
WITH sales_data AS ( | ||
SELECT 'A' AS product, '2022-01' AS month, 10 AS revenue | ||
UNION ALL | ||
SELECT 'A', '2022-02', 15 | ||
UNION ALL | ||
SELECT 'B', '2022-01', 20 | ||
UNION ALL | ||
SELECT 'B', '2022-02', 25 | ||
WITH TestData AS ( | ||
SELECT 'A' AS Col1, 'X' AS Col2, 10 AS Col3, TRUE AS IsTrue UNION ALL | ||
SELECT 'A', 'Y', 20, FALSE UNION ALL | ||
SELECT 'A', 'Y', 30, TRUE UNION ALL | ||
SELECT 'B', 'X', 40, FALSE UNION ALL | ||
SELECT 'B', 'Z', 50, TRUE UNION ALL | ||
SELECT 'B', 'Z', 60, FALSE | ||
) | ||
SELECT product, month, SUM(revenue) AS total_revenue, GROUPING(product) AS product_grouping, GROUPING(month) AS month_grouping | ||
FROM sales_data | ||
GROUP BY GROUPING SETS ((product, month), (product), (month)) | ||
ORDER BY product, month; | ||
|
||
SELECT | ||
Col1, | ||
Col2, | ||
Col3, | ||
IsTrue, | ||
GROUPING(Col1) AS GroupingID_Col1, | ||
GROUPING(Col2) AS GroupingID_Col2, | ||
GROUPING(Col3) AS GroupingID_Col3, | ||
GROUPING(IsTrue) AS GroupingID_IsTrue, | ||
GROUPING(Col1, Col2) AS GroupingID_Col1_Col2, | ||
GROUPING(Col1, Col2, Col3, IsTrue) AS GroupingID_Col1_Col2_Col3_IsTrue | ||
FROM | ||
TestData | ||
GROUP BY | ||
ROLLUP (Col1, Col2, Col3, IsTrue); |
24 changes: 24 additions & 0 deletions
24
e2e/projects/snowflake-npm-features/models/functions/aggregate/grouping_id2.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,24 @@ | ||
WITH TestData AS ( | ||
SELECT 'A' AS Col1, 'X' AS Col2, 10 AS Col3, TRUE AS IsTrue UNION ALL | ||
SELECT 'A', 'Y', 20, FALSE UNION ALL | ||
SELECT 'A', 'Y', 30, TRUE UNION ALL | ||
SELECT 'B', 'X', 40, FALSE UNION ALL | ||
SELECT 'B', 'Z', 50, TRUE UNION ALL | ||
SELECT 'B', 'Z', 60, FALSE | ||
) | ||
|
||
SELECT | ||
Col1, | ||
Col2, | ||
Col3, | ||
IsTrue, | ||
GROUPING_ID(Col1) AS GroupingID_Col1, | ||
GROUPING_ID(Col2) AS GroupingID_Col2, | ||
GROUPING_ID(Col3) AS GroupingID_Col3, | ||
GROUPING_ID(IsTrue) AS GroupingID_IsTrue, | ||
GROUPING_ID(Col1, Col2) AS GroupingID_Col1_Col2, | ||
GROUPING_ID(Col1, Col2, Col3, IsTrue) AS GroupingID_Col1_Col2_Col3_IsTrue | ||
FROM | ||
TestData | ||
GROUP BY | ||
ROLLUP (Col1, Col2, Col3, IsTrue); |
26 changes: 12 additions & 14 deletions
26
e2e/projects/snowflake-npm-features/models/functions/conditional_expression/decode.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 |
---|---|---|
@@ -1,16 +1,14 @@ | ||
WITH sample_data AS ( | ||
SELECT 1 AS id, 'A' AS grade | ||
UNION ALL | ||
SELECT 2, 'B' | ||
UNION ALL | ||
SELECT 3, 'A' | ||
UNION ALL | ||
SELECT 4, 'C' | ||
UNION ALL | ||
SELECT 5, 'B' | ||
WITH test_data AS ( | ||
SELECT 1 AS id, 'A' AS value UNION ALL | ||
SELECT 2, 'B' UNION ALL | ||
SELECT 3, 'C' UNION ALL | ||
SELECT 4, 'D' | ||
) | ||
|
||
SELECT id, | ||
grade, | ||
DECODE(grade, 'A', 'Excellent', 'B', 'Good', 'C', 'Average', 'Unknown') AS performance | ||
FROM sample_data; | ||
SELECT | ||
id, | ||
value, | ||
DECODE(value, 'A', 'First', 'B', 'Second', 'Unknown') AS decode_simple, | ||
DECODE(value, 'A', 'First', 'B', 'Second', 'C', 'Third', 'Unknown') AS decode_extended, | ||
DECODE(value, 'A', 'First', 'B', 'Second', 'C', 'Third', 'D', 'Fourth', 'Unknown') AS decode_full | ||
FROM test_data; |
19 changes: 18 additions & 1 deletion
19
e2e/projects/snowflake-npm-features/models/functions/conditional_expression/iff.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 |
---|---|---|
@@ -1 +1,18 @@ | ||
select iff(True, 'true', 'false'); | ||
WITH test_data AS ( | ||
SELECT 1 AS id, 'A' AS value, 10 AS num UNION ALL | ||
SELECT 2, 'B', 20 UNION ALL | ||
SELECT 3, 'C', 30 UNION ALL | ||
SELECT 4, 'D', 40 | ||
) | ||
|
||
SELECT | ||
id, | ||
value, | ||
num, | ||
IFF(value = 'A', 'First', 'Not First') AS iff_simple, | ||
IFF(num > 20, 'Greater than 20', 'Less than 20') AS iff_extended, | ||
IFF(false, true, false), | ||
IFF(true, true, false), | ||
IFF(false, true, 'false'), | ||
IFF(true, 'true', false) | ||
FROM test_data; |
32 changes: 18 additions & 14 deletions
32
e2e/projects/snowflake-npm-features/models/functions/conditional_expression/nvl.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 |
---|---|---|
@@ -1,16 +1,20 @@ | ||
WITH sample_data AS ( | ||
SELECT 1 AS id, NULL AS score | ||
UNION ALL | ||
SELECT 2, 80 | ||
UNION ALL | ||
SELECT 3, 90 | ||
UNION ALL | ||
SELECT 4, NULL | ||
UNION ALL | ||
SELECT 5, 75 | ||
WITH test_data AS ( | ||
SELECT NULL AS col1, 'Hello' AS col2, 100 AS col3 | ||
UNION ALL | ||
SELECT 'World', NULL, 200 | ||
UNION ALL | ||
SELECT NULL, NULL, NULL | ||
) | ||
|
||
SELECT id, | ||
score, | ||
NVL(score, 0) AS score_with_default | ||
FROM sample_data; | ||
SELECT | ||
col1, | ||
col2, | ||
col3, | ||
NVL(col1, 'Default') AS nvl_col1_string, | ||
NVL(col2, 'Default') AS nvl_col2_string, | ||
NVL(col3, 0) AS nvl_col3_int, | ||
NVL(null, 1), | ||
NVL(1, 2), | ||
NVL(col3, 2), | ||
NVL(col3, col3) | ||
FROM test_data; |
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
9 changes: 9 additions & 0 deletions
9
e2e/projects/snowflake-npm-features/models/joins/consiquent_on.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,9 @@ | ||
WITH cte1 AS (SELECT 1 AS a), | ||
cte2 AS (SELECT 1 AS a), | ||
cte3 AS (SELECT 1 AS a) | ||
|
||
SELECT * | ||
FROM cte1 c1 | ||
JOIN cte2 c2 | ||
JOIN cte3 c3 | ||
ON c1.a = c3.a |
10 changes: 10 additions & 0 deletions
10
e2e/projects/snowflake-npm-features/models/joins/consiquent_on2.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,10 @@ | ||
WITH cte1 AS (SELECT 1 AS a), | ||
cte2 AS (SELECT 1 AS a), | ||
cte3 AS (SELECT 1 AS a) | ||
|
||
SELECT * | ||
FROM cte1 c1 | ||
JOIN cte2 c2 | ||
JOIN cte3 c3 | ||
ON c2.a = c3.a | ||
ON c1.a = c3.a |
8 changes: 8 additions & 0 deletions
8
e2e/projects/snowflake-npm-features/models/joins/consiquent_on3.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,8 @@ | ||
WITH cte1 AS (SELECT 1 AS a), | ||
cte2 AS (SELECT 1 AS a), | ||
cte3 AS (SELECT 1 AS a) | ||
|
||
SELECT * | ||
FROM cte1 c1, cte2 c2 | ||
JOIN cte3 c3 | ||
ON c2.a = c3.a |
11 changes: 11 additions & 0 deletions
11
e2e/projects/snowflake-npm-features/models/joins/consiquent_on4.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,11 @@ | ||
WITH cte1 AS (SELECT 1 AS a), | ||
cte2 AS (SELECT 1 AS a), | ||
cte3 AS (SELECT 1 AS a), | ||
cte4 AS (SELECT 1 AS a) | ||
|
||
SELECT * | ||
FROM cte1 c1, cte2 c2 | ||
JOIN cte3 c3 | ||
JOIN cte4 c4 | ||
ON c3.a = c4.a | ||
ON c2.a = c4.a |