diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-31 07:55:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-31 07:55:38 +0000 |
commit | 139b61d941836298794fcbeb179dc49c43d3fd95 (patch) | |
tree | 5b978af9eb7d9a506a5f73b33b44dde7e9188fcb /tests/dialects/test_tsql.py | |
parent | Adding upstream version 25.7.1. (diff) | |
download | sqlglot-139b61d941836298794fcbeb179dc49c43d3fd95.tar.xz sqlglot-139b61d941836298794fcbeb179dc49c43d3fd95.zip |
Adding upstream version 25.8.1.upstream/25.8.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_tsql.py')
-rw-r--r-- | tests/dialects/test_tsql.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/dialects/test_tsql.py b/tests/dialects/test_tsql.py index 9658a02..cfdcb8d 100644 --- a/tests/dialects/test_tsql.py +++ b/tests/dialects/test_tsql.py @@ -49,6 +49,16 @@ class TestTSQL(Validator): ) self.validate_all( + "WITH A AS (SELECT 2 AS value), C AS (SELECT * FROM A) SELECT * INTO TEMP_NESTED_WITH FROM (SELECT * FROM C) AS temp", + read={ + "snowflake": "CREATE TABLE TEMP_NESTED_WITH AS WITH C AS (WITH A AS (SELECT 2 AS value) SELECT * FROM A) SELECT * FROM C", + "tsql": "WITH A AS (SELECT 2 AS value), C AS (SELECT * FROM A) SELECT * INTO TEMP_NESTED_WITH FROM (SELECT * FROM C) AS temp", + }, + write={ + "snowflake": "CREATE TABLE TEMP_NESTED_WITH AS WITH A AS (SELECT 2 AS value), C AS (SELECT * FROM A) SELECT * FROM (SELECT * FROM C) AS temp", + }, + ) + self.validate_all( "SELECT IIF(cond <> 0, 'True', 'False')", read={ "spark": "SELECT IF(cond, 'True', 'False')", @@ -797,6 +807,7 @@ class TestTSQL(Validator): f"UNIQUE {clustered_keyword} ([internal_id] ASC))", ) + self.validate_identity("CREATE VIEW t AS WITH cte AS (SELECT 1 AS c) SELECT c FROM cte") self.validate_identity( "ALTER TABLE tbl SET SYSTEM_VERSIONING=ON(HISTORY_TABLE=db.tbl, DATA_CONSISTENCY_CHECK=OFF, HISTORY_RETENTION_PERIOD=5 DAYS)" ) @@ -1135,6 +1146,11 @@ WHERE self.validate_all("ISNULL(x, y)", write={"spark": "COALESCE(x, y)"}) def test_json(self): + self.validate_identity( + """JSON_QUERY(REPLACE(REPLACE(x , '''', '"'), '""', '"'))""", + """ISNULL(JSON_QUERY(REPLACE(REPLACE(x, '''', '"'), '""', '"'), '$'), JSON_VALUE(REPLACE(REPLACE(x, '''', '"'), '""', '"'), '$'))""", + ) + self.validate_all( "JSON_QUERY(r.JSON, '$.Attr_INT')", write={ |