[ 
https://issues.apache.org/jira/browse/HUDI-2268?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17399211#comment-17399211
 ] 

ASF GitHub Bot commented on HUDI-2268:
--------------------------------------

yihua commented on a change in pull request #3470:
URL: https://github.com/apache/hudi/pull/3470#discussion_r688960995



##########
File path: 
hudi-common/src/main/java/org/apache/hudi/common/util/MarkerUtils.java
##########
@@ -216,4 +216,4 @@ public static void deleteMarkerTypeFile(FileSystem 
fileSystem, String markerDir)
       throw new HoodieIOException(ioe.getMessage(), ioe);
     }
   }
-}
+}

Review comment:
       Yes.  I made a pass of all filters we use and properly adjusted them.

##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/BaseOneToZeroDowngradeHandler.java
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.table.upgrade;
+
+import org.apache.hudi.common.config.ConfigProperty;
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.table.HoodieTable;
+import org.apache.hudi.table.marker.WriteMarkers;
+import org.apache.hudi.table.marker.WriteMarkersFactory;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public abstract class BaseOneToZeroDowngradeHandler implements 
DowngradeHandler {
+
+  @Override
+  public Map<ConfigProperty, String> downgrade(HoodieWriteConfig config, 
HoodieEngineContext context, String instantTime) {
+    // fetch pending commit info
+    HoodieTable table = getTable(config, context);
+    HoodieTimeline inflightTimeline = 
table.getMetaClient().getCommitsTimeline().filterPendingExcludingCompaction();
+    List<HoodieInstant> commits = 
inflightTimeline.getReverseOrderedInstants().collect(Collectors.toList());
+    for (HoodieInstant commitInstant : commits) {
+      // delete existing markers
+      WriteMarkers writeMarkers = 
WriteMarkersFactory.get(config.getMarkersType(), table, 
commitInstant.getTimestamp());
+      writeMarkers.quietDeleteMarkerDir(context, 
config.getMarkersDeleteParallelism());
+    }
+    return Collections.EMPTY_MAP;

Review comment:
       Yes, this means no additional property should be added.

##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/BaseTwoToOneDowngradeHandler.java
##########
@@ -0,0 +1,140 @@
+/*
+ * 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.table.upgrade;
+
+import org.apache.hudi.common.config.ConfigProperty;
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.MarkerUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.hudi.table.HoodieTable;
+import org.apache.hudi.table.marker.DirectWriteMarkers;
+
+import com.esotericsoftware.minlog.Log;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import static org.apache.hudi.common.util.MarkerUtils.MARKERS_FILENAME_PREFIX;
+
+public abstract class BaseTwoToOneDowngradeHandler implements DowngradeHandler 
{
+
+  @Override
+  public Map<ConfigProperty, String> downgrade(HoodieWriteConfig config, 
HoodieEngineContext context, String instantTime) {
+    HoodieTable table = getTable(config, context);
+    HoodieTableMetaClient metaClient = table.getMetaClient();
+
+    // re-create marker files if any partial timeline server based markers are 
found
+    HoodieTimeline inflightTimeline = 
metaClient.getCommitsTimeline().filterPendingExcludingCompaction();
+    List<HoodieInstant> commits = 
inflightTimeline.getReverseOrderedInstants().collect(Collectors.toList());
+    for (HoodieInstant commitInstant : commits) {

Review comment:
       Renamed.

##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/BaseOneToZeroDowngradeHandler.java
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.table.upgrade;
+
+import org.apache.hudi.common.config.ConfigProperty;
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.table.HoodieTable;
+import org.apache.hudi.table.marker.WriteMarkers;
+import org.apache.hudi.table.marker.WriteMarkersFactory;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public abstract class BaseOneToZeroDowngradeHandler implements 
DowngradeHandler {
+
+  @Override
+  public Map<ConfigProperty, String> downgrade(HoodieWriteConfig config, 
HoodieEngineContext context, String instantTime) {
+    // fetch pending commit info
+    HoodieTable table = getTable(config, context);
+    HoodieTimeline inflightTimeline = 
table.getMetaClient().getCommitsTimeline().filterPendingExcludingCompaction();
+    List<HoodieInstant> commits = 
inflightTimeline.getReverseOrderedInstants().collect(Collectors.toList());
+    for (HoodieInstant commitInstant : commits) {

Review comment:
       Renamed.

##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/BaseTwoToOneDowngradeHandler.java
##########
@@ -0,0 +1,140 @@
+/*
+ * 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.table.upgrade;
+
+import org.apache.hudi.common.config.ConfigProperty;
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.MarkerUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.hudi.table.HoodieTable;
+import org.apache.hudi.table.marker.DirectWriteMarkers;
+
+import com.esotericsoftware.minlog.Log;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import static org.apache.hudi.common.util.MarkerUtils.MARKERS_FILENAME_PREFIX;
+
+public abstract class BaseTwoToOneDowngradeHandler implements DowngradeHandler 
{
+
+  @Override
+  public Map<ConfigProperty, String> downgrade(HoodieWriteConfig config, 
HoodieEngineContext context, String instantTime) {
+    HoodieTable table = getTable(config, context);
+    HoodieTableMetaClient metaClient = table.getMetaClient();
+
+    // re-create marker files if any partial timeline server based markers are 
found
+    HoodieTimeline inflightTimeline = 
metaClient.getCommitsTimeline().filterPendingExcludingCompaction();
+    List<HoodieInstant> commits = 
inflightTimeline.getReverseOrderedInstants().collect(Collectors.toList());
+    for (HoodieInstant commitInstant : commits) {
+      // Converts the markers in new format to old format of direct markers
+      try {
+        convertToDirectMarkers(
+            commitInstant.getTimestamp(), table, context, 
config.getMarkersDeleteParallelism());
+      } catch (IOException e) {
+        throw new HoodieException("Converting marker files to DIRECT style 
failed during downgrade", e);
+      }
+    }
+    return Collections.EMPTY_MAP;
+  }
+
+  abstract HoodieTable getTable(HoodieWriteConfig config, HoodieEngineContext 
context);
+
+  /**
+   * Converts the markers in new format(timeline server based) to old format 
of direct markers,
+   * i.e., one marker file per data file, without MARKERS.type file.
+   * This needs to be idempotent.
+   * 1. read all markers from timeline server based marker files
+   * 2. create direct style markers
+   * 3. delete marker type file
+   * 4. delete timeline server based marker files
+   *
+   * @param commitInstantTime instant of interest for marker conversion.
+   * @param table             instance of {@link HoodieTable} to use
+   * @param context           instance of {@link HoodieEngineContext} to use
+   * @param parallelism       parallelism to use
+   */
+  private void convertToDirectMarkers(final String commitInstantTime,
+                                      HoodieTable table,
+                                      HoodieEngineContext context,
+                                      int parallelism) throws IOException {
+    String markerDir = 
table.getMetaClient().getMarkerFolderPath(commitInstantTime);
+    FileSystem fileSystem = FSUtils.getFs(markerDir, 
context.getHadoopConf().newCopy());
+    Option<MarkerType> markerTypeOption = 
MarkerUtils.readMarkerType(fileSystem, markerDir);
+    if (markerTypeOption.isPresent()) {
+      switch (markerTypeOption.get()) {
+        case TIMELINE_SERVER_BASED:
+          // Reads all markers written by the timeline server
+          Map<String, Set<String>> markersMap =
+              MarkerUtils.readTimelineServerBasedMarkersFromFileSystem(
+                  markerDir, fileSystem, context, parallelism);
+          DirectWriteMarkers directWriteMarkers = new 
DirectWriteMarkers(table, commitInstantTime);
+          // Recreates the markers in the direct format
+          for (Set<String> markers : markersMap.values()) {
+            markers.forEach(directWriteMarkers::create);
+          }
+          // Delete marker type file
+          MarkerUtils.deleteMarkerTypeFile(fileSystem, markerDir);
+          // delete timeline server based markers
+          deleteTimelineBasedMarkerFiles(markerDir, fileSystem);
+          break;
+        default:
+          throw new HoodieException("The marker type \"" + 
markerTypeOption.get().name() + "\" is not supported.");
+      }
+    } else {
+      // incase of partial failures during downgrade, there is a chance that 
marker type file was deleted, but timeline server based marker files are left.
+      // so delete them if any
+      deleteTimelineBasedMarkerFiles(markerDir, fileSystem);

Review comment:
       Yes.  I also changed the filter to be strict to avoid accidental 
matching.

##########
File path: 
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala
##########
@@ -118,7 +118,7 @@ object HoodieSparkSqlWriter {
     } else {
       // Handle various save modes
       handleSaveModes(sqlContext.sparkSession, mode, basePath, tableConfig, 
tblName, operation, fs)
-      val partitionColumns = 
HoodieWriterUtils.getPartitionColumns(keyGenerator)
+      val partitionColumns = 
HoodieSparkWriterUtils.getPartitionColumnsFromKeyGenerator(keyGenerator, 
toProperties(parameters))

Review comment:
       Fixed.

##########
File path: 
hudi-utilities/src/main/java/org/apache/hudi/utilities/deltastreamer/DeltaSync.java
##########
@@ -249,7 +249,7 @@ public void refreshTimeline() throws IOException {
       }
     } else {
       this.commitTimelineOpt = Option.empty();
-      String partitionColumns = 
HoodieWriterUtils.getPartitionColumns(keyGenerator);
+      String partitionColumns = 
HoodieSparkWriterUtils.getPartitionColumnsFromKeyGenerator(keyGenerator, props);

Review comment:
       Fixed.

##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/BaseOneToTwoUpgradeHandler.java
##########
@@ -0,0 +1,43 @@
+/*
+ * 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.table.upgrade;
+
+import org.apache.hudi.common.config.ConfigProperty;
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.table.HoodieTableConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.keygen.constant.KeyGeneratorOptions;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class BaseOneToTwoUpgradeHandler implements UpgradeHandler {
+
+  @Override
+  public Map<ConfigProperty, String> upgrade(HoodieWriteConfig config, 
HoodieEngineContext context, String instantTime) {
+    Map<ConfigProperty, String> tablePropsToAdd = new HashMap<>();
+    tablePropsToAdd.put(HoodieTableConfig.HOODIE_TABLE_NAME_PROP, 
config.getTableName());

Review comment:
       Right.  Removed.

##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/BaseZeroToOneUpgradeHandler.java
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.table.upgrade;
+
+import org.apache.hudi.common.HoodieRollbackStat;
+import org.apache.hudi.common.config.ConfigProperty;
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.model.IOType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.table.timeline.HoodieActiveTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.exception.HoodieRollbackException;
+import org.apache.hudi.table.HoodieTable;
+import org.apache.hudi.table.action.rollback.ListingBasedRollbackRequest;
+import org.apache.hudi.table.action.rollback.RollbackUtils;
+import org.apache.hudi.table.marker.WriteMarkers;
+import org.apache.hudi.table.marker.WriteMarkersFactory;
+
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.Path;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public abstract class BaseZeroToOneUpgradeHandler implements UpgradeHandler {

Review comment:
       Right.

##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/BaseTwoToOneDowngradeHandler.java
##########
@@ -0,0 +1,140 @@
+/*
+ * 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.table.upgrade;
+
+import org.apache.hudi.common.config.ConfigProperty;
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.MarkerUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.hudi.table.HoodieTable;
+import org.apache.hudi.table.marker.DirectWriteMarkers;
+
+import com.esotericsoftware.minlog.Log;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import static org.apache.hudi.common.util.MarkerUtils.MARKERS_FILENAME_PREFIX;
+
+public abstract class BaseTwoToOneDowngradeHandler implements DowngradeHandler 
{
+
+  @Override
+  public Map<ConfigProperty, String> downgrade(HoodieWriteConfig config, 
HoodieEngineContext context, String instantTime) {
+    HoodieTable table = getTable(config, context);
+    HoodieTableMetaClient metaClient = table.getMetaClient();
+
+    // re-create marker files if any partial timeline server based markers are 
found
+    HoodieTimeline inflightTimeline = 
metaClient.getCommitsTimeline().filterPendingExcludingCompaction();
+    List<HoodieInstant> commits = 
inflightTimeline.getReverseOrderedInstants().collect(Collectors.toList());
+    for (HoodieInstant commitInstant : commits) {
+      // Converts the markers in new format to old format of direct markers
+      try {
+        convertToDirectMarkers(
+            commitInstant.getTimestamp(), table, context, 
config.getMarkersDeleteParallelism());
+      } catch (IOException e) {
+        throw new HoodieException("Converting marker files to DIRECT style 
failed during downgrade", e);
+      }
+    }
+    return Collections.EMPTY_MAP;
+  }
+
+  abstract HoodieTable getTable(HoodieWriteConfig config, HoodieEngineContext 
context);
+
+  /**
+   * Converts the markers in new format(timeline server based) to old format 
of direct markers,
+   * i.e., one marker file per data file, without MARKERS.type file.
+   * This needs to be idempotent.
+   * 1. read all markers from timeline server based marker files
+   * 2. create direct style markers
+   * 3. delete marker type file
+   * 4. delete timeline server based marker files
+   *
+   * @param commitInstantTime instant of interest for marker conversion.
+   * @param table             instance of {@link HoodieTable} to use
+   * @param context           instance of {@link HoodieEngineContext} to use
+   * @param parallelism       parallelism to use
+   */
+  private void convertToDirectMarkers(final String commitInstantTime,
+                                      HoodieTable table,
+                                      HoodieEngineContext context,
+                                      int parallelism) throws IOException {
+    String markerDir = 
table.getMetaClient().getMarkerFolderPath(commitInstantTime);
+    FileSystem fileSystem = FSUtils.getFs(markerDir, 
context.getHadoopConf().newCopy());
+    Option<MarkerType> markerTypeOption = 
MarkerUtils.readMarkerType(fileSystem, markerDir);
+    if (markerTypeOption.isPresent()) {
+      switch (markerTypeOption.get()) {
+        case TIMELINE_SERVER_BASED:
+          // Reads all markers written by the timeline server
+          Map<String, Set<String>> markersMap =
+              MarkerUtils.readTimelineServerBasedMarkersFromFileSystem(
+                  markerDir, fileSystem, context, parallelism);
+          DirectWriteMarkers directWriteMarkers = new 
DirectWriteMarkers(table, commitInstantTime);
+          // Recreates the markers in the direct format
+          for (Set<String> markers : markersMap.values()) {

Review comment:
       Fixed.

##########
File path: 
hudi-client/hudi-spark-client/src/main/scala/org/apache/hudi/HoodieSparkWriterUtils.scala
##########
@@ -0,0 +1,64 @@
+/*
+ * 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
+
+import java.util.Properties
+import org.apache.hudi.common.config.TypedProperties
+import org.apache.hudi.keygen.constant.KeyGeneratorOptions
+import org.apache.hudi.keygen.factory.HoodieSparkKeyGeneratorFactory
+import org.apache.hudi.keygen.{BaseKeyGenerator, CustomAvroKeyGenerator, 
CustomKeyGenerator, KeyGenerator}
+import org.apache.spark.sql.sources.v2.DataSourceOptions
+
+import scala.collection.JavaConverters._
+
+/**
+ * A utility class for Spark writer
+ */
+object HoodieSparkWriterUtils {

Review comment:
       Makes sense.  I moved these two functions to `HoodieSparkUtils` class.




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


> Upgrade hoodie table to 0.9.0
> -----------------------------
>
>                 Key: HUDI-2268
>                 URL: https://issues.apache.org/jira/browse/HUDI-2268
>             Project: Apache Hudi
>          Issue Type: Sub-task
>          Components: Usability
>            Reporter: sivabalan narayanan
>            Assignee: sivabalan narayanan
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.9.0
>
>
> Wrt upgrading/downgrading hoodie.properties, here is what we can go. 
> Add a new table version, 2. 
> Add an upgrade step:
> before every write operation. 
>      Check if existing hoodie.props is in an older version. If yes, perform 
> upgrade step to version2 (either from 0 to 2 or from 1 to 2). This 
> essentially means that we need to add new properties pertaining to sql dml to 
> hoodie.properties. 
> Things to watch out for:
> for some operations, not all props might be set by the user. So, we might 
> need to throw an exception. (record key field, partition path field, key gen 
> prop, precombine field). 
> We need to fetch latest table schema since the incoming df could have partial 
> cols.
>  
> Downgrade step: 
> hoodie.properties will have some additional properties. Should not cause any 
> harm. All we need to do is to downgrade the table version to target version 
> and not touch any of the props. 
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to