nastra commented on code in PR #9620:
URL: https://github.com/apache/iceberg/pull/9620#discussion_r1490495749


##########
core/src/test/java/org/apache/iceberg/view/TestViewMetadata.java:
##########
@@ -799,4 +802,299 @@ public void lastAddedSchemaFailure() {
         .isInstanceOf(ValidationException.class)
         .hasMessage("Cannot set last added schema: no schema has been added");
   }
+
+  @Test
+  public void droppingDialectFailsByDefault() {
+    Schema schema = new Schema(Types.NestedField.required(1, "x", 
Types.LongType.get()));
+    ViewRepresentation spark =
+        ImmutableSQLViewRepresentation.builder().dialect("spark").sql("select 
* from tbl").build();
+    ViewRepresentation trino =
+        ImmutableSQLViewRepresentation.builder().dialect("trino").sql("select 
* from tbl").build();
+
+    ViewMetadata metadata =
+        ViewMetadata.builder()
+            .setLocation("custom-location")
+            .addSchema(schema)
+            .setCurrentVersion(
+                ImmutableViewVersion.builder()
+                    .versionId(1)
+                    .schemaId(0)
+                    .timestampMillis(System.currentTimeMillis())
+                    .defaultNamespace(Namespace.empty())
+                    .addRepresentations(spark)
+                    .build(),
+                schema)
+            .build();
+
+    assertThatThrownBy(
+            () ->
+                ViewMetadata.buildFrom(metadata)
+                    .setCurrentVersion(
+                        ImmutableViewVersion.builder()
+                            .versionId(1)
+                            .schemaId(0)
+                            .timestampMillis(System.currentTimeMillis())
+                            .defaultNamespace(Namespace.empty())
+                            .addRepresentations(trino)
+                            .build(),
+                        schema)
+                    .build())
+        .isInstanceOf(IllegalStateException.class)
+        .hasMessage(
+            "Cannot replace view due to loss of view dialects 
(replace.drop-dialect.allowed=false):\n"
+                + "Previous dialects: [spark]\n"
+                + "New dialects: [trino]");
+  }
+
+  @Test
+  public void droppingDialectDoesNotFailWhenAllowed() {
+    Schema schema = new Schema(Types.NestedField.required(1, "x", 
Types.LongType.get()));
+    ViewRepresentation spark =
+        ImmutableSQLViewRepresentation.builder().dialect("spark").sql("select 
* from tbl").build();
+    ViewRepresentation trino =
+        ImmutableSQLViewRepresentation.builder().dialect("trino").sql("select 
* from tbl").build();
+
+    ViewMetadata metadata =
+        ViewMetadata.builder()
+            .setLocation("custom-location")

Review Comment:
   `location` is a required field, thus it has to be set



-- 
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