From 8357429832ac980fbc84ea4bfd0d82f42b967a6a Mon Sep 17 00:00:00 2001 From: Mayank Vadariya <48036907+mayankvadariya@users.noreply.github.com> Date: Tue, 8 Oct 2024 12:00:26 -0400 Subject: [PATCH 1/2] Add varchar/char cast pushdown support in Redshift --- .../trino/plugin/redshift/RedshiftClient.java | 8 +- .../plugin/redshift/RedshiftErrorCode.java | 40 ------ .../io/trino/plugin/redshift/RewriteCast.java | 12 ++ .../redshift/TestRedshiftCastPushdown.java | 119 +++++++++++++++++- .../redshift/TestRedshiftConnectorTest.java | 36 +++++- 5 files changed, 159 insertions(+), 56 deletions(-) delete mode 100644 plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftErrorCode.java diff --git a/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftClient.java b/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftClient.java index d8fc2991eea8c..30ec39ca09d1a 100644 --- a/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftClient.java +++ b/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftClient.java @@ -136,7 +136,6 @@ import static io.trino.plugin.jdbc.StandardColumnMappings.varcharWriteFunction; import static io.trino.plugin.jdbc.TypeHandlingJdbcSessionProperties.getUnsupportedTypeHandling; import static io.trino.plugin.jdbc.UnsupportedTypeHandling.CONVERT_TO_VARCHAR; -import static io.trino.plugin.redshift.RedshiftErrorCode.REDSHIFT_INVALID_TYPE; import static io.trino.spi.StandardErrorCode.INVALID_ARGUMENTS; import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED; import static io.trino.spi.type.BigintType.BIGINT; @@ -666,10 +665,9 @@ public Optional toColumnMapping(ConnectorSession session, Connect RedshiftClient::writeChar)); case Types.VARCHAR: { - if (type.columnSize().isEmpty()) { - throw new TrinoException(REDSHIFT_INVALID_TYPE, "column size not present"); - } - int length = type.requiredColumnSize(); + // Redshift column exposes precision with max precision upto `REDSHIFT_MAX_VARCHAR`. + // Defaulting to `VarcharType.MAX_LENGTH`(instead of `REDSHIFT_MAX_VARCHAR`) as synthetic column created by Trino creates unbounded varchar. + int length = type.columnSize().orElse(VarcharType.MAX_LENGTH); return Optional.of(varcharColumnMapping( length < VarcharType.MAX_LENGTH ? createVarcharType(length) diff --git a/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftErrorCode.java b/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftErrorCode.java deleted file mode 100644 index e092792702705..0000000000000 --- a/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftErrorCode.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.trino.plugin.redshift; - -import io.trino.spi.ErrorCode; -import io.trino.spi.ErrorCodeSupplier; -import io.trino.spi.ErrorType; - -import static io.trino.spi.ErrorType.EXTERNAL; - -public enum RedshiftErrorCode - implements ErrorCodeSupplier -{ - REDSHIFT_INVALID_TYPE(0, EXTERNAL), - /**/; - - private final ErrorCode errorCode; - - RedshiftErrorCode(int code, ErrorType type) - { - errorCode = new ErrorCode(code + 0x0511_0000, name(), type); - } - - @Override - public ErrorCode toErrorCode() - { - return errorCode; - } -} diff --git a/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RewriteCast.java b/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RewriteCast.java index 1694b5a4c8cd6..f7043b4c61072 100644 --- a/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RewriteCast.java +++ b/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RewriteCast.java @@ -18,10 +18,12 @@ import io.trino.plugin.jdbc.expression.AbstractRewriteCast; import io.trino.spi.connector.ConnectorSession; import io.trino.spi.type.BigintType; +import io.trino.spi.type.CharType; import io.trino.spi.type.DecimalType; import io.trino.spi.type.IntegerType; import io.trino.spi.type.SmallintType; import io.trino.spi.type.Type; +import io.trino.spi.type.VarcharType; import java.util.List; import java.util.Optional; @@ -29,9 +31,11 @@ import static java.sql.Types.BIGINT; import static java.sql.Types.BIT; +import static java.sql.Types.CHAR; import static java.sql.Types.INTEGER; import static java.sql.Types.NUMERIC; import static java.sql.Types.SMALLINT; +import static java.sql.Types.VARCHAR; public class RewriteCast extends AbstractRewriteCast @@ -57,6 +61,10 @@ protected Optional toJdbcTypeHandle(JdbcTypeHandle sourceType, T Optional.of(new JdbcTypeHandle(INTEGER, Optional.of(integerType.getBaseName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty())); case BigintType bigintType -> Optional.of(new JdbcTypeHandle(BIGINT, Optional.of(bigintType.getBaseName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty())); + case VarcharType varcharType -> + Optional.of(new JdbcTypeHandle(VARCHAR, Optional.of(varcharType.getBaseName()), varcharType.getLength(), Optional.empty(), Optional.empty(), Optional.empty())); + case CharType charType -> + Optional.of(new JdbcTypeHandle(CHAR, Optional.of(charType.getBaseName()), Optional.of(charType.getLength()), Optional.empty(), Optional.empty(), Optional.empty())); default -> Optional.empty(); }; } @@ -66,6 +74,10 @@ private boolean pushdownSupported(JdbcTypeHandle sourceType, Type targetType) return switch (targetType) { case SmallintType _, IntegerType _, BigintType _ -> SUPPORTED_SOURCE_TYPE_FOR_INTEGRAL_CAST.contains(sourceType.jdbcType()); + // char -> varchar is not supported as Redshift doesn't pad char value with blanks whereas Trino pads char value with blanks. + case VarcharType _ -> VARCHAR == sourceType.jdbcType(); + // varchar -> char is unsupported as varchar supports multi-byte characters whereas char supports only single byte characters. + case CharType _ -> CHAR == sourceType.jdbcType(); default -> false; }; } diff --git a/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftCastPushdown.java b/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftCastPushdown.java index eb4ce8bcd6782..18d67177ad662 100644 --- a/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftCastPushdown.java +++ b/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftCastPushdown.java @@ -21,6 +21,7 @@ import io.trino.sql.planner.plan.ProjectNode; import io.trino.testing.QueryRunner; import io.trino.testing.sql.SqlExecutor; +import io.trino.testing.sql.TestTable; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -79,9 +80,17 @@ public void setupTable() .addColumn("c_numeric_10_2", "numeric(10, 2)", asList(1.23, 2.67, null)) .addColumn("c_numeric_19_2", "numeric(19, 2)", asList(1.23, 2.67, null)) // Equal to REDSHIFT_DECIMAL_CUTOFF_PRECISION .addColumn("c_numeric_30_2", "numeric(30, 2)", asList(1.23, 2.67, null)) + .addColumn("c_char", "char", asList("'I'", "'P'", null)) + .addColumn("c_character", "character", asList("'I'", "'P'", null)) .addColumn("c_char_10", "char(10)", asList("'India'", "'Poland'", null)) .addColumn("c_char_50", "char(50)", asList("'India'", "'Poland'", null)) .addColumn("c_char_4096", "char(4096)", asList("'India'", "'Poland'", null)) // Equal to REDSHIFT_MAX_CHAR + + // the number of Unicode code points in 攻殻機動隊 is 5, and in 😂 is 1. + .addColumn("c_varchar_unicode", "varchar(15)", asList("'攻殻機動隊'", "'😂'", null)) + .addColumn("c_nvarchar_unicode", "nvarchar(15)", asList("'攻殻機動隊'", "'😂'", null)) + + .addColumn("c_nchar", "nchar", asList("'I'", "'P'", null)) .addColumn("c_nchar_10", "nchar(10)", asList("'India'", "'Poland'", null)) .addColumn("c_nchar_50", "nchar(50)", asList("'India'", "'Poland'", null)) .addColumn("c_nchar_4096", "nchar(4096)", asList("'India'", "'Poland'", null)) // Equal to REDSHIFT_MAX_CHAR @@ -89,6 +98,7 @@ public void setupTable() .addColumn("c_varchar_10", "varchar(10)", asList("'India'", "'Poland'", null)) .addColumn("c_varchar_50", "varchar(50)", asList("'India'", "'Poland'", null)) .addColumn("c_varchar_65535", "varchar(65535)", asList("'India'", "'Poland'", null)) // Equal to REDSHIFT_MAX_VARCHAR + .addColumn("c_nvarchar", "nvarchar", asList("'India'", "'Poland'", null)) .addColumn("c_nvarchar_10", "nvarchar(10)", asList("'India'", "'Poland'", null)) .addColumn("c_nvarchar_50", "nvarchar(50)", asList("'India'", "'Poland'", null)) .addColumn("c_nvarchar_65535", "nvarchar(65535)", asList("'India'", "'Poland'", null)) // Greater than REDSHIFT_MAX_VARCHAR @@ -144,9 +154,17 @@ public void setupTable() .addColumn("c_numeric_10_2", "numeric(10, 2)", asList(1.23, 22.67, null)) .addColumn("c_numeric_19_2", "numeric(19, 2)", asList(1.23, 22.67, null)) // Equal to REDSHIFT_DECIMAL_CUTOFF_PRECISION .addColumn("c_numeric_30_2", "numeric(30, 2)", asList(1.23, 22.67, null)) + .addColumn("c_char", "char", asList("'I'", "'F'", null)) + .addColumn("c_character", "character", asList("'I'", "'F'", null)) .addColumn("c_char_10", "char(10)", asList("'India'", "'France'", null)) .addColumn("c_char_50", "char(50)", asList("'India'", "'France'", null)) .addColumn("c_char_4096", "char(4096)", asList("'India'", "'France'", null)) // Equal to REDSHIFT_MAX_CHAR + + // the number of Unicode code points in 攻殻機動隊 is 5, and in 😂 is 1. + .addColumn("c_varchar_unicode", "varchar(15)", asList("'攻殻機動隊'", "'😂'", null)) + .addColumn("c_nvarchar_unicode", "nvarchar(15)", asList("'攻殻機動隊'", "'😂'", null)) + + .addColumn("c_nchar", "nchar", asList("'I'", "'F'", null)) .addColumn("c_nchar_10", "nchar(10)", asList("'India'", "'France'", null)) .addColumn("c_nchar_50", "nchar(50)", asList("'India'", "'France'", null)) .addColumn("c_nchar_4096", "nchar(4096)", asList("'India'", "'France'", null)) // Equal to REDSHIFT_MAX_CHAR @@ -154,6 +172,7 @@ public void setupTable() .addColumn("c_varchar_10", "varchar(10)", asList("'India'", "'France'", null)) .addColumn("c_varchar_50", "varchar(50)", asList("'India'", "'France'", null)) .addColumn("c_varchar_65535", "varchar(65535)", asList("'India'", "'France'", null)) // Equal to REDSHIFT_MAX_VARCHAR + .addColumn("c_nvarchar", "nvarchar", asList("'India'", "'France'", null)) .addColumn("c_nvarchar_10", "nvarchar(10)", asList("'India'", "'France'", null)) .addColumn("c_nvarchar_50", "nvarchar(50)", asList("'India'", "'France'", null)) .addColumn("c_nvarchar_65535", "nvarchar(65535)", asList("'India'", "'France'", null)) // Equal to REDSHIFT_MAX_VARCHAR @@ -243,6 +262,17 @@ public void testAllJoinPushdownWithCast() // Full Join pushdown is not supported assertThat(query("SELECT l.id FROM %s l FULL JOIN %s r ON CAST(l.%s AS %s) = r.%s".formatted(leftTable(), rightTable(), testCase.sourceColumn(), testCase.castType(), testCase.targetColumn()))) .joinIsNotFullyPushedDown(); + + testCase = new CastTestCase("c_varchar_10", "varchar(200)", "c_varchar_50"); + assertThat(query("SELECT l.id FROM %s l LEFT JOIN %s r ON CAST(l.%3$s AS %4$s) = CAST(r.%5$s AS %4$s)".formatted(leftTable(), rightTable(), testCase.sourceColumn(), testCase.castType(), testCase.targetColumn()))) + .isFullyPushedDown(); + assertThat(query("SELECT l.id FROM %s l RIGHT JOIN %s r ON CAST(l.%3$s AS %4$s) = CAST(r.%5$s AS %4$s)".formatted(leftTable(), rightTable(), testCase.sourceColumn(), testCase.castType(), testCase.targetColumn()))) + .isFullyPushedDown(); + assertThat(query("SELECT l.id FROM %s l INNER JOIN %s r ON CAST(l.%3$s AS %4$s) = CAST(r.%5$s AS %4$s)".formatted(leftTable(), rightTable(), testCase.sourceColumn(), testCase.castType(), testCase.targetColumn()))) + .isFullyPushedDown(); + // Full Join pushdown is not supported + assertThat(query("SELECT l.id FROM %s l FULL JOIN %s r ON CAST(l.%3$s AS %4$s) = CAST(r.%5$s AS %4$s)".formatted(leftTable(), rightTable(), testCase.sourceColumn(), testCase.castType(), testCase.targetColumn()))) + .joinIsNotFullyPushedDown(); } @Test @@ -364,6 +394,16 @@ public void testCastPushdownWithForcedTypedToInteger() .isNotFullyPushedDown(ProjectNode.class); } + @Test + void testCastPushdownWithForcedTypedToVarchar() + { + // These column types are not supported by default by trino. These types are forced mapped to varchar. + assertThat(query("SELECT CAST(c_timetz AS VARCHAR(100)) FROM %s".formatted(leftTable()))) + .isNotFullyPushedDown(ProjectNode.class); + assertThat(query("SELECT CAST(c_super AS VARCHAR(100)) FROM %s".formatted(leftTable()))) + .isNotFullyPushedDown(ProjectNode.class); + } + @Override protected List supportedCastTypePushdown() { @@ -393,6 +433,41 @@ protected List supportedCastTypePushdown() new CastTestCase("c_numeric_30_2", "integer", "c_integer"), new CastTestCase("c_decimal_negative", "integer", "c_integer"), + new CastTestCase("c_char_10", "char(50)", "c_char_50"), + new CastTestCase("c_char_10", "char(256)", "c_bpchar"), + new CastTestCase("c_varchar_10", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_nvarchar_10", "varchar(50)", "c_nvarchar_50"), + new CastTestCase("c_varchar_10", "varchar(50)", "c_text"), + + new CastTestCase("c_char_50", "char(10)", "c_char_10"), + new CastTestCase("c_bpchar", "char(10)", "c_char_10"), + new CastTestCase("c_varchar_50", "varchar(10)", "c_varchar_10"), + new CastTestCase("c_nvarchar_50", "varchar(10)", "c_nvarchar_10"), + new CastTestCase("c_text", "varchar(10)", "c_varchar_10"), + + new CastTestCase("c_char_10", "char(50)", "c_char_50"), + new CastTestCase("c_char_10", "char(256)", "c_bpchar"), + new CastTestCase("c_char", "char(4096)", "c_char_4096"), + new CastTestCase("c_char", "char(1)", "c_nchar"), + new CastTestCase("c_varchar_10", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_nvarchar_10", "varchar(50)", "c_nvarchar_50"), + new CastTestCase("c_varchar_10", "varchar(50)", "c_text"), + + new CastTestCase("c_varchar_50", "varchar(10)", "c_varchar_10"), + + new CastTestCase("c_varchar_10", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_varchar_10", "varchar(65535)", "c_varchar_65535"), + new CastTestCase("c_varchar_10", "varchar(256)", "c_nvarchar"), + new CastTestCase("c_varchar_10", "varchar(10)", "c_nvarchar_10"), + new CastTestCase("c_varchar_10", "varchar(50)", "c_nvarchar_50"), + new CastTestCase("c_varchar_10", "varchar(65535)", "c_nvarchar_65535"), + new CastTestCase("c_varchar_10", "varchar(256)", "c_text"), + new CastTestCase("c_varchar_10", "varchar", "c_text"), + + new CastTestCase("c_varchar_unicode", "varchar", "c_varchar_50"), + new CastTestCase("c_varchar_unicode", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_nvarchar_unicode", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_boolean", "bigint", "c_bigint"), new CastTestCase("c_smallint", "bigint", "c_bigint"), new CastTestCase("c_integer", "bigint", "c_bigint"), @@ -460,11 +535,30 @@ protected List unsupportedCastTypePushdown() new CastTestCase("c_real", "double", "c_double_precision"), new CastTestCase("c_double_precision", "real", "c_real"), new CastTestCase("c_double_precision", "decimal(10,2)", "c_decimal_10_2"), - new CastTestCase("c_char_10", "char(50)", "c_char_50"), - new CastTestCase("c_char_10", "char(256)", "c_bpchar"), - new CastTestCase("c_varchar_10", "varchar(50)", "c_varchar_50"), - new CastTestCase("c_nvarchar_10", "varchar(50)", "c_nvarchar_50"), - new CastTestCase("c_varchar_10", "varchar(50)", "c_text"), + + new CastTestCase("c_varchar_50", "char(50)", "c_char_50"), + new CastTestCase("c_char_50", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_boolean", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_smallint", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_int2", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_integer", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_int", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_int4", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_bigint", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_int8", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_real", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_float4", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_double_precision", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_float", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_float8", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_double_precision", "varchar(50)", "c_varchar_50"), + + new CastTestCase("c_timestamp", "varchar(50)", "c_varchar_50"), + new CastTestCase("c_date", "varchar(50)", "c_varchar_50"), + + new CastTestCase("c_varchar_unicode", "char(50)", "c_char_50"), + new CastTestCase("c_nvarchar_unicode", "char(50)", "c_char_50"), + new CastTestCase("c_timestamp", "date", "c_date"), new CastTestCase("c_timestamp", "time", "c_time"), new CastTestCase("c_date", "timestamp", "c_timestamp"), @@ -491,4 +585,19 @@ protected List invalidCast() new InvalidCastTestCase("c_timetz", "int"), new InvalidCastTestCase("c_timetz", "bigint")); } + + @Test + void testCastPushdownWithCharConvertedToVarchar() + { + try (TestTable table = new TestTable( + getQueryRunner()::execute, + TEST_SCHEMA + "." + "case_sensitive_1_", + "(a char(4097))", // char(REDSHIFT_MAX_CHAR` + 1) is converted to varchar(REDSHIFT_MAX_CHAR` + 1) in Redshift + ImmutableList.of("'hello'"))) { + assertThat(query("SELECT cast(a AS varchar(50)) FROM " + table.getName())) + .isFullyPushedDown(); + assertThat(query("SELECT cast(a AS char(50)) FROM " + table.getName())) + .isNotFullyPushedDown(ProjectNode.class); + } + } } diff --git a/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftConnectorTest.java b/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftConnectorTest.java index 2b47cf8b77803..4e6556c606a18 100644 --- a/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftConnectorTest.java +++ b/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftConnectorTest.java @@ -698,17 +698,17 @@ public void testJoinPushdownWithImplicitCast() try (TestTable leftTable = new TestTable( getQueryRunner()::execute, "left_table_", - "(id int, c_boolean boolean, c_tinyint tinyint, c_smallint smallint, c_integer integer, c_bigint bigint, c_real real, c_double_precision double precision, c_decimal_10_2 decimal(10, 2))", + "(id int, c_boolean boolean, c_tinyint tinyint, c_smallint smallint, c_integer integer, c_bigint bigint, c_real real, c_double_precision double precision, c_decimal_10_2 decimal(10, 2), c_varchar_50 varchar(50))", ImmutableList.of( - "(11, true, 12, 12, 12, 12, 12.34, 12.34, 12.34)", - "(12, false, 123, 123, 123, 123, 123.67, 123.67, 123.67)")); + "(11, true, 12, 12, 12, 12, 12.34, 12.34, 12.34, 'India')", + "(12, false, 123, 123, 123, 123, 123.67, 123.67, 123.67, 'Poland')")); TestTable rightTable = new TestTable( getQueryRunner()::execute, "right_table_", - "(id int, c_boolean boolean, c_tinyint tinyint, c_smallint smallint, c_integer integer, c_bigint bigint, c_real real, c_double_precision double precision, c_decimal_10_2 decimal(10, 2))", + "(id int, c_boolean boolean, c_tinyint tinyint, c_smallint smallint, c_integer integer, c_bigint bigint, c_real real, c_double_precision double precision, c_decimal_10_2 decimal(10, 2), c_varchar_100 varchar(100), c_varchar varchar)", ImmutableList.of( - "(21, true, 12, 12, 12, 12, 12.34, 12.34, 12.34)", - "(22, true, 234, 234, 234, 234, 234.67, 234.67, 234.67)"))) { + "(21, true, 12, 12, 12, 12, 12.34, 12.34, 12.34, 'India', 'Japan')", + "(22, true, 234, 234, 234, 234, 234.67, 234.67, 234.67, 'France', 'Poland')"))) { Session session = joinPushdownEnabled(getSession()); String joinQuery = "SELECT l.id FROM " + leftTable.getName() + " l %s " + rightTable.getName() + " r ON %s"; @@ -773,6 +773,30 @@ public void testJoinPushdownWithImplicitCast() // Full Join pushdown is not supported assertThat(query(session,joinQuery.formatted("FULL JOIN", "l.c_decimal_10_2 = r.c_bigint"))) .joinIsNotFullyPushedDown(); + + // Implicit cast between bounded varchar + String joinWithBoundedVarchar = "SELECT l.id FROM %s l %s %s r ON l.c_varchar_50 = r.c_varchar_100".formatted(leftTable.getName(), "%s", rightTable.getName()); + assertThat(query(session, joinWithBoundedVarchar.formatted("LEFT JOIN"))) + .isFullyPushedDown(); + assertThat(query(session, joinWithBoundedVarchar.formatted("RIGHT JOIN"))) + .isFullyPushedDown(); + assertThat(query(session, joinWithBoundedVarchar.formatted("INNER JOIN"))) + .isFullyPushedDown(); + // Full Join pushdown is not supported + assertThat(query(session, joinWithBoundedVarchar.formatted("FULL JOIN"))) + .joinIsNotFullyPushedDown(); + + // Implicit cast between bounded and max precision varchar + String joinWithMaxPrecisionVarchar = "SELECT l.id FROM %s l %s %s r ON l.c_varchar_50 = r.c_varchar".formatted(leftTable.getName(), "%s", rightTable.getName()); + assertThat(query(session, joinWithMaxPrecisionVarchar.formatted("LEFT JOIN"))) + .isFullyPushedDown(); + assertThat(query(session, joinWithMaxPrecisionVarchar.formatted("RIGHT JOIN"))) + .isFullyPushedDown(); + assertThat(query(session, joinWithMaxPrecisionVarchar.formatted("INNER JOIN"))) + .isFullyPushedDown(); + // Full Join pushdown is not supported + assertThat(query(session, joinWithMaxPrecisionVarchar.formatted("FULL JOIN"))) + .joinIsNotFullyPushedDown(); } } From ca1ca7261aff0b1bad603ab9c9b73aa1baf4004e Mon Sep 17 00:00:00 2001 From: Mayank Vadariya <48036907+mayankvadariya@users.noreply.github.com> Date: Tue, 22 Oct 2024 20:50:24 -0400 Subject: [PATCH 2/2] REMOVE - temp commit --- .github/workflows/ci.yml | 2 +- plugin/trino-redshift/pom.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f92c551677d30..c1d8b0d73ead9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -501,7 +501,7 @@ jobs: strategy: fail-fast: false matrix: ${{ fromJson(needs.build-test-matrix.outputs.matrix) }} - timeout-minutes: 60 + timeout-minutes: 180 steps: - uses: actions/checkout@v4 with: diff --git a/plugin/trino-redshift/pom.xml b/plugin/trino-redshift/pom.xml index 7feef70f7d0ce..27a54c63217f9 100644 --- a/plugin/trino-redshift/pom.xml +++ b/plugin/trino-redshift/pom.xml @@ -265,6 +265,7 @@ **/TestRedshiftCastPushdown.java **/TestRedshiftConnectorSmokeTest.java + **/TestRedshiftConnectorTest.java