diff --git a/plugin/trino-faker/src/main/java/io/trino/plugin/faker/FakerMetadata.java b/plugin/trino-faker/src/main/java/io/trino/plugin/faker/FakerMetadata.java index d16d788a6f5c..0e3be1ef747f 100644 --- a/plugin/trino-faker/src/main/java/io/trino/plugin/faker/FakerMetadata.java +++ b/plugin/trino-faker/src/main/java/io/trino/plugin/faker/FakerMetadata.java @@ -66,6 +66,7 @@ import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableMap.toImmutableMap; import static io.trino.spi.StandardErrorCode.INVALID_COLUMN_PROPERTY; +import static io.trino.spi.StandardErrorCode.INVALID_COLUMN_REFERENCE; import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED; import static io.trino.spi.StandardErrorCode.SCHEMA_ALREADY_EXISTS; import static io.trino.spi.StandardErrorCode.SCHEMA_NOT_FOUND; @@ -263,7 +264,7 @@ public synchronized void setColumnComment(ConnectorSession session, ConnectorTab .map(columnInfo -> { if (columnInfo.handle().equals(column)) { if (ROW_ID_COLUMN_NAME.equals(columnInfo.handle().name())) { - throw new IllegalArgumentException(String.format("Cannot set comment for %s column", ROW_ID_COLUMN_NAME)); + throw new TrinoException(INVALID_COLUMN_REFERENCE, "Cannot set comment for %s column".formatted(ROW_ID_COLUMN_NAME)); } return columnInfo.withComment(comment); } diff --git a/plugin/trino-faker/src/test/java/io/trino/plugin/faker/TestFakerQueries.java b/plugin/trino-faker/src/test/java/io/trino/plugin/faker/TestFakerQueries.java index 82836df77502..2c552a3f6cca 100644 --- a/plugin/trino-faker/src/test/java/io/trino/plugin/faker/TestFakerQueries.java +++ b/plugin/trino-faker/src/test/java/io/trino/plugin/faker/TestFakerQueries.java @@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test; import static io.trino.plugin.faker.FakerSplitManager.MAX_ROWS_PER_SPLIT; +import static io.trino.spi.StandardErrorCode.INVALID_COLUMN_REFERENCE; import static org.assertj.core.api.Assertions.assertThat; final class TestFakerQueries @@ -54,7 +55,8 @@ void testCannotCommentRowId() { try (TestTable table = new TestTable(getQueryRunner()::execute, "cannot_comment", "(id INTEGER, name VARCHAR)")) { assertThat(query("COMMENT ON COLUMN \"%s\".\"$row_id\" IS 'comment text'".formatted(table.getName()))) - .nonTrinoExceptionFailure() + .failure() + .hasErrorCode(INVALID_COLUMN_REFERENCE) .hasMessageContaining("Cannot set comment for $row_id column"); } }