From 8d6b86b36fa01c97ab66d8142fd81fa512a76f21 Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Mon, 22 Mar 2021 23:51:39 +0100 Subject: [PATCH] Run PostgreSQL queries in tpch test schema by default This makes test's remote database execution consistent with default session. --- .../TestPostgreSqlCaseInsensitiveMapping.java | 4 +- .../TestPostgreSqlConnectorTest.java | 78 +++++----- .../postgresql/TestPostgreSqlTypeMapping.java | 138 +++++++++--------- .../postgresql/TestingPostgreSqlServer.java | 2 +- 4 files changed, 111 insertions(+), 111 deletions(-) diff --git a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlCaseInsensitiveMapping.java b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlCaseInsensitiveMapping.java index 03c5a83fec09a..ce67a2aa3b318 100644 --- a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlCaseInsensitiveMapping.java +++ b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlCaseInsensitiveMapping.java @@ -145,8 +145,8 @@ public void testTableNameClash() for (int i = 0; i < nameVariants.length; i++) { for (int j = i + 1; j < nameVariants.length; j++) { - try (AutoCloseable ignore1 = withTable("tpch." + nameVariants[i], "(c varchar(5))"); - AutoCloseable ignore2 = withTable("tpch." + nameVariants[j], "(d varchar(5))")) { + try (AutoCloseable ignore1 = withTable(nameVariants[i], "(c varchar(5))"); + AutoCloseable ignore2 = withTable(nameVariants[j], "(d varchar(5))")) { assertThat(computeActual("SHOW TABLES").getOnlyColumn()).contains("casesensitivename"); assertThat(computeActual("SHOW TABLES").getOnlyColumn().filter("casesensitivename"::equals)).hasSize(1); // TODO, should be 2 assertQueryFails("SHOW COLUMNS FROM casesensitivename", "Failed to find remote table name:.*Multiple entries with same key.*"); diff --git a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConnectorTest.java b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConnectorTest.java index 5604d9827644e..73a61dbd01882 100644 --- a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConnectorTest.java +++ b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConnectorTest.java @@ -106,7 +106,7 @@ protected TestTable createTableWithDefaultColumns() { return new TestTable( new JdbcSqlExecutor(postgreSqlServer.getJdbcUrl(), postgreSqlServer.getProperties()), - "tpch.table", + "table", "(col_required BIGINT NOT NULL," + "col_nullable BIGINT," + "col_default BIGINT DEFAULT 43," + @@ -128,7 +128,7 @@ public void testDropTable() public void testInsertInPresenceOfNotSupportedColumn() throws Exception { - execute("CREATE TABLE tpch.test_insert_not_supported_column_present(x bigint, y decimal(50,0), z varchar(10))"); + execute("CREATE TABLE test_insert_not_supported_column_present(x bigint, y decimal(50,0), z varchar(10))"); // Check that column y is not supported. assertQuery("SELECT column_name FROM information_schema.columns WHERE table_name = 'test_insert_not_supported_column_present'", "VALUES 'x', 'z'"); assertUpdate("INSERT INTO test_insert_not_supported_column_present (x, z) VALUES (123, 'test')", 1); @@ -140,20 +140,20 @@ public void testInsertInPresenceOfNotSupportedColumn() public void testViews() throws Exception { - execute("CREATE OR REPLACE VIEW tpch.test_view AS SELECT * FROM tpch.orders"); + execute("CREATE OR REPLACE VIEW test_view AS SELECT * FROM orders"); assertTrue(getQueryRunner().tableExists(getSession(), "test_view")); assertQuery("SELECT orderkey FROM test_view", "SELECT orderkey FROM orders"); - execute("DROP VIEW IF EXISTS tpch.test_view"); + execute("DROP VIEW IF EXISTS test_view"); } @Test public void testMaterializedView() throws Exception { - execute("CREATE MATERIALIZED VIEW tpch.test_mv as SELECT * FROM tpch.orders"); + execute("CREATE MATERIALIZED VIEW test_mv as SELECT * FROM orders"); assertTrue(getQueryRunner().tableExists(getSession(), "test_mv")); assertQuery("SELECT orderkey FROM test_mv", "SELECT orderkey FROM orders"); - execute("DROP MATERIALIZED VIEW tpch.test_mv"); + execute("DROP MATERIALIZED VIEW test_mv"); } @Test @@ -161,10 +161,10 @@ public void testForeignTable() throws Exception { execute("CREATE SERVER devnull FOREIGN DATA WRAPPER file_fdw"); - execute("CREATE FOREIGN TABLE tpch.test_ft (x bigint) SERVER devnull OPTIONS (filename '/dev/null')"); + execute("CREATE FOREIGN TABLE test_ft (x bigint) SERVER devnull OPTIONS (filename '/dev/null')"); assertTrue(getQueryRunner().tableExists(getSession(), "test_ft")); computeActual("SELECT * FROM test_ft"); - execute("DROP FOREIGN TABLE tpch.test_ft"); + execute("DROP FOREIGN TABLE test_ft"); execute("DROP SERVER devnull"); } @@ -188,9 +188,9 @@ public void testTableWithNoSupportedColumns() String unsupportedDataType = "interval"; String supportedDataType = "varchar(5)"; - try (AutoCloseable ignore1 = withTable("tpch.no_supported_columns", format("(c %s)", unsupportedDataType)); - AutoCloseable ignore2 = withTable("tpch.supported_columns", format("(good %s)", supportedDataType)); - AutoCloseable ignore3 = withTable("tpch.no_columns", "()")) { + try (AutoCloseable ignore1 = withTable("no_supported_columns", format("(c %s)", unsupportedDataType)); + AutoCloseable ignore2 = withTable("supported_columns", format("(good %s)", supportedDataType)); + AutoCloseable ignore3 = withTable("no_columns", "()")) { assertThat(computeActual("SHOW TABLES").getOnlyColumnAsSet()).contains("orders", "no_supported_columns", "supported_columns", "no_columns"); assertQueryFails("SELECT c FROM no_supported_columns", "Table 'tpch.no_supported_columns' not found"); @@ -328,29 +328,29 @@ public void testPredicatePushdown() public void testDecimalPredicatePushdown() throws Exception { - try (AutoCloseable ignore = withTable("tpch.test_decimal_pushdown", + try (AutoCloseable ignore = withTable("test_decimal_pushdown", "(short_decimal decimal(9, 3), long_decimal decimal(30, 10))")) { - execute("INSERT INTO tpch.test_decimal_pushdown VALUES (123.321, 123456789.987654321)"); + execute("INSERT INTO test_decimal_pushdown VALUES (123.321, 123456789.987654321)"); - assertThat(query("SELECT * FROM tpch.test_decimal_pushdown WHERE short_decimal <= 124")) + assertThat(query("SELECT * FROM test_decimal_pushdown WHERE short_decimal <= 124")) .matches("VALUES (CAST(123.321 AS decimal(9,3)), CAST(123456789.987654321 AS decimal(30, 10)))") .isFullyPushedDown(); - assertThat(query("SELECT * FROM tpch.test_decimal_pushdown WHERE short_decimal <= 124")) + assertThat(query("SELECT * FROM test_decimal_pushdown WHERE short_decimal <= 124")) .matches("VALUES (CAST(123.321 AS decimal(9,3)), CAST(123456789.987654321 AS decimal(30, 10)))") .isFullyPushedDown(); - assertThat(query("SELECT * FROM tpch.test_decimal_pushdown WHERE long_decimal <= 123456790")) + assertThat(query("SELECT * FROM test_decimal_pushdown WHERE long_decimal <= 123456790")) .matches("VALUES (CAST(123.321 AS decimal(9,3)), CAST(123456789.987654321 AS decimal(30, 10)))") .isFullyPushedDown(); - assertThat(query("SELECT * FROM tpch.test_decimal_pushdown WHERE short_decimal <= 123.321")) + assertThat(query("SELECT * FROM test_decimal_pushdown WHERE short_decimal <= 123.321")) .matches("VALUES (CAST(123.321 AS decimal(9,3)), CAST(123456789.987654321 AS decimal(30, 10)))") .isFullyPushedDown(); - assertThat(query("SELECT * FROM tpch.test_decimal_pushdown WHERE long_decimal <= 123456789.987654321")) + assertThat(query("SELECT * FROM test_decimal_pushdown WHERE long_decimal <= 123456789.987654321")) .matches("VALUES (CAST(123.321 AS decimal(9,3)), CAST(123456789.987654321 AS decimal(30, 10)))") .isFullyPushedDown(); - assertThat(query("SELECT * FROM tpch.test_decimal_pushdown WHERE short_decimal = 123.321")) + assertThat(query("SELECT * FROM test_decimal_pushdown WHERE short_decimal = 123.321")) .matches("VALUES (CAST(123.321 AS decimal(9,3)), CAST(123456789.987654321 AS decimal(30, 10)))") .isFullyPushedDown(); - assertThat(query("SELECT * FROM tpch.test_decimal_pushdown WHERE long_decimal = 123456789.987654321")) + assertThat(query("SELECT * FROM test_decimal_pushdown WHERE long_decimal = 123456789.987654321")) .matches("VALUES (CAST(123.321 AS decimal(9,3)), CAST(123456789.987654321 AS decimal(30, 10)))") .isFullyPushedDown(); } @@ -360,19 +360,19 @@ public void testDecimalPredicatePushdown() public void testCharPredicatePushdown() throws Exception { - try (AutoCloseable ignore = withTable("tpch.test_char_pushdown", + try (AutoCloseable ignore = withTable("test_char_pushdown", "(char_1 char(1), char_5 char(5), char_10 char(10))")) { - execute("INSERT INTO tpch.test_char_pushdown VALUES" + + execute("INSERT INTO test_char_pushdown VALUES" + "('0', '0' , '0' )," + "('1', '12345', '1234567890')"); - assertThat(query("SELECT * FROM tpch.test_char_pushdown WHERE char_1 = '0' AND char_5 = '0'")) + assertThat(query("SELECT * FROM test_char_pushdown WHERE char_1 = '0' AND char_5 = '0'")) .matches("VALUES (CHAR'0', CHAR'0 ', CHAR'0 ')") .isFullyPushedDown(); - assertThat(query("SELECT * FROM tpch.test_char_pushdown WHERE char_5 = CHAR'12345' AND char_10 = '1234567890'")) + assertThat(query("SELECT * FROM test_char_pushdown WHERE char_5 = CHAR'12345' AND char_10 = '1234567890'")) .matches("VALUES (CHAR'1', CHAR'12345', CHAR'1234567890')") .isFullyPushedDown(); - assertThat(query("SELECT * FROM tpch.test_char_pushdown WHERE char_10 = CHAR'0'")) + assertThat(query("SELECT * FROM test_char_pushdown WHERE char_10 = CHAR'0'")) .matches("VALUES (CHAR'0', CHAR'0 ', CHAR'0 ')") .isFullyPushedDown(); } @@ -382,7 +382,7 @@ public void testCharPredicatePushdown() public void testCharTrailingSpace() throws Exception { - execute("CREATE TABLE tpch.char_trailing_space (x char(10))"); + execute("CREATE TABLE char_trailing_space (x char(10))"); assertUpdate("INSERT INTO char_trailing_space VALUES ('test')", 1); assertQuery("SELECT * FROM char_trailing_space WHERE x = char 'test'", "VALUES 'test'"); @@ -550,7 +550,7 @@ public void testTopNWithEnum() postgreSqlServer.execute("CREATE TYPE " + enumType + " AS ENUM ('A', 'b', 'B', 'a')"); try (TestTable testTable = new TestTable( postgreSqlServer::execute, - "tpch.test_case_sensitive_topn_pushdown_with_enums", + "test_case_sensitive_topn_pushdown_with_enums", "(an_enum " + enumType + ", a_bigint bigint)", List.of( "'A', 1", @@ -652,7 +652,7 @@ public void testCovarianceAggregationPushdown() // empty table try (TestTable testTable = new TestTable( postgreSqlServer::execute, - "tpch.test_covariance_pushdown", + "test_covariance_pushdown", "(t_double1 DOUBLE PRECISION, t_double2 DOUBLE PRECISION, t_real1 REAL, t_real2 REAL)")) { assertThat(query("SELECT covar_pop(t_double1, t_double2), covar_pop(t_real1, t_real2) FROM " + testTable.getName())).isFullyPushedDown(); assertThat(query("SELECT covar_samp(t_double1, t_double2), covar_samp(t_real1, t_real2) FROM " + testTable.getName())).isFullyPushedDown(); @@ -661,7 +661,7 @@ public void testCovarianceAggregationPushdown() // test some values for which the aggregate functions return whole numbers try (TestTable testTable = new TestTable( postgreSqlServer::execute, - "tpch.test_covariance_pushdown", + "test_covariance_pushdown", "(t_double1 DOUBLE PRECISION, t_double2 DOUBLE PRECISION, t_real1 REAL, t_real2 REAL)", ImmutableList.of("2, 2, 2, 2", "4, 4, 4, 4"))) { assertThat(query("SELECT covar_pop(t_double1, t_double2), covar_pop(t_real1, t_real2) FROM " + testTable.getName())).isFullyPushedDown(); @@ -671,7 +671,7 @@ public void testCovarianceAggregationPushdown() // non-whole number results try (TestTable testTable = new TestTable( postgreSqlServer::execute, - "tpch.test_covariance_pushdown", + "test_covariance_pushdown", "(t_double1 DOUBLE PRECISION, t_double2 DOUBLE PRECISION, t_real1 REAL, t_real2 REAL)", ImmutableList.of("1, 2, 1, 2", "100000000.123456, 4, 100000000.123456, 4", "123456789.987654, 8, 123456789.987654, 8"))) { assertThat(query("SELECT covar_pop(t_double1, t_double2), covar_pop(t_real1, t_real2) FROM " + testTable.getName())).isFullyPushedDown(); @@ -685,7 +685,7 @@ public void testCorrAggregationPushdown() // empty table try (TestTable testTable = new TestTable( postgreSqlServer::execute, - "tpch.test_corr_pushdown", + "test_corr_pushdown", "(t_double1 DOUBLE PRECISION, t_double2 DOUBLE PRECISION, t_real1 REAL, t_real2 REAL)")) { assertThat(query("SELECT corr(t_double1, t_double2), corr(t_real1, t_real2) FROM " + testTable.getName())).isFullyPushedDown(); } @@ -693,7 +693,7 @@ public void testCorrAggregationPushdown() // test some values for which the aggregate functions return whole numbers try (TestTable testTable = new TestTable( postgreSqlServer::execute, - "tpch.test_corr_pushdown", + "test_corr_pushdown", "(t_double1 DOUBLE PRECISION, t_double2 DOUBLE PRECISION, t_real1 REAL, t_real2 REAL)", ImmutableList.of("2, 2, 2, 2", "4, 4, 4, 4"))) { assertThat(query("SELECT corr(t_double1, t_double2), corr(t_real1, t_real2) FROM " + testTable.getName())).isFullyPushedDown(); @@ -702,7 +702,7 @@ public void testCorrAggregationPushdown() // non-whole number results try (TestTable testTable = new TestTable( postgreSqlServer::execute, - "tpch.test_corr_pushdown", + "test_corr_pushdown", "(t_double1 DOUBLE PRECISION, t_double2 DOUBLE PRECISION, t_real1 REAL, t_real2 REAL)", ImmutableList.of("1, 2, 1, 2", "100000000.123456, 4, 100000000.123456, 4", "123456789.987654, 8, 123456789.987654, 8"))) { assertThat(query("SELECT corr(t_double1, t_double2), corr(t_real1, t_real2) FROM " + testTable.getName())).isFullyPushedDown(); @@ -715,7 +715,7 @@ public void testRegrAggregationPushdown() // empty table try (TestTable testTable = new TestTable( postgreSqlServer::execute, - "tpch.test_regr_pushdown", + "test_regr_pushdown", "(t_double1 DOUBLE PRECISION, t_double2 DOUBLE PRECISION, t_real1 REAL, t_real2 REAL)")) { assertThat(query("SELECT regr_intercept(t_double1, t_double2), regr_intercept(t_real1, t_real2) FROM " + testTable.getName())).isFullyPushedDown(); assertThat(query("SELECT regr_slope(t_double1, t_double2), regr_slope(t_real1, t_real2) FROM " + testTable.getName())).isFullyPushedDown(); @@ -724,7 +724,7 @@ public void testRegrAggregationPushdown() // test some values for which the aggregate functions return whole numbers try (TestTable testTable = new TestTable( postgreSqlServer::execute, - "tpch.test_regr_pushdown", + "test_regr_pushdown", "(t_double1 DOUBLE PRECISION, t_double2 DOUBLE PRECISION, t_real1 REAL, t_real2 REAL)", ImmutableList.of("2, 2, 2, 2", "4, 4, 4, 4"))) { assertThat(query("SELECT regr_intercept(t_double1, t_double2), regr_intercept(t_real1, t_real2) FROM " + testTable.getName())).isFullyPushedDown(); @@ -734,7 +734,7 @@ public void testRegrAggregationPushdown() // non-whole number results try (TestTable testTable = new TestTable( postgreSqlServer::execute, - "tpch.test_regr_pushdown", + "test_regr_pushdown", "(t_double1 DOUBLE PRECISION, t_double2 DOUBLE PRECISION, t_real1 REAL, t_real2 REAL)", ImmutableList.of("1, 2, 1, 2", "100000000.123456, 4, 100000000.123456, 4", "123456789.987654, 8, 123456789.987654, 8"))) { assertThat(query("SELECT regr_intercept(t_double1, t_double2), regr_intercept(t_real1, t_real2) FROM " + testTable.getName())).isFullyPushedDown(); @@ -783,7 +783,7 @@ public void testLimitPushdown() public void testNativeLargeIn() throws SQLException { - execute("SELECT count(*) FROM tpch.orders WHERE " + getLongInClause(0, 500_000)); + execute("SELECT count(*) FROM orders WHERE " + getLongInClause(0, 500_000)); } /** @@ -796,7 +796,7 @@ public void testNativeMultipleInClauses() String longInClauses = range(0, 20) .mapToObj(value -> getLongInClause(value * 10_000, 10_000)) .collect(joining(" OR ")); - execute("SELECT count(*) FROM tpch.orders WHERE " + longInClauses); + execute("SELECT count(*) FROM orders WHERE " + longInClauses); } /** @@ -806,7 +806,7 @@ public void testNativeMultipleInClauses() public void testTimestampColumnAndTimestampWithTimeZoneConstant() throws Exception { - String tableName = "tpch.test_timestamptz_unwrap_cast" + randomTableSuffix(); + String tableName = "test_timestamptz_unwrap_cast" + randomTableSuffix(); try (AutoCloseable ignored = withTable(tableName, "(id integer, ts_col timestamp(6))")) { execute("INSERT INTO " + tableName + " (id, ts_col) VALUES " + "(1, timestamp '2020-01-01 01:01:01.000')," + diff --git a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlTypeMapping.java b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlTypeMapping.java index 3e487af96957d..f49adb09d680b 100644 --- a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlTypeMapping.java +++ b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlTypeMapping.java @@ -198,7 +198,7 @@ public void testReal() .addRoundTrip("real", "'NaN'::real", REAL, "CAST(nan() AS real)") .addRoundTrip("real", "'-Infinity'::real", REAL, "CAST(-infinity() AS real)") .addRoundTrip("real", "'+Infinity'::real", REAL, "CAST(+infinity() AS real)") - .execute(getQueryRunner(), postgresCreateAndInsert("tpch.postgresql_test_real")); + .execute(getQueryRunner(), postgresCreateAndInsert("postgresql_test_real")); SqlDataTypeTest.create() .addRoundTrip("real", "NULL", REAL, "CAST(NULL AS real)") @@ -219,7 +219,7 @@ public void testDouble() .addRoundTrip("double precision", "'NaN'::double precision", DOUBLE, "nan()") .addRoundTrip("double precision", "'+Infinity'::double precision", DOUBLE, "+infinity()") .addRoundTrip("double precision", "'-Infinity'::double precision", DOUBLE, "-infinity()") - .execute(getQueryRunner(), postgresCreateAndInsert("tpch.postgresql_test_double")); + .execute(getQueryRunner(), postgresCreateAndInsert("postgresql_test_double")); SqlDataTypeTest.create() .addRoundTrip("double", "NULL", DOUBLE, "CAST(NULL AS double)") @@ -250,7 +250,7 @@ public void testDecimal() .addRoundTrip("decimal(30, 5)", "CAST('-3141592653589793238462643.38327' AS decimal(30, 5))", createDecimalType(30, 5), "CAST('-3141592653589793238462643.38327' AS decimal(30, 5))") .addRoundTrip("decimal(38, 0)", "CAST('27182818284590452353602874713526624977' AS decimal(38, 0))", createDecimalType(38, 0), "CAST('27182818284590452353602874713526624977' AS decimal(38, 0))") .addRoundTrip("decimal(38, 0)", "CAST('-27182818284590452353602874713526624977' AS decimal(38, 0))", createDecimalType(38, 0), "CAST('-27182818284590452353602874713526624977' AS decimal(38, 0))") - .execute(getQueryRunner(), postgresCreateAndInsert("tpch.test_decimal")) + .execute(getQueryRunner(), postgresCreateAndInsert("test_decimal")) .execute(getQueryRunner(), trinoCreateAsSelect("test_decimal")); } @@ -264,7 +264,7 @@ public void testChar() .addRoundTrip("char(32)", "'攻殻機動隊'", createCharType(32), "CAST('攻殻機動隊' AS char(32))") .addRoundTrip("char(1)", "'😂'", createCharType(1), "CAST('😂' AS char(1))") .addRoundTrip("char(77)", "'Ну, погоди!'", createCharType(77), "CAST('Ну, погоди!' AS char(77))") - .execute(getQueryRunner(), postgresCreateAndInsert("tpch.test_char")) + .execute(getQueryRunner(), postgresCreateAndInsert("test_char")) .execute(getQueryRunner(), trinoCreateAsSelect("test_char")); // too long for a char in Trino @@ -275,17 +275,17 @@ public void testChar() .addRoundTrip(postgresqlType, "'test_f'", trinoType, format("'test_f%s'", " ".repeat(length - 6))) .addRoundTrip(postgresqlType, format("'%s'", "a".repeat(length)), trinoType, format("'%s'", "a".repeat(length))) .addRoundTrip(postgresqlType, "'\uD83D\uDE02'", trinoType, format("'\uD83D\uDE02%s'", " ".repeat(length - 1))) - .execute(getQueryRunner(), postgresCreateAndInsert("tpch.test_char")); + .execute(getQueryRunner(), postgresCreateAndInsert("test_char")); } @Test public void testPostgreSqlCreatedVarchar() { varcharDataTypeTest(DataType::varcharDataType) - .execute(getQueryRunner(), postgresCreateAndInsert("tpch.test_varchar")); + .execute(getQueryRunner(), postgresCreateAndInsert("test_varchar")); varcharDataTypeTest(length -> varcharDataType()) - .execute(getQueryRunner(), postgresCreateAndInsert("tpch.test_varchar")); + .execute(getQueryRunner(), postgresCreateAndInsert("test_varchar")); } @Test @@ -333,7 +333,7 @@ public void testVarbinary() .addRoundTrip("bytea", utf8ByteaLiteral("Bag full of 💰"), VARBINARY, "to_utf8('Bag full of 💰')") .addRoundTrip("bytea", "bytea E'\\\\x0001020304050607080DF9367AA7000000'", VARBINARY, "X'0001020304050607080DF9367AA7000000'") // non-text .addRoundTrip("bytea", "bytea E'\\\\x000000000000'", VARBINARY, "X'000000000000'") - .execute(getQueryRunner(), postgresCreateAndInsert("tpch.test_varbinary")); + .execute(getQueryRunner(), postgresCreateAndInsert("test_varbinary")); SqlDataTypeTest.create() .addRoundTrip("varbinary", "NULL", VARBINARY, "CAST(NULL AS varbinary)") @@ -355,8 +355,8 @@ private static String utf8ByteaLiteral(String string) public void testForcedMappingToVarchar() { JdbcSqlExecutor jdbcSqlExecutor = new JdbcSqlExecutor(postgreSqlServer.getJdbcUrl(), postgreSqlServer.getProperties()); - jdbcSqlExecutor.execute("CREATE TABLE tpch.test_forced_varchar_mapping(tsrange_col tsrange, inet_col inet, tsrange_arr_col tsrange[], unsupported_nonforced_column tstzrange)"); - jdbcSqlExecutor.execute("INSERT INTO tpch.test_forced_varchar_mapping(tsrange_col, inet_col, tsrange_arr_col, unsupported_nonforced_column) " + + jdbcSqlExecutor.execute("CREATE TABLE test_forced_varchar_mapping(tsrange_col tsrange, inet_col inet, tsrange_arr_col tsrange[], unsupported_nonforced_column tstzrange)"); + jdbcSqlExecutor.execute("INSERT INTO test_forced_varchar_mapping(tsrange_col, inet_col, tsrange_arr_col, unsupported_nonforced_column) " + "VALUES ('[2010-01-01 14:30, 2010-01-01 15:30)'::tsrange, '172.0.0.1'::inet, array['[2010-01-01 14:30, 2010-01-01 15:30)'::tsrange], '[2010-01-01 14:30, 2010-01-01 15:30)'::tstzrange)"); try { assertQuery( @@ -366,24 +366,24 @@ public void testForcedMappingToVarchar() assertQuery( sessionWithArrayAsArray(), - "SELECT * FROM tpch.test_forced_varchar_mapping", + "SELECT * FROM test_forced_varchar_mapping", "VALUES ('[\"2010-01-01 14:30:00\",\"2010-01-01 15:30:00\")','172.0.0.1',ARRAY['[\"2010-01-01 14:30:00\",\"2010-01-01 15:30:00\")'])"); // test predicate pushdown to column that has forced varchar mapping - assertThat(query("SELECT 1 FROM tpch.test_forced_varchar_mapping WHERE tsrange_col = '[\"2010-01-01 14:30:00\",\"2010-01-01 15:30:00\")'")) + assertThat(query("SELECT 1 FROM test_forced_varchar_mapping WHERE tsrange_col = '[\"2010-01-01 14:30:00\",\"2010-01-01 15:30:00\")'")) .matches("VALUES 1") .isNotFullyPushedDown(FilterNode.class); - assertThat(query("SELECT 1 FROM tpch.test_forced_varchar_mapping WHERE tsrange_col = 'some value'")) + assertThat(query("SELECT 1 FROM test_forced_varchar_mapping WHERE tsrange_col = 'some value'")) .returnsEmptyResult() .isNotFullyPushedDown(FilterNode.class); // test insert into column that has forced varchar mapping assertQueryFails( - "INSERT INTO tpch.test_forced_varchar_mapping (tsrange_col) VALUES ('some value')", + "INSERT INTO test_forced_varchar_mapping (tsrange_col) VALUES ('some value')", "Underlying type that is mapped to VARCHAR is not supported for INSERT: tsrange"); } finally { - jdbcSqlExecutor.execute("DROP TABLE tpch.test_forced_varchar_mapping"); + jdbcSqlExecutor.execute("DROP TABLE test_forced_varchar_mapping"); } } @@ -411,12 +411,12 @@ public void testDecimalExceedingPrecisionMaxWithExceedingIntegerValues() try (TestTable testTable = new TestTable( jdbcSqlExecutor, - "tpch.test_exceeding_max_decimal", + "test_exceeding_max_decimal", "(d_col decimal(65,25))", asList("1234567890123456789012345678901234567890.123456789", "-1234567890123456789012345678901234567890.123456789"))) { assertQuery( sessionWithDecimalMappingAllowOverflow(UNNECESSARY, 0), - format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_schema||'.'||table_name = '%s'", testTable.getName()), + format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = '%s'", testTable.getName()), "VALUES ('d_col', 'decimal(38,0)')"); assertQueryFails( sessionWithDecimalMappingAllowOverflow(UNNECESSARY, 0), @@ -428,7 +428,7 @@ public void testDecimalExceedingPrecisionMaxWithExceedingIntegerValues() "Decimal overflow"); assertQuery( sessionWithDecimalMappingStrict(CONVERT_TO_VARCHAR), - format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_schema||'.'||table_name = '%s'", testTable.getName()), + format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = '%s'", testTable.getName()), "VALUES ('d_col', 'varchar')"); assertQuery( sessionWithDecimalMappingStrict(CONVERT_TO_VARCHAR), @@ -444,12 +444,12 @@ public void testDecimalExceedingPrecisionMaxWithNonExceedingIntegerValues() try (TestTable testTable = new TestTable( jdbcSqlExecutor, - "tpch.test_exceeding_max_decimal", + "test_exceeding_max_decimal", "(d_col decimal(60,20))", asList("123456789012345678901234567890.123456789012345", "-123456789012345678901234567890.123456789012345"))) { assertQuery( sessionWithDecimalMappingAllowOverflow(UNNECESSARY, 0), - format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_schema||'.'||table_name = '%s'", testTable.getName()), + format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = '%s'", testTable.getName()), "VALUES ('d_col', 'decimal(38,0)')"); assertQueryFails( sessionWithDecimalMappingAllowOverflow(UNNECESSARY, 0), @@ -461,7 +461,7 @@ public void testDecimalExceedingPrecisionMaxWithNonExceedingIntegerValues() "VALUES (123456789012345678901234567890), (-123456789012345678901234567890)"); assertQuery( sessionWithDecimalMappingAllowOverflow(UNNECESSARY, 8), - format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_schema||'.'||table_name = '%s'", testTable.getName()), + format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = '%s'", testTable.getName()), "VALUES ('d_col', 'decimal(38,8)')"); assertQueryFails( sessionWithDecimalMappingAllowOverflow(UNNECESSARY, 8), @@ -473,7 +473,7 @@ public void testDecimalExceedingPrecisionMaxWithNonExceedingIntegerValues() "VALUES (123456789012345678901234567890.12345679), (-123456789012345678901234567890.12345679)"); assertQuery( sessionWithDecimalMappingAllowOverflow(HALF_UP, 22), - format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_schema||'.'||table_name = '%s'", testTable.getName()), + format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = '%s'", testTable.getName()), "VALUES ('d_col', 'decimal(38,20)')"); assertQueryFails( sessionWithDecimalMappingAllowOverflow(HALF_UP, 20), @@ -485,7 +485,7 @@ public void testDecimalExceedingPrecisionMaxWithNonExceedingIntegerValues() "Decimal overflow"); assertQuery( sessionWithDecimalMappingStrict(CONVERT_TO_VARCHAR), - format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_schema||'.'||table_name = '%s'", testTable.getName()), + format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = '%s'", testTable.getName()), "VALUES ('d_col', 'varchar')"); assertQuery( sessionWithDecimalMappingStrict(CONVERT_TO_VARCHAR), @@ -501,12 +501,12 @@ public void testDecimalExceedingPrecisionMaxWithSupportedValues(int typePrecisio try (TestTable testTable = new TestTable( jdbcSqlExecutor, - "tpch.test_exceeding_max_decimal", + "test_exceeding_max_decimal", format("(d_col decimal(%d,%d))", typePrecision, typeScale), asList("12.01", "-12.01", "123", "-123", "1.12345678", "-1.12345678"))) { assertQuery( sessionWithDecimalMappingAllowOverflow(UNNECESSARY, 0), - format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_schema||'.'||table_name = '%s'", testTable.getName()), + format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = '%s'", testTable.getName()), "VALUES ('d_col', 'decimal(38,0)')"); assertQueryFails( sessionWithDecimalMappingAllowOverflow(UNNECESSARY, 0), @@ -518,7 +518,7 @@ public void testDecimalExceedingPrecisionMaxWithSupportedValues(int typePrecisio "VALUES (12), (-12), (123), (-123), (1), (-1)"); assertQuery( sessionWithDecimalMappingAllowOverflow(HALF_UP, 3), - format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_schema||'.'||table_name = '%s'", testTable.getName()), + format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = '%s'", testTable.getName()), "VALUES ('d_col', 'decimal(38,3)')"); assertQuery( sessionWithDecimalMappingAllowOverflow(HALF_UP, 3), @@ -530,7 +530,7 @@ public void testDecimalExceedingPrecisionMaxWithSupportedValues(int typePrecisio "Rounding necessary"); assertQuery( sessionWithDecimalMappingAllowOverflow(HALF_UP, 8), - format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_schema||'.'||table_name = '%s'", testTable.getName()), + format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = '%s'", testTable.getName()), "VALUES ('d_col', 'decimal(38,8)')"); assertQuery( sessionWithDecimalMappingAllowOverflow(HALF_UP, 8), @@ -563,12 +563,12 @@ public void testDecimalUnspecifiedPrecisionWithSupportedValues() try (TestTable testTable = new TestTable( jdbcSqlExecutor, - "tpch.test_var_decimal", + "test_var_decimal", "(d_col decimal)", asList("1.12", "123456.789", "-1.12", "-123456.789"))) { assertQuery( sessionWithDecimalMappingAllowOverflow(UNNECESSARY, 0), - format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_schema||'.'||table_name = '%s'", testTable.getName()), + format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = '%s'", testTable.getName()), "VALUES ('d_col','decimal(38,0)')"); assertQueryFails( sessionWithDecimalMappingAllowOverflow(UNNECESSARY, 0), @@ -584,7 +584,7 @@ public void testDecimalUnspecifiedPrecisionWithSupportedValues() "Rounding necessary"); assertQuery( sessionWithDecimalMappingAllowOverflow(HALF_UP, 1), - format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_schema||'.'||table_name = '%s'", testTable.getName()), + format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = '%s'", testTable.getName()), "VALUES ('d_col','decimal(38,1)')"); assertQuery( sessionWithDecimalMappingAllowOverflow(HALF_UP, 1), @@ -600,7 +600,7 @@ public void testDecimalUnspecifiedPrecisionWithSupportedValues() "VALUES (1.12), (123456.79), (-1.12), (-123456.79)"); assertQuery( sessionWithDecimalMappingAllowOverflow(UNNECESSARY, 3), - format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_schema||'.'||table_name = '%s'", testTable.getName()), + format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = '%s'", testTable.getName()), "VALUES ('d_col','decimal(38,3)')"); assertQuery( sessionWithDecimalMappingAllowOverflow(UNNECESSARY, 3), @@ -615,12 +615,12 @@ public void testDecimalUnspecifiedPrecisionWithExceedingValue() JdbcSqlExecutor jdbcSqlExecutor = new JdbcSqlExecutor(postgreSqlServer.getJdbcUrl(), postgreSqlServer.getProperties()); try (TestTable testTable = new TestTable( jdbcSqlExecutor, - "tpch.test_var_decimal_with_exceeding_value", + "test_var_decimal_with_exceeding_value", "(key varchar(5), d_col decimal)", asList("NULL, '1.12'", "NULL, '1234567890123456789012345678901234567890.1234567'"))) { assertQuery( sessionWithDecimalMappingAllowOverflow(UNNECESSARY, 0), - format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_schema||'.'||table_name = '%s'", testTable.getName()), + format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = '%s'", testTable.getName()), "VALUES ('key', 'varchar(5)'),('d_col', 'decimal(38,0)')"); assertQueryFails( sessionWithDecimalMappingAllowOverflow(UNNECESSARY, 0), @@ -632,7 +632,7 @@ public void testDecimalUnspecifiedPrecisionWithExceedingValue() "Decimal overflow"); assertQuery( sessionWithDecimalMappingStrict(CONVERT_TO_VARCHAR), - format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_schema||'.'||table_name = '%s'", testTable.getName()), + format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = '%s'", testTable.getName()), "VALUES ('key', 'varchar(5)'),('d_col', 'varchar')"); assertQuery( sessionWithDecimalMappingStrict(CONVERT_TO_VARCHAR), @@ -640,7 +640,7 @@ public void testDecimalUnspecifiedPrecisionWithExceedingValue() "VALUES (NULL, '1.12'), (NULL, '1234567890123456789012345678901234567890.1234567')"); assertQuery( sessionWithDecimalMappingStrict(IGNORE), - format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_schema||'.'||table_name = '%s'", testTable.getName()), + format("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = '%s'", testTable.getName()), "VALUES ('key', 'varchar(5)')"); } } @@ -677,17 +677,17 @@ public void testArray() arrayDateTest(TestPostgreSqlTypeMapping::arrayDataType) .execute(getQueryRunner(), session, trinoCreateAsSelect(session, "test_array_date")); arrayDateTest(TestPostgreSqlTypeMapping::postgresArrayDataType) - .execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_array_date")); + .execute(getQueryRunner(), session, postgresCreateAndInsert("test_array_date")); arrayDecimalTest(TestPostgreSqlTypeMapping::arrayDataType) .execute(getQueryRunner(), session, trinoCreateAsSelect(session, "test_array_decimal")); arrayDecimalTest(TestPostgreSqlTypeMapping::postgresArrayDataType) - .execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_array_decimal")); + .execute(getQueryRunner(), session, postgresCreateAndInsert("test_array_decimal")); arrayVarcharDataTypeTest(TestPostgreSqlTypeMapping::arrayDataType) .execute(getQueryRunner(), session, trinoCreateAsSelect(session, "test_array_varchar")); arrayVarcharDataTypeTest(TestPostgreSqlTypeMapping::postgresArrayDataType) - .execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_array_varchar")); + .execute(getQueryRunner(), session, postgresCreateAndInsert("test_array_varchar")); testUnsupportedDataTypeAsIgnored(session, "bytea[]", "ARRAY['binary value'::bytea]"); testUnsupportedDataTypeAsIgnored(session, "bytea[]", "ARRAY[ARRAY['binary value'::bytea]]"); @@ -698,11 +698,11 @@ public void testArray() arrayUnicodeDataTypeTest(TestPostgreSqlTypeMapping::arrayDataType, DataType::charDataType) .execute(getQueryRunner(), session, trinoCreateAsSelect(session, "test_array_parameterized_char_unicode")); arrayUnicodeDataTypeTest(TestPostgreSqlTypeMapping::postgresArrayDataType, DataType::charDataType) - .execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_array_parameterized_char_unicode")); + .execute(getQueryRunner(), session, postgresCreateAndInsert("test_array_parameterized_char_unicode")); arrayVarcharUnicodeDataTypeTest(TestPostgreSqlTypeMapping::arrayDataType) .execute(getQueryRunner(), session, trinoCreateAsSelect(session, "test_array_parameterized_varchar_unicode")); arrayVarcharUnicodeDataTypeTest(TestPostgreSqlTypeMapping::postgresArrayDataType) - .execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_array_parameterized_varchar_unicode")); + .execute(getQueryRunner(), session, postgresCreateAndInsert("test_array_parameterized_varchar_unicode")); } @Test @@ -711,7 +711,7 @@ public void testInternalArray() DataTypeTest.create() .addRoundTrip(arrayDataType(integerDataType(), "_int4"), asList(1, 2, 3)) .addRoundTrip(arrayDataType(varcharDataType(), "_text"), asList("a", "b")) - .execute(getQueryRunner(), sessionWithArrayAsArray(), postgresCreateAndInsert("tpch.test_array_with_native_name")); + .execute(getQueryRunner(), sessionWithArrayAsArray(), postgresCreateAndInsert("test_array_with_native_name")); } @Test @@ -837,7 +837,7 @@ public void testArrayAsJson() .addRoundTrip(arrayAsJsonDataType("_bool"), "[[true,false],[null,null]]") .addRoundTrip(arrayAsJsonDataType("_bool"), "[[[null]]]") .addRoundTrip(arrayAsJsonDataType("_bool"), "[]") - .execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_boolean_array_as_json")); + .execute(getQueryRunner(), session, postgresCreateAndInsert("test_boolean_array_as_json")); DataTypeTest.create() .addRoundTrip(arrayAsJsonDataType("integer[]"), null) @@ -847,7 +847,7 @@ public void testArrayAsJson() .addRoundTrip(arrayAsJsonDataType("integer[]"), "[]") .addRoundTrip(arrayAsJsonDataType("_int4"), "[]") .addRoundTrip(arrayAsJsonDataType("_int4"), "[[0],[1],[2],[3]]") - .execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_integer_array_as_json")); + .execute(getQueryRunner(), session, postgresCreateAndInsert("test_integer_array_as_json")); DataTypeTest.create() .addRoundTrip(arrayAsJsonDataType("double precision[]"), null) @@ -857,7 +857,7 @@ public void testArrayAsJson() .addRoundTrip(arrayAsJsonDataType("double precision[]"), "[]") .addRoundTrip(arrayAsJsonDataType("_float8"), "[]") .addRoundTrip(arrayAsJsonDataType("_float8"), "[[1.1],[2.2]]") - .execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_double_array_as_json")); + .execute(getQueryRunner(), session, postgresCreateAndInsert("test_double_array_as_json")); DataTypeTest.create() .addRoundTrip(arrayAsJsonDataType("real[]"), null) @@ -867,7 +867,7 @@ public void testArrayAsJson() .addRoundTrip(arrayAsJsonDataType("real[]"), "[]") .addRoundTrip(arrayAsJsonDataType("_float4"), "[]") .addRoundTrip(arrayAsJsonDataType("_float4"), "[[1.1],[2.2]]") - .execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_real_array_as_json")); + .execute(getQueryRunner(), session, postgresCreateAndInsert("test_real_array_as_json")); DataTypeTest.create() .addRoundTrip(arrayAsJsonDataType("varchar[]"), null) @@ -875,7 +875,7 @@ public void testArrayAsJson() .addRoundTrip(arrayAsJsonDataType("_text"), "[[\"one\",\"two\"],[\"three\",\"four\"]]") .addRoundTrip(arrayAsJsonDataType("_text"), "[[\"one\",null]]") .addRoundTrip(arrayAsJsonDataType("_text"), "[]") - .execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_varchar_array_as_json")); + .execute(getQueryRunner(), session, postgresCreateAndInsert("test_varchar_array_as_json")); testUnsupportedDataTypeAsIgnored(session, "bytea[]", "ARRAY['binary value'::bytea]"); testUnsupportedDataTypeAsIgnored(session, "bytea[]", "ARRAY[ARRAY['binary value'::bytea]]"); @@ -887,13 +887,13 @@ public void testArrayAsJson() .addRoundTrip(arrayAsJsonDataType("date[]"), null) .addRoundTrip(arrayAsJsonDataType("date[]"), "[\"2019-01-02\"]") .addRoundTrip(arrayAsJsonDataType("date[]"), "[null,null]") - .execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_timestamp_array_as_json")); + .execute(getQueryRunner(), session, postgresCreateAndInsert("test_timestamp_array_as_json")); DataTypeTest.create() .addRoundTrip(arrayAsJsonDataType("timestamp[]"), null) .addRoundTrip(arrayAsJsonDataType("timestamp[]"), "[\"2019-01-02 03:04:05.789000\"]") .addRoundTrip(arrayAsJsonDataType("timestamp[]"), "[null,null]") - .execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_timestamp_array_as_json")); + .execute(getQueryRunner(), session, postgresCreateAndInsert("test_timestamp_array_as_json")); DataTypeTest.create() .addRoundTrip(arrayAsJsonDataType("hstore[]"), null) @@ -901,7 +901,7 @@ public void testArrayAsJson() .addRoundTrip(arrayAsJsonDataType("hstore[]"), "[null,null]") .addRoundTrip(hstoreArrayAsJsonDataType(), "[{\"a\":\"1\",\"b\":\"2\"},{\"a\":\"3\",\"d\":\"4\"}]") .addRoundTrip(hstoreArrayAsJsonDataType(), "[{\"a\":null,\"b\":\"2\"}]") - .execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_hstore_array_as_json")); + .execute(getQueryRunner(), session, postgresCreateAndInsert("test_hstore_array_as_json")); } private static DataType> arrayDataType(DataType elementType) @@ -976,7 +976,7 @@ public void testDate() Session session = Session.builder(getSession()) .setTimeZoneKey(TimeZoneKey.getTimeZoneKey(timeZoneId)) .build(); - testCases.execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_date")); + testCases.execute(getQueryRunner(), session, postgresCreateAndInsert("test_date")); testCases.execute(getQueryRunner(), session, trinoCreateAsSelect(session, "test_date")); testCases.execute(getQueryRunner(), session, trinoCreateAsSelect(getSession(), "test_date")); testCases.execute(getQueryRunner(), session, trinoCreateAndInsert(session, "test_date")); @@ -988,17 +988,17 @@ public void testEnum() { JdbcSqlExecutor jdbcSqlExecutor = new JdbcSqlExecutor(postgreSqlServer.getJdbcUrl(), postgreSqlServer.getProperties()); jdbcSqlExecutor.execute("CREATE TYPE enum_t AS ENUM ('a','b','c')"); - jdbcSqlExecutor.execute("CREATE TABLE tpch.test_enum(id int, enum_column enum_t)"); - jdbcSqlExecutor.execute("INSERT INTO tpch.test_enum(id,enum_column) values (1,'a'::enum_t),(2,'b'::enum_t)"); + jdbcSqlExecutor.execute("CREATE TABLE test_enum(id int, enum_column enum_t)"); + jdbcSqlExecutor.execute("INSERT INTO test_enum(id,enum_column) values (1,'a'::enum_t),(2,'b'::enum_t)"); try { assertQuery( "SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = 'test_enum'", "VALUES ('id','integer'),('enum_column','varchar')"); - assertQuery("SELECT * FROM tpch.test_enum", "VALUES (1,'a'),(2,'b')"); - assertQuery("SELECT * FROM tpch.test_enum WHERE enum_column='a'", "VALUES (1,'a')"); + assertQuery("SELECT * FROM test_enum", "VALUES (1,'a'),(2,'b')"); + assertQuery("SELECT * FROM test_enum WHERE enum_column='a'", "VALUES (1,'a')"); } finally { - jdbcSqlExecutor.execute("DROP TABLE tpch.test_enum"); + jdbcSqlExecutor.execute("DROP TABLE test_enum"); jdbcSqlExecutor.execute("DROP TYPE enum_t"); } } @@ -1043,7 +1043,7 @@ public void testTime(boolean insertWithTrino, ZoneId sessionZone) tests.execute(getQueryRunner(), session, trinoCreateAndInsert(session, "test_time")); } else { - tests.execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_time")); + tests.execute(getQueryRunner(), session, postgresCreateAndInsert("test_time")); } } @@ -1139,7 +1139,7 @@ public void testTime24() { try (TestTable testTable = new TestTable( new JdbcSqlExecutor(postgreSqlServer.getJdbcUrl(), postgreSqlServer.getProperties()), - "tpch.test_time_24", + "test_time_24", "(a time(0), b time(3), c time(6))", List.of( // "zero" row @@ -1224,7 +1224,7 @@ public void testTimestamp(boolean insertWithTrino, ZoneId sessionZone) tests.execute(getQueryRunner(), session, trinoCreateAndInsert(session, "test_timestamp")); } else { - tests.execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_timestamp")); + tests.execute(getQueryRunner(), session, postgresCreateAndInsert("test_timestamp")); } } @@ -1321,7 +1321,7 @@ public void testArrayTimestamp(boolean insertWithTrino, ZoneId sessionZone) tests.execute(getQueryRunner(), session, trinoCreateAsSelect(sessionWithArrayAsArray(), "test_array_timestamp")); } else { - tests.execute(getQueryRunner(), session, postgresCreateAndInsert("tpch.test_array_timestamp")); + tests.execute(getQueryRunner(), session, postgresCreateAndInsert("test_array_timestamp")); } } @@ -1409,7 +1409,7 @@ public void testTimestampWithTimeZone(boolean insertWithTrino) tests.execute(getQueryRunner(), trinoCreateAsSelect("test_timestamp_with_time_zone")); } else { - tests.execute(getQueryRunner(), postgresCreateAndInsert("tpch.test_timestamp_with_time_zone")); + tests.execute(getQueryRunner(), postgresCreateAndInsert("test_timestamp_with_time_zone")); } } @@ -1511,7 +1511,7 @@ public void testArrayTimestampWithTimeZone(boolean insertWithTrino) tests.execute(getQueryRunner(), sessionWithArrayAsArray(), trinoCreateAsSelect(sessionWithArrayAsArray(), "test_array_timestamp_with_time_zone")); } else { - tests.execute(getQueryRunner(), sessionWithArrayAsArray(), postgresCreateAndInsert("tpch.test_array_timestamp_with_time_zone")); + tests.execute(getQueryRunner(), sessionWithArrayAsArray(), postgresCreateAndInsert("test_array_timestamp_with_time_zone")); } } @@ -1519,7 +1519,7 @@ public void testArrayTimestampWithTimeZone(boolean insertWithTrino) public void testJson() { jsonTestCases(jsonDataType()) - .execute(getQueryRunner(), postgresCreateAndInsert("tpch.postgresql_test_json")); + .execute(getQueryRunner(), postgresCreateAndInsert("postgresql_test_json")); jsonTestCases(jsonDataType()) .execute(getQueryRunner(), trinoCreateAsSelect("trino__test_json")); @@ -1529,7 +1529,7 @@ public void testJson() public void testJsonb() { jsonTestCases(jsonbDataType()) - .execute(getQueryRunner(), postgresCreateAndInsert("tpch.postgresql_test_jsonb")); + .execute(getQueryRunner(), postgresCreateAndInsert("postgresql_test_jsonb")); } private DataTypeTest jsonTestCases(DataType jsonDataType) @@ -1551,10 +1551,10 @@ private DataTypeTest jsonTestCases(DataType jsonDataType) public void testHstore() { hstoreTestCases(hstoreDataType()) - .execute(getQueryRunner(), postgresCreateAndInsert("tpch.postgresql_test_hstore")); + .execute(getQueryRunner(), postgresCreateAndInsert("postgresql_test_hstore")); hstoreTestCases(varcharMapDataType()) - .execute(getQueryRunner(), postgresCreateTrinoInsert("tpch.postgresql_test_hstore")); + .execute(getQueryRunner(), postgresCreateTrinoInsert("postgresql_test_hstore")); } private DataTypeTest hstoreTestCases(DataType> varcharMapDataType) @@ -1572,7 +1572,7 @@ private DataTypeTest hstoreTestCases(DataType> varcharMapDat public void testUuid() { uuidTestCases(uuidDataType()) - .execute(getQueryRunner(), postgresCreateAndInsert("tpch.postgresql_test_uuid")); + .execute(getQueryRunner(), postgresCreateAndInsert("postgresql_test_uuid")); uuidTestCases(uuidDataType()) .execute(getQueryRunner(), trinoCreateAsSelect("trino__test_uuid")); @@ -1593,7 +1593,7 @@ public void testMoney() .addRoundTrip(moneyDataType(), 10.) .addRoundTrip(moneyDataType(), 10.54) .addRoundTrip(moneyDataType(), 10_000_000.42) - .execute(getQueryRunner(), postgresCreateAndInsert("tpch.trino_test_money")); + .execute(getQueryRunner(), postgresCreateAndInsert("trino_test_money")); } private void testUnsupportedDataTypeAsIgnored(String dataTypeName, String databaseValue) @@ -1606,7 +1606,7 @@ private void testUnsupportedDataTypeAsIgnored(Session session, String dataTypeNa JdbcSqlExecutor jdbcSqlExecutor = new JdbcSqlExecutor(postgreSqlServer.getJdbcUrl(), postgreSqlServer.getProperties()); try (TestTable table = new TestTable( jdbcSqlExecutor, - "tpch.unsupported_type", + "unsupported_type", format("(key varchar(5), unsupported_column %s)", dataTypeName), ImmutableList.of( "'1', NULL", @@ -1627,7 +1627,7 @@ private void testUnsupportedDataTypeConvertedToVarchar(Session session, String d JdbcSqlExecutor jdbcSqlExecutor = new JdbcSqlExecutor(postgreSqlServer.getJdbcUrl(), postgreSqlServer.getProperties()); try (TestTable table = new TestTable( jdbcSqlExecutor, - "tpch.unsupported_type", + "unsupported_type", format("(key varchar(5), unsupported_column %s)", dataTypeName), ImmutableList.of( "1, NULL", diff --git a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestingPostgreSqlServer.java b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestingPostgreSqlServer.java index 5e9aa6adfaeeb..5350e88677132 100644 --- a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestingPostgreSqlServer.java +++ b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestingPostgreSqlServer.java @@ -82,7 +82,7 @@ public Properties getProperties() public String getJdbcUrl() { - return format("jdbc:postgresql://%s:%s/%s", dockerContainer.getContainerIpAddress(), dockerContainer.getMappedPort(POSTGRESQL_PORT), DATABASE); + return format("jdbc:postgresql://%s:%s/%s?currentSchema=tpch", dockerContainer.getContainerIpAddress(), dockerContainer.getMappedPort(POSTGRESQL_PORT), DATABASE); } @Override