From cf606e6b9c2bd703d35537ef8880a8b80edf52a5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 3 Jun 2024 22:08:03 +0200 Subject: Merging upstream version 24.1.0. Signed-off-by: Daniel Baumann --- tests/dialects/test_postgres.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/dialects/test_postgres.py') 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") @@ -327,6 +328,16 @@ class TestPostgres(Validator): "CAST(x AS BIGINT)", ) + 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={ @@ -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)") @@ -845,6 +861,14 @@ class TestPostgres(Validator): self.validate_identity( "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'", -- cgit v1.2.3