diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-10-26 17:21:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-10-26 17:21:50 +0000 |
commit | 6c774776db5e016d597e582c7006ba8d27006f9d (patch) | |
tree | 8a65b7a9938002f9b152d9a6dfd150f15e402a6b /tests/dialects/test_redshift.py | |
parent | Adding upstream version 18.13.0. (diff) | |
download | sqlglot-6c774776db5e016d597e582c7006ba8d27006f9d.tar.xz sqlglot-6c774776db5e016d597e582c7006ba8d27006f9d.zip |
Adding upstream version 18.17.0.upstream/18.17.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_redshift.py')
-rw-r--r-- | tests/dialects/test_redshift.py | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/tests/dialects/test_redshift.py b/tests/dialects/test_redshift.py index f182feb..c848010 100644 --- a/tests/dialects/test_redshift.py +++ b/tests/dialects/test_redshift.py @@ -6,6 +6,10 @@ class TestRedshift(Validator): dialect = "redshift" def test_redshift(self): + self.validate_identity( + "SELECT * FROM x WHERE y = DATEADD('month', -1, DATE_TRUNC('month', (SELECT y FROM #temp_table)))", + "SELECT * FROM x WHERE y = DATEADD(month, -1, CAST(DATE_TRUNC('month', (SELECT y FROM #temp_table)) AS DATE))", + ) self.validate_all( "SELECT APPROXIMATE COUNT(DISTINCT y)", read={ @@ -16,13 +20,6 @@ class TestRedshift(Validator): "spark": "SELECT APPROX_COUNT_DISTINCT(y)", }, ) - self.validate_identity("SELECT APPROXIMATE AS y") - - self.validate_identity( - "SELECT 'a''b'", - "SELECT 'a\\'b'", - ) - self.validate_all( "x ~* 'pat'", write={ @@ -30,7 +27,6 @@ class TestRedshift(Validator): "snowflake": "REGEXP_LIKE(x, 'pat', 'i')", }, ) - self.validate_all( "SELECT CAST('01:03:05.124' AS TIME(2) WITH TIME ZONE)", read={ @@ -248,6 +244,19 @@ class TestRedshift(Validator): self.validate_identity("CAST('foo' AS HLLSKETCH)") self.validate_identity("'abc' SIMILAR TO '(b|c)%'") self.validate_identity("CREATE TABLE datetable (start_date DATE, end_date DATE)") + self.validate_identity("SELECT APPROXIMATE AS y") + self.validate_identity("CREATE TABLE t (c BIGINT IDENTITY(0, 1))") + self.validate_identity( + "SELECT 'a''b'", + "SELECT 'a\\'b'", + ) + self.validate_identity( + "CREATE TABLE t (c BIGINT GENERATED BY DEFAULT AS IDENTITY (0, 1))", + "CREATE TABLE t (c BIGINT IDENTITY(0, 1))", + ) + self.validate_identity( + "CREATE OR REPLACE VIEW v1 AS SELECT id, AVG(average_metric1) AS m1, AVG(average_metric2) AS m2 FROM t GROUP BY id WITH NO SCHEMA BINDING" + ) self.validate_identity( "SELECT caldate + INTERVAL '1 second' AS dateplus FROM date WHERE caldate = '12-31-2008'" ) @@ -301,6 +310,7 @@ ORDER BY self.validate_identity( "SELECT attr AS attr, JSON_TYPEOF(val) AS value_type FROM customer_orders_lineitem AS c, UNPIVOT c.c_orders AS val AT attr WHERE c_custkey = 9451" ) + self.validate_identity("SELECT JSON_PARSE('[]')") def test_values(self): # Test crazy-sized VALUES clause to UNION ALL conversion to ensure we don't get RecursionError |