jackye1995 commented on a change in pull request #3593:
URL: https://github.com/apache/iceberg/pull/3593#discussion_r754716535



##########
File path: core/src/main/java/org/apache/iceberg/io/ResolvingFileIO.java
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.io;
+
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.iceberg.CatalogUtil;
+import org.apache.iceberg.hadoop.HadoopConfigurable;
+import org.apache.iceberg.hadoop.SerializableConfiguration;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.iceberg.util.SerializableSupplier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * FileIO implementation that uses location scheme to choose the correct 
FileIO implementation.
+ */
+public class ResolvingFileIO implements FileIO, HadoopConfigurable {
+  private static final Logger LOG = 
LoggerFactory.getLogger(ResolvingFileIO.class);
+  private static final String DEFAULT_SCHEME = "fs";
+  private static final String FALLBACK_IMPL = 
"org.apache.iceberg.hadoop.HadoopFileIO";
+  private static final Map<String, String> SCHEME_TO_FILE_IO = ImmutableMap.of(
+      DEFAULT_SCHEME, FALLBACK_IMPL,

Review comment:
       Regarding to point 1, when I thought about the process we use to 
initialize a catalog, we are only specifying 1 single FileIO for the catalog to 
use, so I would expect something like the following:
   
   ```
   spark-sql --packages org.apache.iceberg:iceberg-spark3-runtime:0.12.1\
       --conf 
spark.sql.catalog.spark_catalog=org.apache.iceberg.spark.SparkSessionCatalog \
       --conf spark.sql.catalog.spark_catalog.type=hive \
       --conf 
spark.sql.catalog.spark_catalog.io-impl=org.apache.iceberg.aws.s3.S3FileIO
   ```
   
   So at that point it makes more sense to only check the schemes supported by 
that FileIO and fallback if not found.
   
   In the end I was expecting this to be extended to something like:
   
   ```
   spark-sql --packages org.apache.iceberg:iceberg-spark3-runtime:0.12.1\
       --conf 
spark.sql.catalog.spark_catalog=org.apache.iceberg.spark.SparkSessionCatalog \
       --conf spark.sql.catalog.spark_catalog.type=hive \
       --conf 
spark.sql.catalog.spark_catalog.io-impl=org.apache.iceberg.hadoop.HadoopFileIO 
// default
       --conf 
spark.sql.catalog.spark_catalog.io-impl.s3=org.apache.iceberg.aws.s3.S3FileIO
       --conf 
spark.sql.catalog.spark_catalog.io-impl.s3a=org.apache.iceberg.aws.s3.S3FileIO
   ```
   
   Was there any particular reason for us to scan all the available FileIO 
implementations?




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