rdblue commented on code in PR #4465:
URL: https://github.com/apache/iceberg/pull/4465#discussion_r841278063


##########
azure/src/main/java/org/apache/iceberg/azure/blob/AzureURI.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.azure.blob;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.apache.iceberg.exceptions.ValidationException;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class represents an immutable fully qualified location in Azure Blob 
Storage for input/output operations
+ * expressed as URI. This implementation is provided to ensure compatibility 
with Hadoop Path implementations.
+ */
+public class AzureURI {
+
+  private static final Logger LOG = LoggerFactory.getLogger(AzureURI.class);
+  private static final String AUTHORITY_DELIMITER = "@";
+  private static final String ENDPOINT_DELIMITER = "\\.";
+  private static final String PATH_DELIMITER = "/";
+  private static final String ABFS_SCHEME = "abfs";
+  private static final String EXPECTED_URI_FORM = String.format(
+      "%s://[<container name>%s]<account name>.dfs.core.windows.net/<file 
path>",
+      ABFS_SCHEME,
+      AUTHORITY_DELIMITER);
+  private static final String INVALID_URI_MESSAGE = "Invalid Azure URI. 
Expected form is '%s': %s.";
+
+  private final String location;
+  private final String container;
+  private final String storageAccount;
+  private final String path;
+
+  private AzureURI(String location) {
+    Preconditions.checkNotNull(location, "Location cannot be null.");
+    final URI uri;
+    try {
+      uri = new URI(location);
+    } catch (URISyntaxException e) {
+      throw new ValidationException("Invalid Azure URI: %s.", location);
+    }
+    this.location = location;
+
+    ValidationException.check(

Review Comment:
   `ValidationException` is not a substitute for `IllegalArgumentException`. 
`ValidationException` indicates that while an argument may be valid, it is 
inconsistent with other arguments or config.
   
   For example, when creating a partition spec, `"column"` is a valid column 
reference, but `null` would result in an `IllegalArgumentException`. But, if 
`"column"` is not a defined name in the schema then a `ValidationException` is 
thrown because you can't partition by an unknown column.



-- 
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: dev-unsubscr...@iceberg.apache.org

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

Reply via email to