deniskuzZ commented on code in PR #6655:
URL: https://github.com/apache/hive/pull/6655#discussion_r3782897484


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/vended/VendedCredentialSupport.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * 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.mr.hive.vended;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.aws.AwsClientProperties;
+import org.apache.iceberg.aws.s3.S3FileIOProperties;
+import org.apache.iceberg.io.FileIO;
+import org.apache.iceberg.io.StorageCredential;
+
+/** Public helpers for {@link 
org.apache.iceberg.mr.hive.IcebergVendedCredentialUtil}. */
+public final class VendedCredentialSupport {
+
+  private VendedCredentialSupport() {
+  }
+
+  public static String storagePrefixFromLocation(String location) {
+    return VendedCredentialPrefixUtil.storagePrefixFromLocation(location);
+  }
+
+  public static String scopeFromPrefix(String prefix) {
+    return VendedCredentialPrefixUtil.scopeFromPrefix(prefix);
+  }
+
+  public static VendedCredentialHadoopMapper mapperFor(StorageCredential 
credential) {
+    return VendedCredentialHadoopMappers.forCredential(credential);
+  }
+
+  public static String toHadoopProperty(
+      VendedCredentialHadoopMapper mapper, String scope, String icebergKey) {
+    if (mapper == null || scope == null) {
+      return null;
+    }
+    return mapper.toHadoopProperty(scope, icebergKey);
+  }
+
+  public static Map<String, String> additionalNonSecretHadoopProperties(
+      VendedCredentialHadoopMapper mapper, String scope, Map<String, String> 
config) {
+    if (mapper == null) {
+      return Map.of();
+    }
+    return mapper.additionalNonSecretHadoopProperties(scope, config);
+  }
+
+  public static List<StorageCredential> credentialsFromFileIoProperties(Table 
table, FileIO io) {

Review Comment:
   can we refactor to
   ````
   expose in HadoopMappers:
   
   static List<StorageCredential> credentialsFromProperties(
       String prefix, Map<String, String> properties) {
     for (HadoopMapper mapper : MAPPERS) {
       List<StorageCredential> credentials =
           mapper.credentialsFromProperties(prefix, properties);
       if (!credentials.isEmpty()) {
         return credentials;
       }
     }
     return List.of();
   }
   
   and then 
   
   public static List<StorageCredential> credentialsFromFileIoProperties(
       Table table, FileIO io) {
     Map<String, String> props = io.properties();
     if (props == null || props.isEmpty()) {
       return List.of();
     }
   
     return HadoopMappers.credentialsFromProperties(
         storagePrefixFromLocation(table.location()), props);
   }
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to