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


##########
core/src/main/java/org/apache/iceberg/view/ViewMetadata.java:
##########
@@ -510,5 +529,29 @@ static List<ViewHistoryEntry> 
updateHistory(List<ViewHistoryEntry> history, Set<
     private <U extends MetadataUpdate> Stream<U> changes(Class<U> updateClass) 
{
       return 
changes.stream().filter(updateClass::isInstance).map(updateClass::cast);
     }
+
+    private void checkIfDialectIsDropped(ViewVersion previous, ViewVersion 
current) {
+      Set<String> baseDialects = sqlDialectsFor(previous);
+      Set<String> updatedDialects = sqlDialectsFor(current);
+
+      Preconditions.checkState(
+          updatedDialects.containsAll(baseDialects),
+          "Cannot replace view due to loss of view dialects 
(%s=false):\nPrevious dialects: %s\nNew dialects: %s",
+          ViewProperties.REPLACE_DROP_DIALECT_ALLOWED,
+          baseDialects,
+          updatedDialects);
+    }
+
+    private Set<String> sqlDialectsFor(ViewVersion viewVersion) {
+      Set<String> dialects = Sets.newHashSet();
+      for (ViewRepresentation repr : viewVersion.representations()) {
+        if (repr instanceof SQLViewRepresentation) {
+          SQLViewRepresentation sql = (SQLViewRepresentation) repr;
+          dialects.add(sql.dialect());

Review Comment:
   When detecting whether we have multiple dialects in 
https://github.com/apache/iceberg/blob/d2be90d9cf087b7f644350dd251071e15ff71a11/core/src/main/java/org/apache/iceberg/view/ViewMetadata.java#L295
 we use the dialect as-is, hence I'm doing the same here.
   I think we should be ok not doing a `toLowerCase()` in both of these cases 
as typically an engine would add & read a dialect using the same casing



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