|
19 | 19 | import io.trino.execution.warnings.WarningCollector;
|
20 | 20 | import io.trino.metadata.QualifiedObjectName;
|
21 | 21 | import io.trino.metadata.TableHandle;
|
| 22 | +import io.trino.metadata.ViewColumn; |
22 | 23 | import io.trino.security.AllowAllAccessControl;
|
23 | 24 | import io.trino.spi.connector.ConnectorTableMetadata;
|
24 | 25 | import io.trino.sql.tree.Comment;
|
|
33 | 34 | import static io.trino.spi.StandardErrorCode.COLUMN_NOT_FOUND;
|
34 | 35 | import static io.trino.spi.StandardErrorCode.TABLE_NOT_FOUND;
|
35 | 36 | import static io.trino.spi.connector.SaveMode.FAIL;
|
| 37 | +import static io.trino.spi.type.BigintType.BIGINT; |
36 | 38 | import static io.trino.sql.tree.Comment.Type.COLUMN;
|
37 | 39 | import static io.trino.sql.tree.Comment.Type.TABLE;
|
38 | 40 | import static io.trino.sql.tree.Comment.Type.VIEW;
|
@@ -143,6 +145,24 @@ public void testCommentViewColumn()
|
143 | 145 | .hasMessageContaining("Column does not exist: %s", missingColumnName.getSuffix());
|
144 | 146 | }
|
145 | 147 |
|
| 148 | + @Test |
| 149 | + public void testCommentOnMixedCaseViewColumn() |
| 150 | + { |
| 151 | + QualifiedObjectName viewName = qualifiedObjectName("existing_view"); |
| 152 | + metadata.createView(testSession, viewName, viewDefinition("SELECT 1", ImmutableList.of(new ViewColumn("Mixed", BIGINT.getTypeId(), Optional.empty()))), ImmutableMap.of(), false); |
| 153 | + assertThat(metadata.isView(testSession, viewName)).isTrue(); |
| 154 | + |
| 155 | + QualifiedName columnNameLowerCase = qualifiedColumnName("existing_view", "mixed"); |
| 156 | + getFutureValue(setComment(COLUMN, columnNameLowerCase, Optional.of("new mixed column comment"))); |
| 157 | + assertThat(metadata.getView(testSession, viewName).get().getColumns().stream().filter(column -> "Mixed".equals(column.name())).collect(onlyElement()).comment()) |
| 158 | + .isEqualTo(Optional.of("new mixed column comment")); |
| 159 | + |
| 160 | + QualifiedName columnNameMixedCase = qualifiedColumnName("existing_view", "Mixed"); |
| 161 | + getFutureValue(setComment(COLUMN, columnNameMixedCase, Optional.of("new Mixed column comment"))); |
| 162 | + assertThat(metadata.getView(testSession, viewName).get().getColumns().stream().filter(column -> "Mixed".equals(column.name())).collect(onlyElement()).comment()) |
| 163 | + .isEqualTo(Optional.of("new Mixed column comment")); |
| 164 | + } |
| 165 | + |
146 | 166 | @Test
|
147 | 167 | public void testCommentMaterializedViewColumn()
|
148 | 168 | {
|
|
0 commit comments