Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix testSetColumnTypes nested catch+verify #15930

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
Original file line number Diff line number Diff line change
Expand Up @@ -6375,6 +6375,8 @@ protected Optional<SetColumnTypeSetup> filterSetColumnTypesDataProvider(SetColum
case "bigint -> integer":
case "decimal(5,3) -> decimal(5,2)":
case "varchar -> char(20)":
case "time(6) -> time(3)":
case "timestamp(6) -> timestamp(3)":
case "array(integer) -> array(bigint)":
// Iceberg allows updating column types if the update is safe. Safe updates are:
// - int to bigint
Expand All @@ -6393,7 +6395,9 @@ protected Optional<SetColumnTypeSetup> filterSetColumnTypesDataProvider(SetColum
@Override
protected void verifySetColumnTypeFailurePermissible(Throwable e)
{
assertThat(e).hasMessageMatching(".*(Cannot change column type|not supported for Iceberg|Not a primitive type|Cannot change type ).*");
assertThat(e).hasMessageMatching(".*(Failed to set column type: Cannot change (column type:|type from .* to )" +
"|Time(stamp)? precision \\(3\\) not supported for Iceberg. Use \"time(stamp)?\\(6\\)\" instead" +
"|Type not supported for Iceberg: char\\(20\\)).*");
}

private Session prepareCleanUpSession()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2212,7 +2212,15 @@ public void testSetColumnTypes(SetColumnTypeSetup setup)
{
skipTestUnless(hasBehavior(SUPPORTS_SET_COLUMN_TYPE) && hasBehavior(SUPPORTS_CREATE_TABLE_WITH_DATA));

try (TestTable table = new TestTable(getQueryRunner()::execute, "test_set_column_type_", " AS SELECT CAST(" + setup.sourceValueLiteral + " AS " + setup.sourceColumnType + ") AS col")) {
TestTable table;
try {
table = new TestTable(getQueryRunner()::execute, "test_set_column_type_", " AS SELECT CAST(" + setup.sourceValueLiteral + " AS " + setup.sourceColumnType + ") AS col");
}
catch (Exception e) {
verifyUnsupportedTypeException(e, setup.sourceColumnType);
throw new SkipException("Unsupported column type: " + setup.sourceColumnType);
}
try (table) {
Runnable setColumnType = () -> assertUpdate("ALTER TABLE " + table.getName() + " ALTER COLUMN col SET DATA TYPE " + setup.newColumnType);
findepi marked this conversation as resolved.
Show resolved Hide resolved
if (setup.unsupportedType) {
assertThatThrownBy(setColumnType::run)
Expand All @@ -2226,10 +2234,6 @@ public void testSetColumnTypes(SetColumnTypeSetup setup)
.skippingTypesCheck()
.matches("SELECT " + setup.newValueLiteral);
}
catch (Exception e) {
verifyUnsupportedTypeException(e, setup.sourceColumnType);
throw new SkipException("Unsupported column type: " + setup.sourceColumnType);
}
}

@DataProvider
Expand Down