diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 20:07:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 20:07:58 +0000 |
commit | fc2b129d31cbb474bbebfa0baa8537238f6332ed (patch) | |
tree | 5c6055c1be787787ae2d13b144f280740e235f79 /tests/dialects/test_postgres.py | |
parent | Adding upstream version 24.0.0. (diff) | |
download | sqlglot-fc2b129d31cbb474bbebfa0baa8537238f6332ed.tar.xz sqlglot-fc2b129d31cbb474bbebfa0baa8537238f6332ed.zip |
Adding upstream version 24.1.0.upstream/24.1.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_postgres.py')
-rw-r--r-- | tests/dialects/test_postgres.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/dialects/test_postgres.py b/tests/dialects/test_postgres.py index 8ba4e96..38c262f 100644 --- a/tests/dialects/test_postgres.py +++ b/tests/dialects/test_postgres.py @@ -22,6 +22,7 @@ class TestPostgres(Validator): self.assertIsInstance(expr, exp.AlterTable) self.assertEqual(expr.sql(dialect="postgres"), alter_table_only) + self.validate_identity("STRING_TO_ARRAY('xx~^~yy~^~zz', '~^~', 'yy')") self.validate_identity("SELECT x FROM t WHERE CAST($1 AS TEXT) = 'ok'") self.validate_identity("SELECT * FROM t TABLESAMPLE SYSTEM (50) REPEATABLE (55)") self.validate_identity("x @@ y") @@ -328,6 +329,16 @@ class TestPostgres(Validator): ) self.validate_all( + "STRING_TO_ARRAY('xx~^~yy~^~zz', '~^~', 'yy')", + read={ + "doris": "SPLIT_BY_STRING('xx~^~yy~^~zz', '~^~', 'yy')", + }, + write={ + "doris": "SPLIT_BY_STRING('xx~^~yy~^~zz', '~^~', 'yy')", + "postgres": "STRING_TO_ARRAY('xx~^~yy~^~zz', '~^~', 'yy')", + }, + ) + self.validate_all( "SELECT ARRAY[1, 2, 3] @> ARRAY[1, 2]", read={ "duckdb": "SELECT ARRAY_HAS_ALL([1, 2, 3], [1, 2])", @@ -706,6 +717,9 @@ class TestPostgres(Validator): self.validate_identity( "COPY (SELECT * FROM t) TO 'file' WITH (FORMAT format, HEADER MATCH, FREEZE TRUE)" ) + self.validate_identity("cast(a as FLOAT)", "CAST(a AS DOUBLE PRECISION)") + self.validate_identity("cast(a as FLOAT8)", "CAST(a AS DOUBLE PRECISION)") + self.validate_identity("cast(a as FLOAT4)", "CAST(a AS REAL)") def test_ddl(self): # Checks that user-defined types are parsed into DataType instead of Identifier @@ -723,6 +737,8 @@ class TestPostgres(Validator): cdef.args["kind"].assert_is(exp.DataType) self.assertEqual(expr.sql(dialect="postgres"), "CREATE TABLE t (x INTERVAL DAY)") + self.validate_identity("CREATE TABLE t (col INT[3][5])") + self.validate_identity("CREATE TABLE t (col INT[3])") self.validate_identity("CREATE INDEX IF NOT EXISTS ON t(c)") self.validate_identity("CREATE INDEX et_vid_idx ON et(vid) INCLUDE (fid)") self.validate_identity("CREATE INDEX idx_x ON x USING BTREE(x, y) WHERE (NOT y IS NULL)") @@ -846,6 +862,14 @@ class TestPostgres(Validator): "CREATE UNLOGGED TABLE foo AS WITH t(c) AS (SELECT 1) SELECT * FROM (SELECT c AS c FROM t) AS temp" ) self.validate_identity( + "CREATE TABLE t (col integer ARRAY[3])", + "CREATE TABLE t (col INT[3])", + ) + self.validate_identity( + "CREATE TABLE t (col integer ARRAY)", + "CREATE TABLE t (col INT[])", + ) + self.validate_identity( "CREATE FUNCTION x(INT) RETURNS INT SET search_path TO 'public'", "CREATE FUNCTION x(INT) RETURNS INT SET search_path = 'public'", ) |