diff --git a/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/TestAccumuloConnectorTest.java b/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/TestAccumuloConnectorTest.java index 6404b1049d5c..6e0bdab21e28 100644 --- a/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/TestAccumuloConnectorTest.java +++ b/plugin/trino-accumulo/src/test/java/io/trino/plugin/accumulo/TestAccumuloConnectorTest.java @@ -29,6 +29,7 @@ import static io.trino.plugin.accumulo.AccumuloQueryRunner.createAccumuloQueryRunner; import static io.trino.spi.type.VarcharType.VARCHAR; import static io.trino.testing.MaterializedResult.resultBuilder; +import static io.trino.testing.sql.TestTable.randomTableSuffix; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.testng.Assert.assertEquals; @@ -95,6 +96,18 @@ protected TestTable createTableWithDefaultColumns() throw new SkipException("Accumulo connector does not support column default values"); } + @Override + public void testCreateTableWithColumnComment() + { + // TODO Avoid setting hard-coded column comment + String tableName = "test_create_" + randomTableSuffix(); + + assertUpdate("CREATE TABLE " + tableName + " (a bigint COMMENT 'test comment')"); + assertEquals(getColumnComment(tableName, "a"), "Accumulo row ID"); + + assertUpdate("DROP TABLE " + tableName); + } + @Override public void testCreateTableAsSelect() { diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/BaseJdbcClient.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/BaseJdbcClient.java index e5c5e44e1d52..bdef454289c8 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/BaseJdbcClient.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/BaseJdbcClient.java @@ -546,6 +546,9 @@ protected String createTableSql(RemoteTableName remoteTableName, List co protected String getColumnDefinitionSql(ConnectorSession session, ColumnMetadata column, String columnName) { + if (column.getComment() != null) { + throw new TrinoException(NOT_SUPPORTED, "This connector does not support creating tables with column comment"); + } StringBuilder sb = new StringBuilder() .append(quoted(columnName)) .append(" ") diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcConnectorTest.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcConnectorTest.java index 80a4ea3be695..71fffa2636fb 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcConnectorTest.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcConnectorTest.java @@ -66,6 +66,7 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) case SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS: return false; + case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: case SUPPORTS_COMMENT_ON_TABLE: case SUPPORTS_COMMENT_ON_COLUMN: case SUPPORTS_ADD_COLUMN_WITH_COMMENT: diff --git a/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryMetadata.java b/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryMetadata.java index 9efb930d6ec3..4cd534d33ce3 100644 --- a/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryMetadata.java +++ b/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryMetadata.java @@ -79,6 +79,7 @@ import static io.trino.plugin.bigquery.BigQueryTableHandle.BigQueryPartitionType.INGESTION; import static io.trino.plugin.bigquery.BigQueryType.toField; import static io.trino.plugin.bigquery.BigQueryUtil.isWildcardTable; +import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED; import static java.util.Locale.ENGLISH; import static java.util.Objects.requireNonNull; import static java.util.function.Function.identity; @@ -393,6 +394,7 @@ private void createTable(ConnectorSession session, ConnectorTableMetadata tableM } List fields = tableMetadata.getColumns().stream() + .peek(column -> throwIfNotNull(column.getComment())) .map(column -> toField(column.getName(), column.getType())) .collect(toImmutableList()); @@ -507,4 +509,11 @@ public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, Connect } }; } + + private static void throwIfNotNull(String comment) + { + if (comment != null) { + throw new TrinoException(NOT_SUPPORTED, "This connector does not support creating tables with column comment"); + } + } } diff --git a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestBigQueryConnectorTest.java b/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestBigQueryConnectorTest.java index 51047711468e..17f61cfcf38d 100644 --- a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestBigQueryConnectorTest.java +++ b/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestBigQueryConnectorTest.java @@ -69,6 +69,7 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) case SUPPORTS_RENAME_TABLE: case SUPPORTS_NOT_NULL_CONSTRAINT: case SUPPORTS_CREATE_TABLE_WITH_DATA: + case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: case SUPPORTS_DELETE: case SUPPORTS_INSERT: case SUPPORTS_ADD_COLUMN: diff --git a/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraMetadata.java b/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraMetadata.java index 1740cbbd599f..c5b252137571 100644 --- a/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraMetadata.java +++ b/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraMetadata.java @@ -293,6 +293,9 @@ private CassandraOutputTableHandle createTable(ConnectorTableMetadata tableMetad ImmutableList.Builder columnExtra = ImmutableList.builder(); columnExtra.add(new ExtraColumnMetadata(ID_COLUMN_NAME, true)); for (ColumnMetadata column : tableMetadata.getColumns()) { + if (column.getComment() != null) { + throw new TrinoException(NOT_SUPPORTED, "This connector does not support creating tables with column comment"); + } columnNames.add(column.getName()); columnTypes.add(column.getType()); columnExtra.add(new ExtraColumnMetadata(column.getName(), column.isHidden())); diff --git a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java index 8ec93a8d2707..a6eb746d7ca0 100644 --- a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java +++ b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java @@ -95,6 +95,9 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) case SUPPORTS_CREATE_VIEW: return false; + case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: + return false; + case SUPPORTS_RENAME_TABLE: return false; diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseConnectorTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseConnectorTest.java index 22090b79557a..c2764b2260d2 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseConnectorTest.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseConnectorTest.java @@ -224,15 +224,6 @@ protected TestTable createTableWithDefaultColumns() "col_required2 Int64) ENGINE=Log"); } - @Test - public void testCreateTableWithColumnComment() - { - // TODO (https://github.com/trinodb/trino/issues/11162) Merge into BaseConnectorTest - try (TestTable table = new TestTable(getQueryRunner()::execute, "test_column_comment", "(col integer COMMENT 'column comment')")) { - assertEquals(getColumnComment(table.getName(), "col"), "column comment"); - } - } - @Override public void testCharVarcharComparison() { diff --git a/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/KuduMetadata.java b/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/KuduMetadata.java index 92a5f3fac2ff..8638d7eefe2f 100755 --- a/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/KuduMetadata.java +++ b/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/KuduMetadata.java @@ -247,6 +247,9 @@ public void dropSchema(ConnectorSession session, String schemaName) @Override public void createTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, boolean ignoreExisting) { + if (tableMetadata.getColumns().stream().anyMatch(column -> column.getComment() != null)) { + throw new TrinoException(NOT_SUPPORTED, "This connector does not support creating tables with column comment"); + } clientSession.createTable(tableMetadata, ignoreExisting); } diff --git a/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/AbstractKuduConnectorTest.java b/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/AbstractKuduConnectorTest.java index d769c3aa2585..898e75b0dfe5 100644 --- a/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/AbstractKuduConnectorTest.java +++ b/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/AbstractKuduConnectorTest.java @@ -275,6 +275,22 @@ public void testCreateTable() throw new SkipException("TODO"); } + @Override + public void testCreateTableWithColumnComment() + { + // TODO https://github.com/trinodb/trino/issues/12469 Support column comment when creating tables + String tableName = "test_create_" + randomTableSuffix(); + + assertQueryFails( + "CREATE TABLE " + tableName + "(" + + "id INT WITH (primary_key=true)," + + "a VARCHAR COMMENT 'test comment')" + + "WITH (partition_by_hash_columns = ARRAY['id'], partition_by_hash_buckets = 2)", + "This connector does not support creating tables with column comment"); + + assertUpdate("DROP TABLE IF EXISTS " + tableName); + } + @Override public void testDropTable() { diff --git a/plugin/trino-mariadb/src/test/java/io/trino/plugin/mariadb/BaseMariaDbConnectorTest.java b/plugin/trino-mariadb/src/test/java/io/trino/plugin/mariadb/BaseMariaDbConnectorTest.java index 5e128fb478e0..38e43430eccc 100644 --- a/plugin/trino-mariadb/src/test/java/io/trino/plugin/mariadb/BaseMariaDbConnectorTest.java +++ b/plugin/trino-mariadb/src/test/java/io/trino/plugin/mariadb/BaseMariaDbConnectorTest.java @@ -43,6 +43,7 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) case SUPPORTS_AGGREGATION_PUSHDOWN_STDDEV: case SUPPORTS_AGGREGATION_PUSHDOWN_VARIANCE: return true; + case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: case SUPPORTS_ADD_COLUMN_WITH_COMMENT: case SUPPORTS_JOIN_PUSHDOWN_WITH_FULL_JOIN: case SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM: diff --git a/plugin/trino-memory/src/main/java/io/trino/plugin/memory/MemoryMetadata.java b/plugin/trino-memory/src/main/java/io/trino/plugin/memory/MemoryMetadata.java index b5991e8614e5..d5d0ef11510e 100644 --- a/plugin/trino-memory/src/main/java/io/trino/plugin/memory/MemoryMetadata.java +++ b/plugin/trino-memory/src/main/java/io/trino/plugin/memory/MemoryMetadata.java @@ -67,6 +67,7 @@ import static com.google.common.collect.ImmutableMap.toImmutableMap; import static io.trino.spi.StandardErrorCode.ALREADY_EXISTS; import static io.trino.spi.StandardErrorCode.NOT_FOUND; +import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED; import static io.trino.spi.StandardErrorCode.SCHEMA_NOT_EMPTY; import static io.trino.spi.connector.RetryMode.NO_RETRIES; import static io.trino.spi.connector.SampleType.SYSTEM; @@ -244,6 +245,9 @@ public synchronized MemoryOutputTableHandle beginCreateTable(ConnectorSession se ImmutableList.Builder columns = ImmutableList.builder(); for (int i = 0; i < tableMetadata.getColumns().size(); i++) { ColumnMetadata column = tableMetadata.getColumns().get(i); + if (column.getComment() != null) { + throw new TrinoException(NOT_SUPPORTED, "This connector does not support creating tables with column comment"); + } columns.add(new ColumnInfo(new MemoryColumnHandle(i), column.getName(), column.getType())); } diff --git a/plugin/trino-memory/src/test/java/io/trino/plugin/memory/TestMemoryConnectorTest.java b/plugin/trino-memory/src/test/java/io/trino/plugin/memory/TestMemoryConnectorTest.java index 9fef9673f399..99c383176324 100644 --- a/plugin/trino-memory/src/test/java/io/trino/plugin/memory/TestMemoryConnectorTest.java +++ b/plugin/trino-memory/src/test/java/io/trino/plugin/memory/TestMemoryConnectorTest.java @@ -97,6 +97,7 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) case SUPPORTS_RENAME_COLUMN: return false; + case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: case SUPPORTS_COMMENT_ON_TABLE: case SUPPORTS_COMMENT_ON_COLUMN: return false; diff --git a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/BaseMongoConnectorTest.java b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/BaseMongoConnectorTest.java index 02458d39809c..d3bccd2e651a 100644 --- a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/BaseMongoConnectorTest.java +++ b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/BaseMongoConnectorTest.java @@ -135,18 +135,6 @@ public Object[][] guessFieldTypesProvider() }; } - @Test - public void testCreateTableWithColumnComment() - { - // TODO (https://github.com/trinodb/trino/issues/11162) Merge into io.trino.testing.BaseConnectorTest#testCommentColumn - try (TestTable table = new TestTable(getQueryRunner()::execute, "test_column_comment", "(col integer COMMENT 'test')")) { - assertThat((String) computeScalar("SHOW CREATE TABLE " + table.getName())) - .isEqualTo(format("CREATE TABLE %s.%s.%s (\n" + - " col integer COMMENT 'test'\n" + - ")", getSession().getCatalog().orElseThrow(), getSession().getSchema().orElseThrow(), table.getName())); - } - } - @Test public void createTableWithEveryType() { diff --git a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java index 4e8cf3945f63..75d60a392722 100644 --- a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java +++ b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java @@ -63,6 +63,9 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) case SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM: return false; + case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: + return false; + case SUPPORTS_COMMENT_ON_COLUMN: case SUPPORTS_ADD_COLUMN_WITH_COMMENT: return false; diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java index bd05d8562c92..4da53d54fb17 100644 --- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java +++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java @@ -64,6 +64,9 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) case SUPPORTS_COMMENT_ON_TABLE: return false; + case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: + return false; + case SUPPORTS_ADD_COLUMN_WITH_COMMENT: return false; diff --git a/plugin/trino-phoenix/src/main/java/io/trino/plugin/phoenix/PhoenixClient.java b/plugin/trino-phoenix/src/main/java/io/trino/plugin/phoenix/PhoenixClient.java index be6abb7b03e0..bf00b34782a0 100644 --- a/plugin/trino-phoenix/src/main/java/io/trino/plugin/phoenix/PhoenixClient.java +++ b/plugin/trino-phoenix/src/main/java/io/trino/plugin/phoenix/PhoenixClient.java @@ -604,6 +604,9 @@ public JdbcOutputTableHandle beginCreateTable(ConnectorSession session, Connecto rowkeyColumn = Optional.of(ROWKEY); } for (ColumnMetadata column : tableColumns) { + if (column.getComment() != null) { + throw new TrinoException(NOT_SUPPORTED, "This connector does not support creating tables with column comment"); + } String columnName = getIdentifierMapping().toRemoteColumnName(connection, column.getName()); columnNames.add(columnName); columnTypes.add(column.getType()); diff --git a/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConnectorTest.java b/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConnectorTest.java index a1080c6ea985..79050b271d99 100644 --- a/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConnectorTest.java +++ b/plugin/trino-phoenix/src/test/java/io/trino/plugin/phoenix/TestPhoenixConnectorTest.java @@ -71,6 +71,9 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) case SUPPORTS_AGGREGATION_PUSHDOWN: return false; + case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: + return false; + case SUPPORTS_COMMENT_ON_TABLE: case SUPPORTS_COMMENT_ON_COLUMN: case SUPPORTS_ADD_COLUMN_WITH_COMMENT: diff --git a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java index a0f861e870f8..dab7457c52c7 100644 --- a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java +++ b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java @@ -596,6 +596,9 @@ public JdbcOutputTableHandle beginCreateTable(ConnectorSession session, Connecto rowkeyColumn = Optional.of(ROWKEY); } for (ColumnMetadata column : tableColumns) { + if (column.getComment() != null) { + throw new TrinoException(NOT_SUPPORTED, "This connector does not support creating tables with column comment"); + } String columnName = getIdentifierMapping().toRemoteColumnName(connection, column.getName()); columnNames.add(columnName); columnTypes.add(column.getType()); diff --git a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java index 715c2d1ab2e7..18e34d9d2a7e 100644 --- a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java +++ b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java @@ -89,6 +89,9 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) case SUPPORTS_AGGREGATION_PUSHDOWN: return false; + case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: + return false; + case SUPPORTS_COMMENT_ON_TABLE: case SUPPORTS_COMMENT_ON_COLUMN: case SUPPORTS_ADD_COLUMN_WITH_COMMENT: 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 b61f2bcfa551..64d2c004cbbf 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 @@ -118,6 +118,9 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) case SUPPORTS_JOIN_PUSHDOWN: return true; + case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: + return false; + case SUPPORTS_COMMENT_ON_TABLE: case SUPPORTS_ADD_COLUMN_WITH_COMMENT: return false; diff --git a/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/RaptorMetadata.java b/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/RaptorMetadata.java index b074e38d0016..8ce1c80b1480 100644 --- a/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/RaptorMetadata.java +++ b/plugin/trino-raptor-legacy/src/main/java/io/trino/plugin/raptor/legacy/RaptorMetadata.java @@ -565,6 +565,9 @@ public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, Con long columnId = 1; for (ColumnMetadata column : tableMetadata.getColumns()) { + if (column.getComment() != null) { + throw new TrinoException(NOT_SUPPORTED, "This connector does not support creating tables with column comment"); + } columnHandles.add(new RaptorColumnHandle(column.getName(), columnId, column.getType())); columnTypes.add(column.getType()); columnId++; diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/BaseRaptorConnectorTest.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/BaseRaptorConnectorTest.java index 321fccc3b36f..badeeecb8ffa 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/BaseRaptorConnectorTest.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/BaseRaptorConnectorTest.java @@ -73,6 +73,7 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) return true; case SUPPORTS_CREATE_SCHEMA: case SUPPORTS_RENAME_SCHEMA: + case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: case SUPPORTS_COMMENT_ON_TABLE: case SUPPORTS_COMMENT_ON_COLUMN: case SUPPORTS_ADD_COLUMN_WITH_COMMENT: diff --git a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java index ed01249d589f..83e60625ac2a 100644 --- a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java +++ b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java @@ -79,6 +79,9 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) case SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM: return false; + case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: + return false; + case SUPPORTS_COMMENT_ON_TABLE: case SUPPORTS_COMMENT_ON_COLUMN: case SUPPORTS_ADD_COLUMN_WITH_COMMENT: diff --git a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java index 24d9a6a31af0..f827190d6c4b 100644 --- a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java +++ b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java @@ -71,6 +71,7 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) case SUPPORTS_JOIN_PUSHDOWN_WITH_DISTINCT_FROM: return false; + case SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT: case SUPPORTS_COMMENT_ON_TABLE: case SUPPORTS_COMMENT_ON_COLUMN: return false; diff --git a/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java b/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java index 5f1f130344b8..ae27b4cab8a8 100644 --- a/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java +++ b/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java @@ -82,6 +82,7 @@ import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_CREATE_MATERIALIZED_VIEW; import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_CREATE_SCHEMA; import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_CREATE_TABLE; +import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT; import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_CREATE_TABLE_WITH_DATA; import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_CREATE_VIEW; import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_DELETE; @@ -1891,6 +1892,23 @@ public void testCreateTable() assertFalse(getQueryRunner().tableExists(getSession(), tableNameLike)); } + @Test + public void testCreateTableWithColumnComment() + { + skipTestUnless(hasBehavior(SUPPORTS_CREATE_TABLE)); + + String tableName = "test_create_" + randomTableSuffix(); + if (!hasBehavior(SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT)) { + assertQueryFails("CREATE TABLE " + tableName + " (a bigint COMMENT 'test comment')", "This connector does not support creating tables with column comment"); + return; + } + + assertUpdate("CREATE TABLE " + tableName + " (a bigint COMMENT 'test comment')"); + assertEquals(getColumnComment(tableName, "a"), "test comment"); + + assertUpdate("DROP TABLE " + tableName); + } + @Test public void testCreateTableSchemaNotFound() { diff --git a/testing/trino-testing/src/main/java/io/trino/testing/TestingConnectorBehavior.java b/testing/trino-testing/src/main/java/io/trino/testing/TestingConnectorBehavior.java index 0863433cc245..aed2e5de0440 100644 --- a/testing/trino-testing/src/main/java/io/trino/testing/TestingConnectorBehavior.java +++ b/testing/trino-testing/src/main/java/io/trino/testing/TestingConnectorBehavior.java @@ -54,6 +54,7 @@ public enum TestingConnectorBehavior SUPPORTS_CREATE_TABLE, SUPPORTS_CREATE_TABLE_WITH_DATA(SUPPORTS_CREATE_TABLE), + SUPPORTS_CREATE_TABLE_WITH_COLUMN_COMMENT(SUPPORTS_CREATE_TABLE), SUPPORTS_RENAME_TABLE, SUPPORTS_RENAME_TABLE_ACROSS_SCHEMAS(SUPPORTS_RENAME_TABLE),