tomtongue commented on code in PR #12544:
URL: https://github.com/apache/iceberg/pull/12544#discussion_r2052002017


##########
aws/src/test/java/org/apache/iceberg/aws/glue/TestGlueCatalog.java:
##########
@@ -679,4 +680,140 @@ public void testTableLevelS3TagProperties() {
                 S3FileIOProperties.S3_TAG_ICEBERG_NAMESPACE),
             "db");
   }
+
+  @Test
+  public void testDropView() {
+    TableIdentifier viewIdent = TableIdentifier.of("db", "drop_view");
+    Table glueView =
+        Table.builder()
+            .databaseName("db")
+            .name("drop_view")
+            .tableType("VIRTUAL_VIEW")
+            .parameters(
+                ImmutableMap.of(
+                    "table_type", "iceberg-view", "metadata_location", 
"s3://xx/metadata.json"))
+            .build();
+
+    Mockito.doReturn(GetTableResponse.builder().table(glueView).build())
+        .when(glue)
+        .getTable(Mockito.any(GetTableRequest.class));
+    Mockito.doReturn(DeleteTableResponse.builder().build())
+        .when(glue)
+        .deleteTable(Mockito.any(DeleteTableRequest.class));
+
+    boolean dropped = glueCatalog.dropView(viewIdent);
+    assertThat(dropped).isTrue();
+
+    Mockito.verify(glue, Mockito.times(1))
+        .deleteTable(
+            Mockito.argThat(
+                (DeleteTableRequest r) ->
+                    r.databaseName().equals("db") && 
r.name().equals("drop_view")));
+  }
+
+  @Test
+  public void testDropViewNotFound() {
+    TableIdentifier viewIdent = TableIdentifier.of("db", "no_view");
+    Mockito.doThrow(EntityNotFoundException.builder().build())
+        .when(glue)
+        .getTable(Mockito.any(GetTableRequest.class));
+
+    boolean result = glueCatalog.dropView(viewIdent);
+    assertThat(result).isFalse();
+  }
+
+  @Test
+  public void testDropViewButItsNotView() {
+    TableIdentifier viewIdent = TableIdentifier.of("db", "not_view");
+    Table glueTable =
+        Table.builder()
+            .databaseName("db")
+            .name("not_view")
+            .tableType("EXTERNAL_TABLE")
+            .parameters(ImmutableMap.of("table_type", "iceberg-table")) // not 
"iceberg-view"
+            .build();
+
+    Mockito.doReturn(GetTableResponse.builder().table(glueTable).build())
+        .when(glue)
+        .getTable(Mockito.any(GetTableRequest.class));
+
+    boolean dropped = glueCatalog.dropView(viewIdent);
+    assertThat(dropped).isFalse();
+  }
+
+  @Test
+  public void testListViews() {
+    Mockito.doReturn(
+            GetTablesResponse.builder()
+                .tableList(
+                    Table.builder()
+                        .databaseName("db")
+                        .name("my_view")
+                        .tableType("VIRTUAL_VIEW")
+                        .parameters(
+                            ImmutableMap.of(
+                                "table_type",
+                                "iceberg-view",
+                                "metadata_location",
+                                "s3://v1/metadata.json"))
+                        .build(),
+                    Table.builder()
+                        .databaseName("db")
+                        .name("my_table")
+                        .tableType("EXTERNAL_TABLE")
+                        .parameters(ImmutableMap.of("table_type", 
"iceberg-table"))
+                        .build())
+                .build())
+        .when(glue)
+        .getTables(Mockito.any(GetTablesRequest.class));
+
+    List<TableIdentifier> views = glueCatalog.listViews(Namespace.of("db"));
+    assertThat(views).hasSize(1);
+    assertThat(views.get(0)).isEqualTo(TableIdentifier.of("db", "my_view"));

Review Comment:
   ```suggestion
       assertThat(views)
           .hasSize(1)
           .containsExactly(TableIdentifier.of("db", "my_view"));
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to