garyli1019 commented on a change in pull request #2242:
URL: https://github.com/apache/hudi/pull/2242#discussion_r529169090



##########
File path: 
hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/selector/AbstractDFSPathSelector.java
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.hudi.utilities.sources.selector;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hudi.ApiMaturityLevel;
+import org.apache.hudi.PublicAPIClass;
+import org.apache.hudi.common.config.TypedProperties;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.collection.Pair;
+import org.apache.hudi.utilities.config.HoodieDeltaStreamerConfig;
+
+@PublicAPIClass(maturity = ApiMaturityLevel.STABLE)
+public abstract class AbstractDFSPathSelector {

Review comment:
       Do you think we can make this simpler? I feel like making an Abstract 
class here was a bit overkill. 

##########
File path: 
hudi-utilities/src/main/java/org/apache/hudi/utilities/UtilHelpers.java
##########
@@ -152,8 +156,26 @@ public static InitialCheckPointProvider 
createInitialCheckpointProvider(
   }
 
   /**
-   *
+   * Factory method for creating custom DFSPathSelector.
    */
+  public static AbstractDFSPathSelector createSourceSelector(TypedProperties 
props, Configuration conf) {

Review comment:
       IMO we could keep this method inside the path related class if possible, 
so the code would be more straightforward. 

##########
File path: 
hudi-utilities/src/main/java/org/apache/hudi/utilities/UtilHelpers.java
##########
@@ -152,8 +156,26 @@ public static InitialCheckPointProvider 
createInitialCheckpointProvider(
   }
 
   /**
-   *
+   * Factory method for creating custom DFSPathSelector.
    */
+  public static AbstractDFSPathSelector createSourceSelector(TypedProperties 
props, Configuration conf) {
+
+    HoodieDeltaStreamerConfig deltaStreamerConfig = new 
HoodieDeltaStreamerConfig(props);
+    String sourceSelectorClass;
+    if (deltaStreamerConfig.getFullOverwrite()) {
+      sourceSelectorClass = OverwriteDFSPathSelector.class.getName();
+    } else {
+      sourceSelectorClass = deltaStreamerConfig.getInputSelector();

Review comment:
       Can we load the overwrite method through here?

##########
File path: 
hudi-utilities/src/main/java/org/apache/hudi/utilities/deltastreamer/HoodieDeltaStreamer.java
##########
@@ -522,14 +523,18 @@ public static void main(String[] args) throws Exception {
      */
     private transient DeltaSync deltaSync;
 
+    private final HoodieDeltaStreamerConfig deltaStreamerConfig;
+
     public DeltaSyncService(Config cfg, JavaSparkContext jssc, FileSystem fs, 
Configuration conf,
                             Option<TypedProperties> properties) throws 
IOException {
+      this.props = properties.get();
       this.cfg = cfg;
       this.jssc = jssc;
       this.sparkSession = 
SparkSession.builder().config(jssc.getConf()).getOrCreate();
       this.asyncCompactService = Option.empty();
+      this.deltaStreamerConfig = new HoodieDeltaStreamerConfig(props);
 
-      if (fs.exists(new Path(cfg.targetBasePath))) {
+      if (fs.exists(new Path(cfg.targetBasePath)) && 
!deltaStreamerConfig.getFullOverwrite()) {

Review comment:
       If a user would like to use overwrite through the command-line tool, is 
there any way to do that?




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

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


Reply via email to