diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-12 10:03:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-12 10:03:37 +0000 |
commit | 24e839c04c39d1f4423b267c371e8e5b5bc33867 (patch) | |
tree | 2395ec71424fe1ff783e0dc7ca0f9b4e16def8a9 /tests/dialects/test_snowflake.py | |
parent | Adding upstream version 10.6.3. (diff) | |
download | sqlglot-24e839c04c39d1f4423b267c371e8e5b5bc33867.tar.xz sqlglot-24e839c04c39d1f4423b267c371e8e5b5bc33867.zip |
Adding upstream version 11.0.1.upstream/11.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_snowflake.py')
-rw-r--r-- | tests/dialects/test_snowflake.py | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py index f3e8e24..201cc4e 100644 --- a/tests/dialects/test_snowflake.py +++ b/tests/dialects/test_snowflake.py @@ -6,6 +6,43 @@ class TestSnowflake(Validator): dialect = "snowflake" def test_snowflake(self): + self.validate_identity("SELECT REGEXP_LIKE(a, b, c)") + self.validate_identity("PUT file:///dir/tmp.csv @%table") + self.validate_identity("CREATE TABLE foo (bar FLOAT AUTOINCREMENT START 0 INCREMENT 1)") + self.validate_identity( + 'COPY INTO NEW_TABLE ("foo", "bar") FROM (SELECT $1, $2, $3, $4 FROM @%old_table)' + ) + + self.validate_all( + "CREATE OR REPLACE TEMPORARY TABLE x (y NUMBER IDENTITY(0, 1))", + write={ + "snowflake": "CREATE OR REPLACE TEMPORARY TABLE x (y DECIMAL AUTOINCREMENT START 0 INCREMENT 1)", + }, + ) + self.validate_all( + "CREATE TEMPORARY TABLE x (y NUMBER AUTOINCREMENT(0, 1))", + write={ + "snowflake": "CREATE TEMPORARY TABLE x (y DECIMAL AUTOINCREMENT START 0 INCREMENT 1)", + }, + ) + self.validate_all( + "CREATE TABLE x (y NUMBER IDENTITY START 0 INCREMENT 1)", + write={ + "snowflake": "CREATE TABLE x (y DECIMAL AUTOINCREMENT START 0 INCREMENT 1)", + }, + ) + self.validate_all( + "ALTER TABLE foo ADD COLUMN id INT identity(1, 1)", + write={ + "snowflake": "ALTER TABLE foo ADD COLUMN id INT AUTOINCREMENT START 1 INCREMENT 1", + }, + ) + self.validate_all( + "SELECT DAYOFWEEK('2016-01-02T23:39:20.123-07:00'::TIMESTAMP)", + write={ + "snowflake": "SELECT DAYOFWEEK(CAST('2016-01-02T23:39:20.123-07:00' AS TIMESTAMPNTZ))", + }, + ) self.validate_all( "SELECT * FROM xxx WHERE col ilike '%Don''t%'", write={ @@ -165,10 +202,10 @@ class TestSnowflake(Validator): self.validate_all( r"SELECT $$a ' \ \t \x21 z $ $$", write={ - "snowflake": r"SELECT 'a \' \\ \\t \\x21 z $ '", + "snowflake": r"SELECT 'a \' \\ \t \\x21 z $ '", }, ) - self.validate_identity("SELECT REGEXP_LIKE(a, b, c)") + self.validate_identity(r"REGEXP_REPLACE('target', 'pattern', '\n')") self.validate_all( "SELECT RLIKE(a, b)", write={ @@ -253,6 +290,8 @@ class TestSnowflake(Validator): ) def test_timestamps(self): + self.validate_identity("SELECT EXTRACT(month FROM a)") + self.validate_all( "SELECT CAST(a AS TIMESTAMP)", write={ @@ -277,7 +316,6 @@ class TestSnowflake(Validator): "snowflake": "SELECT CAST(a AS TIMESTAMPLTZ)", }, ) - self.validate_identity("SELECT EXTRACT(month FROM a)") self.validate_all( "SELECT EXTRACT('month', a)", write={ @@ -313,6 +351,8 @@ class TestSnowflake(Validator): def test_semi_structured_types(self): self.validate_identity("SELECT CAST(a AS VARIANT)") + self.validate_identity("SELECT CAST(a AS ARRAY)") + self.validate_all( "SELECT a::VARIANT", write={ @@ -320,7 +360,6 @@ class TestSnowflake(Validator): "tsql": "SELECT CAST(a AS SQL_VARIANT)", }, ) - self.validate_identity("SELECT CAST(a AS ARRAY)") self.validate_all( "ARRAY_CONSTRUCT(0, 1, 2)", write={ @@ -343,6 +382,7 @@ class TestSnowflake(Validator): "CREATE TABLE a (x DATE, y BIGINT) WITH (PARTITION BY (x), integration='q', auto_refresh=TRUE, file_format=(type = parquet))" ) self.validate_identity("CREATE MATERIALIZED VIEW a COMMENT='...' AS SELECT 1 FROM x") + self.validate_all( "CREATE OR REPLACE TRANSIENT TABLE a (id INT)", read={ |