dimas-b commented on code in PR #8909:
URL: https://github.com/apache/iceberg/pull/8909#discussion_r1422637569


##########
nessie/src/main/java/org/apache/iceberg/nessie/NessieCatalog.java:
##########
@@ -347,4 +339,65 @@ private TableIdentifier identifierWithoutTableReference(
   protected Map<String, String> properties() {
     return catalogOptions;
   }
+
+  @Override
+  protected ViewOperations newViewOps(TableIdentifier identifier) {
+    TableReference tr = parseTableReference(identifier);
+    return new NessieViewOperations(
+        ContentKey.of(
+            
org.projectnessie.model.Namespace.of(identifier.namespace().levels()), 
tr.getName()),
+        client.withReference(tr.getReference(), tr.getHash()),
+        fileIO);
+  }
+
+  @Override
+  public List<TableIdentifier> listViews(Namespace namespace) {
+    return client.listViews(namespace);
+  }
+
+  @Override
+  public boolean dropView(TableIdentifier identifier) {
+    TableReference tableReference = parseTableReference(identifier);
+    return client
+        .withReference(tableReference.getReference(), tableReference.getHash())
+        .dropView(identifierWithoutTableReference(identifier, tableReference), 
false);
+  }
+
+  @Override
+  public void renameView(TableIdentifier from, TableIdentifier to) {
+    TableReference fromTableReference = parseTableReference(from);
+    TableReference toTableReference = parseTableReference(to);
+
+    validateReferenceForRename(fromTableReference, toTableReference, 
Content.Type.ICEBERG_VIEW);
+
+    TableIdentifier fromIdentifier =
+        NessieUtil.removeCatalogName(
+            identifierWithoutTableReference(from, fromTableReference), name());
+    TableIdentifier toIdentifier =
+        NessieUtil.removeCatalogName(identifierWithoutTableReference(to, 
toTableReference), name());
+    client
+        .withReference(fromTableReference.getReference(), 
fromTableReference.getHash())
+        .renameView(fromIdentifier, toIdentifier);
+  }
+
+  private void validateReferenceForRename(
+      TableReference fromTableReference, TableReference toTableReference, 
Content.Type type) {
+    String fromReference =
+        fromTableReference.hasReference()
+            ? fromTableReference.getReference()
+            : client.getRef().getName();
+    String toReference =
+        toTableReference.hasReference()
+            ? toTableReference.getReference()
+            : client.getRef().getName();
+    Preconditions.checkArgument(
+        fromReference.equalsIgnoreCase(toReference),
+        "Cannot rename %s '%s' on reference '%s' to '%s' on reference '%s':"
+            + " source and target references must be the same.",
+        NessieUtil.contentTypeString(type).toLowerCase(),

Review Comment:
   I did a quick scan of the Iceberg codebase for this, and I do a few places 
where `.toLowerCase()` may be a concern:
   
   1) `TableIdentifier.toLoweCase()` is used only in `CachingCatalog` 
internally, which is probably ok, since the lower case strings are not exposed 
to the outside.
   
   2) 
[VectorizedSupport](https://github.com/apache/iceberg/blob/c07f2aabc0a1d02f068ecf1514d2479c0fbdd3b0/mr/src/main/java/org/apache/hadoop/hive/ql/exec/vector/VectorizedSupport.java#L33)
 seems like it may be a problem, but I do not really know whether the lower 
case data is exposed and how.
   
   3) 
[IcebergRecordObjectInspector](https://github.com/apache/iceberg/blob/c07f2aabc0a1d02f068ecf1514d2479c0fbdd3b0/mr/src/main/java/org/apache/iceberg/mr/hive/serde/objectinspector/IcebergRecordObjectInspector.java#L55)
 converts field names to lower case, and that seems to be affected by the 
locale problem as various case names are accepted as input parameters to its 
methods.
   
   4) `jQuery` code uses a log of `toLowerCase()`, but I do not really know how 
it is supposed to be used.
   
   @nastra : Do you think this is worth opening an issue? To the best of my 
knowledge this kind of case conversion can be problematic only in German and 
Turkish locales. The German locale affects only proper German language words 
(so it is less of a problem), but the Turkish locale can cause English words to 
be converted in unexpected ways. Does Iceberg support using its libraries in 
user-defined locales?



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