-
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.
Merge pull request #14 from Snowflake-Labs/antlr-parser
Added test module
- Loading branch information
Showing
35 changed files
with
121,007 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
# DLSync Backlog | ||
- [x] Rollback for migration | ||
- [x] Verify module State Script | ||
- [x] create script to capture config tables | ||
- [x] Script hierarchy design | ||
- [x] Verify module for migration Script | ||
- [ ] Migration Script parsing using ATLR | ||
- [ ] Support for different DB | ||
- [ ] use config file for connection properties | ||
- [ ] create command line application | ||
- [ ] use antlr4 for verify module |
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
8 changes: 8 additions & 0 deletions
8
example_scripts/main/example_db/MAIN_SCHEMA/FUNCTIONS/GET_RETURNED_ORDERS.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 @@ | ||
CREATE OR REPLACE FUNCTION ${EXAMPLE_DB}.${MAIN_SCHEMA}.GET_RETURNED_ORDERS(USER VARCHAR) | ||
RETURNS NUMERIC(10, 2) | ||
LANGUAGE SQL | ||
AS | ||
$$ | ||
SELECT COUNT(*) FROM ${EXAMPLE_DB}.${MAIN_SCHEMA}.ORDER_RETURNS | ||
WHERE USER_ID = USER | ||
$$ |
10 changes: 10 additions & 0 deletions
10
example_scripts/main/example_db/MAIN_SCHEMA/TABLES/ORDER_RETURNS.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 @@ | ||
---version: 0, author: DlSync | ||
CREATE TABLE ${EXAMPLE_DB}.${MAIN_SCHEMA}.ORDER_RETURNS ( | ||
ID INT AUTOINCREMENT PRIMARY KEY, | ||
USER_ID INT REFERENCES ${EXAMPLE_DB}.${MAIN_SCHEMA}.USERS(ID), | ||
ORDER_ID INT REFERENCES ${EXAMPLE_DB}.${MAIN_SCHEMA}.ORDERS(ID), | ||
REASON VARCHAR, | ||
RETURN_DATE TIMESTAMP DEFAULT CURRENT_TIMESTAMP | ||
); | ||
---rollback: DROP TABLE IF EXISTS ${EXAMPLE_DB}.${MAIN_SCHEMA}.ORDER_RETURNS; | ||
---verify: SELECT * FROM ${EXAMPLE_DB}.${MAIN_SCHEMA}.ORDER_RETURNS LIMIT 1; |
7 changes: 7 additions & 0 deletions
7
example_scripts/test/example_db/MAIN_SCHEMA/FUNCTIONS/CALCULATE_DISCOUNT_TEST.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,7 @@ | ||
with MOCK_DATA AS ( | ||
SELECT 100 AS P_PRICE, 10 AS P_DISCOUNT_RATE | ||
), | ||
EXPECTED_DATA AS ( | ||
SELECT 90 AS RETURN_VALUE | ||
) | ||
SELECT CALCULATE_ORDER_TOTAL(P_PRICE, P_DISCOUNT_RATE) AS RETURN_VALUE from MOCK_DATA; |
10 changes: 10 additions & 0 deletions
10
example_scripts/test/example_db/MAIN_SCHEMA/FUNCTIONS/GET_RETURNED_ORDERS_TEST.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 MOCK_DATA AS ( | ||
SELECT 1 AS USER | ||
), | ||
ORDER_RETURNS AS ( | ||
SELECT * FROM VALUES(1, 1, 1, 'broken'), (2, 1, 2, 'not arrived'), (3, 2, 3, 'quality') AS T(ID, USER_ID, ORDER_ID, RETURNED_QUANTITY) | ||
), | ||
EXPECTED_DATA AS ( | ||
SELECT 2 AS RETURN_VALUE | ||
) | ||
SELECT GET_RETURNED_ORDERS(USER) AS RETURN_VALUE from MOCK_DATA; |
7 changes: 7 additions & 0 deletions
7
example_scripts/test/example_db/MAIN_SCHEMA/VIEWS/STOCK_SUMMARY_TEST.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,7 @@ | ||
WITH PRODUCTS AS ( | ||
SELECT * FROM VALUES(1, 'Product 1', 5, 100), (2, 'Product 2', 20, 50), (3, 'Product 3', 30, 5) AS T(ID, PRODUCT_NAME, STOCK, PRICE) | ||
), | ||
EXPECTED_DATA AS ( | ||
SELECT * FROM VALUES(1, 'Product 1', 5, 'LOW STOCK'), (2, 'Product 2', 20, 'SUFFICIENT STOCK'), (3, 'Product 3', 30, 'SUFFICIENT STOCK') AS T(ID, PRODUCT_NAME, STOCK, STOCK_STATUS) | ||
) | ||
SELECT * FROM STOCK_SUMMARY; |
13 changes: 13 additions & 0 deletions
13
example_scripts/test/example_db/MAIN_SCHEMA/VIEWS/USER_ORDER_SUMMARY_TEST.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,13 @@ | ||
WITH USERS AS ( | ||
SELECT * FROM VALUES(1, 'Alice'), (2, 'Bob') AS T(ID, USER_NAME) | ||
), | ||
ORDERS AS ( | ||
SELECT * FROM VALUES(1, 1, 1, 10), (2, 1, 2, 20), (3, 2, 3, 30) AS T(ID, USER_ID, PRODUCT_ID, QUANTITY) | ||
), | ||
PRODUCTS AS ( | ||
SELECT * FROM VALUES(1, 'Product 1', 100), (2, 'Product 2', 50), (3, 'Product 3', 5) AS T(ID, PRODUCT_NAME, PRICE) | ||
), | ||
EXPECTED_DATA AS ( | ||
SELECT * FROM VALUES(1, 'Alice', 2, 2000), (2, 'Bob', 1, 150) AS T(USER_ID, USER_NAME, TOTAL_ORDERS, TOTAL_SPENT) | ||
) | ||
SELECT * FROM ${EXAMPLE_DB}.${MAIN_SCHEMA}.USER_ORDER_SUMMARY; |
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 @@ | ||
releaseVersion=1.5.0 | ||
releaseVersion=2.0.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
Oops, something went wrong.