This is an automated email from the ASF dual-hosted git repository.
yihua pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/master by this push:
new 51d28fd75f5 [HUDI-6264] Assert that bootstrap base path is different
than path (#8808)
51d28fd75f5 is described below
commit 51d28fd75f5deb9f2f5a96f3522cf613ed0e95ee
Author: Jon Vexler <[email protected]>
AuthorDate: Tue May 30 12:27:50 2023 -0400
[HUDI-6264] Assert that bootstrap base path is different than path (#8808)
Co-authored-by: Jonathan Vexler <=>
Co-authored-by: Y Ethan Guo <[email protected]>
---
.../src/main/java/org/apache/hudi/cli/commands/BootstrapCommand.java | 4 ++++
.../src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala | 3 ++-
.../spark/sql/hudi/command/procedures/RunBootstrapProcedure.scala | 4 ++++
.../org/apache/hudi/utilities/deltastreamer/BootstrapExecutor.java | 4 ++++
4 files changed, 14 insertions(+), 1 deletion(-)
diff --git
a/hudi-cli/src/main/java/org/apache/hudi/cli/commands/BootstrapCommand.java
b/hudi-cli/src/main/java/org/apache/hudi/cli/commands/BootstrapCommand.java
index 98cf9fc0d90..4f046df6198 100644
--- a/hudi-cli/src/main/java/org/apache/hudi/cli/commands/BootstrapCommand.java
+++ b/hudi-cli/src/main/java/org/apache/hudi/cli/commands/BootstrapCommand.java
@@ -82,6 +82,10 @@ public class BootstrapCommand {
defaultValue = "") final String[] configs)
throws IOException, InterruptedException, URISyntaxException {
+ if (targetPath.equals(srcPath)) {
+ throw new IllegalArgumentException("srcPath and targetPath must be
different");
+ }
+
String sparkPropertiesPath =
Utils.getDefaultPropertiesFile(JavaConverters.mapAsScalaMapConverter(System.getenv()).asScala());
diff --git
a/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala
b/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala
index f353f78b063..8b35bf43403 100644
---
a/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala
+++
b/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala
@@ -54,7 +54,7 @@ import
org.apache.hudi.internal.schema.utils.AvroSchemaEvolutionUtils.reconcileN
import org.apache.hudi.internal.schema.utils.{AvroSchemaEvolutionUtils,
SerDeHelper}
import org.apache.hudi.keygen.constant.KeyGeneratorOptions
import org.apache.hudi.keygen.factory.HoodieSparkKeyGeneratorFactory
-import
org.apache.hudi.keygen.factory.HoodieSparkKeyGeneratorFactory.{createKeyGenerator,
getKeyGeneratorClassName}
+import
org.apache.hudi.keygen.factory.HoodieSparkKeyGeneratorFactory.getKeyGeneratorClassName
import org.apache.hudi.keygen.{BaseKeyGenerator, KeyGenUtils,
SparkKeyGeneratorInterface, TimestampBasedAvroKeyGenerator,
TimestampBasedKeyGenerator}
import org.apache.hudi.metrics.Metrics
import org.apache.hudi.sync.common.HoodieSyncConfig
@@ -703,6 +703,7 @@ object HoodieSparkSqlWriter {
val bootstrapBasePath = hoodieConfig.getStringOrThrow(BASE_PATH,
s"'${BASE_PATH.key}' is required for '${BOOTSTRAP_OPERATION_OPT_VAL}'" +
" operation'")
+ assert(!path.equals(bootstrapBasePath), "Bootstrap base path and Hudi
table base path must be different")
val bootstrapIndexClass = hoodieConfig.getStringOrDefault(INDEX_CLASS_NAME)
var schema: String = null
diff --git
a/hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/RunBootstrapProcedure.scala
b/hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/RunBootstrapProcedure.scala
index 458d618e92b..c2f18edaeeb 100644
---
a/hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/RunBootstrapProcedure.scala
+++
b/hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/RunBootstrapProcedure.scala
@@ -95,6 +95,10 @@ class RunBootstrapProcedure extends BaseProcedure with
ProcedureBuilder with Log
properties.setProperty(HoodieBootstrapConfig.BASE_PATH.key, bootstrapPath)
+ if (bootstrapPath.equals(basePath)) {
+ throw new IllegalArgumentException("bootstrap_path and base_path must be
different")
+ }
+
if (!StringUtils.isNullOrEmpty(keyGeneratorClass) &&
KeyGeneratorType.getNames.contains(keyGeneratorClass.toUpperCase(Locale.ROOT)))
{
properties.setProperty(HoodieWriteConfig.KEYGENERATOR_TYPE.key,
keyGeneratorClass.toUpperCase(Locale.ROOT))
}
diff --git
a/hudi-utilities/src/main/java/org/apache/hudi/utilities/deltastreamer/BootstrapExecutor.java
b/hudi-utilities/src/main/java/org/apache/hudi/utilities/deltastreamer/BootstrapExecutor.java
index 07cfbeb847d..fc7ecc0f156 100644
---
a/hudi-utilities/src/main/java/org/apache/hudi/utilities/deltastreamer/BootstrapExecutor.java
+++
b/hudi-utilities/src/main/java/org/apache/hudi/utilities/deltastreamer/BootstrapExecutor.java
@@ -202,6 +202,10 @@ public class BootstrapExecutor implements Serializable {
}
}
+ if (cfg.targetBasePath.equals(bootstrapBasePath)) {
+ throw new IllegalArgumentException("Bootstrap source base path and Hudi
table base path must be different");
+ }
+
HoodieTableMetaClient.PropertyBuilder builder =
HoodieTableMetaClient.withPropertyBuilder()
.fromProperties(props)
.setTableType(cfg.tableType)