Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin/trino-redshift/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<dependency>
<groupId>com.amazon.redshift</groupId>
<artifactId>redshift-jdbc42</artifactId>
<version>2.1.0.9</version>
<version>2.1.0.12</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import static io.trino.plugin.redshift.RedshiftQueryRunner.createRedshiftQueryRunner;
import static io.trino.plugin.redshift.RedshiftQueryRunner.executeInRedshift;
import static io.trino.plugin.redshift.RedshiftQueryRunner.executeWithRedshift;
import static io.trino.testing.DataProviders.cartesianProduct;
import static io.trino.testing.DataProviders.trueFalse;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static java.lang.String.format;
import static java.util.Locale.ENGLISH;
Expand Down Expand Up @@ -151,6 +153,30 @@ public void testReadFromLateBindingView(String redshiftType, String trinoType)
}
}

@Test(dataProvider = "testReadNullFromViewDataProvider")
public void testReadNullFromView(String redshiftType, String trinoType, boolean lateBindingView)
{
try (TestView view = new TestView(
onRemoteDatabase(),
TEST_SCHEMA + ".cast_null_view",
"SELECT CAST(NULL AS %s) AS value %s".formatted(redshiftType, lateBindingView ? "WITH NO SCHEMA BINDING" : ""))) {
assertThat(query("SELECT value FROM %s".formatted(view.getName())))
.skippingTypesCheck() // trino returns 'unknown' for null
.matches("VALUES null");

assertThat(query("SHOW COLUMNS FROM %s LIKE 'value'".formatted(view.getName())))
.projected(1)
.skippingTypesCheck()
.matches("VALUES '%s'".formatted(trinoType));
}
}

@DataProvider
public Object[][] testReadNullFromViewDataProvider()
{
return cartesianProduct(redshiftTypeToTrinoTypes(), trueFalse());
}

@DataProvider
public Object[][] redshiftTypeToTrinoTypes()
{
Expand All @@ -164,6 +190,8 @@ public Object[][] redshiftTypeToTrinoTypes()
{"BOOLEAN", "boolean"},
{"CHAR(1)", "char(1)"},
{"VARCHAR(1)", "varchar(1)"},
// consider to extract "CHARACTER VARYING" type from here as it requires exact length, 0 - is for the empty string
{"CHARACTER VARYING", "varchar(0)"},
{"TIME", "time(6)"},
{"TIMESTAMP", "timestamp(6)"},
{"TIMESTAMPTZ", "timestamp(6) with time zone"}};
Expand Down