You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xtable.apache.org by "vinishjail97 (via GitHub)" <gi...@apache.org> on 2026/07/07 20:22:35 UTC

[PR] [836] xtable-spark-runtime: thin drop-in bundle (packaging) + resilient target discovery [incubator-xtable]

vinishjail97 opened a new pull request, #838:
URL: https://github.com/apache/incubator-xtable/pull/838

   ## What is the purpose of the pull request
   
   First of two PRs splitting #837 (per review feedback) into **packaging** and **listener**. This is the **packaging** PR (the listener stacks on top): it introduces the `xtable-spark-runtime` module producing a thin, drop-in Spark bundle, plus RFC-3, and validates the jar end-to-end via `spark-submit`.
   
   ## Brief change log
   
   - **RFC-3** (`rfc/rfc-3/rfc-3.md`).
   - New module `xtable-spark-runtime_${scala.binary.version}` (thin shaded bundle, **~4 MB**).
   - `XTableSparkSync` — standalone `spark-submit` entry point (RunSync-equivalent for this bundle).
   - `TableSyncSpec` / `XTableSyncService` — shared sync building blocks (reused by the listener PR).
   - `ConversionTargetFactory`: make `ServiceLoader` target discovery **resilient** — skip targets whose engine lib isn't on the classpath (separable core change; see commit 1).
   - `ITXTableSparkRuntimeBundle` — spark-submit jar-validation test.
   
   ### Packaging model (the important part)
   Per review feedback, engines are **not bundled**. Spark, Hadoop, **and Hudi/Iceberg/Delta are all `provided`** — the user brings their own engine versions (Hudi 1.1 / 1.2 / …) and the thin XTable jar stays compatible across them.
   
   - Curated shade allowlist: only XTable modules + `guava`/`protobuf` (relocated under `org.apache.xtable.shaded.*`).
   - Libraries XTable **exchanges with the engines are deliberately not relocated/bundled** — relocating `avro` breaks the boundary (Hudi returns a real `org.apache.avro.Schema` → `NoSuchMethodError`). `avro`/`parquet`/`jackson`/`commons` come from the provided runtime.
   - Because target discovery uses `ServiceLoader`, it's made resilient so a user can run with only the engines they use (e.g. Hudi + Iceberg, no Delta).
   
   ## Verify this pull request
   
   `ITXTableSparkRuntimeBundle` (skipped unless `SPARK_HOME` is set) builds the shaded jar and runs a real sync:
   
   ```
   SPARK_LOCAL_IP=127.0.0.1 mvn -pl xtable-spark-runtime -am verify
   ```
   
   It creates a local Hudi table, `spark-submit`s the bundle with Hudi + Iceberg supplied via `--packages` (versions from the root pom: Hudi 1.2.0, Iceberg 1.9.2), and asserts the Iceberg metadata is produced. Validated locally on Spark 3.5.2 (engines built for 3.4 → also a cross-version check).
   
   Part of #836. Listener PR follows, stacked on this branch.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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: commits-unsubscribe@xtable.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [836] xtable-spark-runtime: thin drop-in bundle (packaging) + resilient target discovery [incubator-xtable]

Posted by "vinishjail97 (via GitHub)" <gi...@apache.org>.
vinishjail97 commented on code in PR #838:
URL: https://github.com/apache/incubator-xtable/pull/838#discussion_r3540257999


##########
xtable-spark-runtime/src/main/java/org/apache/xtable/spark/XTableSparkSync.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * 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.xtable.spark;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import lombok.extern.log4j.Log4j2;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.spark.sql.SparkSession;
+
+/**
+ * Standalone {@code spark-submit} entry point that runs a single XTable sync using the relocated
+ * {@code xtable-spark-runtime} bundle. It is the RunSync-equivalent for this bundle and is
+ * primarily used to validate that the shaded jar is self-contained on a real Spark install.
+ *
+ * <pre>
+ * $SPARK_HOME/bin/spark-submit \
+ *   --class org.apache.xtable.spark.XTableSparkSync \
+ *   xtable-spark-runtime_2.12-&lt;ver&gt;.jar \
+ *   --basePath /warehouse/db/orders --sourceFormat HUDI --targets ICEBERG,DELTA
+ * </pre>
+ */
+@Log4j2
+public final class XTableSparkSync {
+
+  private XTableSparkSync() {}
+
+  public static void main(String[] args) {
+    Map<String, String> opts = parseArgs(args);
+    String basePath = required(opts, "basePath");
+    String sourceFormat = required(opts, "sourceFormat");
+    String targets = required(opts, "targets");
+    String tableName = opts.getOrDefault("tableName", basePathToName(basePath));
+
+    List<String> targetFormats =
+        Arrays.stream(targets.split(","))
+            .map(String::trim)
+            .filter(s -> !s.isEmpty())
+            .map(s -> s.toUpperCase(java.util.Locale.ROOT))
+            .collect(Collectors.toList());
+
+    TableSyncSpec spec =
+        TableSyncSpec.builder()
+            .key(tableName)
+            .basePath(basePath)
+            .dataPath(opts.get("dataPath"))
+            .namespace(opts.containsKey("namespace") ? opts.get("namespace").split("\\.") : null)
+            .sourceFormat(sourceFormat.toUpperCase(java.util.Locale.ROOT))
+            .targets(targetFormats)
+            .build();
+
+    SparkSession spark = SparkSession.builder().appName("xtable-spark-sync").getOrCreate();
+    try {
+      Configuration hadoopConf = spark.sparkContext().hadoopConfiguration();
+      log.info("Starting standalone XTable sync for {}", spec.getBasePath());
+      new XTableSyncService().sync(spec, hadoopConf);
+      log.info("Completed XTable sync for {}", spec.getBasePath());
+    } finally {
+      spark.stop();
+    }
+  }
+
+  private static Map<String, String> parseArgs(String[] args) {

Review Comment:
   Good call. Switched to Apache Commons CLI (`Options` + `DefaultParser` + `HelpFormatter`), mirroring `RunSync`. commons-cli is bundled and relocated under `org.apache.xtable.shaded.*`. Done in 96da5d67.



##########
xtable-core/src/main/java/org/apache/xtable/conversion/ConversionTargetFactory.java:
##########
@@ -87,7 +90,19 @@ public ConversionTarget createConversionTargetForName(
         TableFormat.DELTA.equalsIgnoreCase(tableFormatName)
             && DeltaConversionTargetConfig.fromProperties(properties).isUseKernel();
     ServiceLoader<ConversionTarget> loader = ServiceLoader.load(ConversionTarget.class);
-    for (ConversionTarget target : loader) {
+    Iterator<ConversionTarget> iterator = loader.iterator();
+    while (iterator.hasNext()) {
+      ConversionTarget target;
+      try {
+        target = iterator.next();
+      } catch (ServiceConfigurationError | LinkageError error) {
+        // A registered target whose engine library is not on the classpath (e.g. Delta when only
+        // Hudi/Iceberg are provided). Skip it so a subset of engines can still be used; a missing
+        // engine for the requested format surfaces below as NotSupportedException.
+        log.debug(

Review Comment:
   Changed to `log.warn` with a message pointing the user to provide the missing engine, so an absent provided package is visible. Done in 96da5d67.



##########
xtable-core/src/main/java/org/apache/xtable/conversion/ConversionTargetFactory.java:
##########
@@ -96,7 +111,12 @@ && isDeltaKernelTarget(target) == useKernel) {
     throw new NotSupportedException("Target format is not yet supported: " + tableFormatName);
   }
 
+  private static final String DELTA_KERNEL_TARGET_CLASS =
+      "org.apache.xtable.kernel.DeltaKernelConversionTarget";
+
+  // Name-based to avoid loading DeltaKernelConversionTarget (and its io.delta.kernel dependencies)

Review Comment:
   Removed. Done in 96da5d67.



-- 
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: commits-unsubscribe@xtable.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [836] xtable-spark-runtime: thin drop-in bundle (packaging) + resilient target discovery [incubator-xtable]

Posted by "vinishjail97 (via GitHub)" <gi...@apache.org>.
vinishjail97 commented on code in PR #838:
URL: https://github.com/apache/incubator-xtable/pull/838#discussion_r3539857186


##########
xtable-core/src/main/java/org/apache/xtable/conversion/ConversionTargetFactory.java:
##########
@@ -87,7 +90,19 @@ public ConversionTarget createConversionTargetForName(
         TableFormat.DELTA.equalsIgnoreCase(tableFormatName)
             && DeltaConversionTargetConfig.fromProperties(properties).isUseKernel();
     ServiceLoader<ConversionTarget> loader = ServiceLoader.load(ConversionTarget.class);
-    for (ConversionTarget target : loader) {
+    Iterator<ConversionTarget> iterator = loader.iterator();
+    while (iterator.hasNext()) {
+      ConversionTarget target;
+      try {
+        target = iterator.next();
+      } catch (ServiceConfigurationError | LinkageError error) {
+        // A registered target whose engine library is not on the classpath (e.g. Delta when only
+        // Hudi/Iceberg are provided). Skip it so a subset of engines can still be used; a missing
+        // engine for the requested format surfaces below as NotSupportedException.
+        log.debug(

Review Comment:
   Make this a warn log so that it's visible for the user if some provided package is missing? 



##########
xtable-core/src/main/java/org/apache/xtable/conversion/ConversionTargetFactory.java:
##########
@@ -96,7 +111,12 @@ && isDeltaKernelTarget(target) == useKernel) {
     throw new NotSupportedException("Target format is not yet supported: " + tableFormatName);
   }
 
+  private static final String DELTA_KERNEL_TARGET_CLASS =
+      "org.apache.xtable.kernel.DeltaKernelConversionTarget";
+
+  // Name-based to avoid loading DeltaKernelConversionTarget (and its io.delta.kernel dependencies)

Review Comment:
   Remove this comment..the code is self explanatory.



##########
xtable-spark-runtime/src/main/java/org/apache/xtable/spark/XTableSparkSync.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * 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.xtable.spark;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import lombok.extern.log4j.Log4j2;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.spark.sql.SparkSession;
+
+/**
+ * Standalone {@code spark-submit} entry point that runs a single XTable sync using the relocated
+ * {@code xtable-spark-runtime} bundle. It is the RunSync-equivalent for this bundle and is
+ * primarily used to validate that the shaded jar is self-contained on a real Spark install.
+ *
+ * <pre>
+ * $SPARK_HOME/bin/spark-submit \
+ *   --class org.apache.xtable.spark.XTableSparkSync \
+ *   xtable-spark-runtime_2.12-&lt;ver&gt;.jar \
+ *   --basePath /warehouse/db/orders --sourceFormat HUDI --targets ICEBERG,DELTA
+ * </pre>
+ */
+@Log4j2
+public final class XTableSparkSync {
+
+  private XTableSparkSync() {}
+
+  public static void main(String[] args) {
+    Map<String, String> opts = parseArgs(args);
+    String basePath = required(opts, "basePath");
+    String sourceFormat = required(opts, "sourceFormat");
+    String targets = required(opts, "targets");
+    String tableName = opts.getOrDefault("tableName", basePathToName(basePath));
+
+    List<String> targetFormats =
+        Arrays.stream(targets.split(","))
+            .map(String::trim)
+            .filter(s -> !s.isEmpty())
+            .map(s -> s.toUpperCase(java.util.Locale.ROOT))
+            .collect(Collectors.toList());
+
+    TableSyncSpec spec =
+        TableSyncSpec.builder()
+            .key(tableName)
+            .basePath(basePath)
+            .dataPath(opts.get("dataPath"))
+            .namespace(opts.containsKey("namespace") ? opts.get("namespace").split("\\.") : null)
+            .sourceFormat(sourceFormat.toUpperCase(java.util.Locale.ROOT))
+            .targets(targetFormats)
+            .build();
+
+    SparkSession spark = SparkSession.builder().appName("xtable-spark-sync").getOrCreate();
+    try {
+      Configuration hadoopConf = spark.sparkContext().hadoopConfiguration();
+      log.info("Starting standalone XTable sync for {}", spec.getBasePath());
+      new XTableSyncService().sync(spec, hadoopConf);
+      log.info("Completed XTable sync for {}", spec.getBasePath());
+    } finally {
+      spark.stop();
+    }
+  }
+
+  private static Map<String, String> parseArgs(String[] args) {

Review Comment:
   Is this the right to parse? Any existing libraries that can be used to avoid hand-written logic? 
   https://github.com/apache/incubator-xtable/blob/main/xtable-utilities/src/main/java/org/apache/xtable/utilities/RunSync.java#L240 



-- 
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: commits-unsubscribe@xtable.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [836] xtable-spark-runtime: thin drop-in bundle (packaging) + resilient target discovery [incubator-xtable]

Posted by "the-other-tim-brown (via GitHub)" <gi...@apache.org>.
the-other-tim-brown commented on code in PR #838:
URL: https://github.com/apache/incubator-xtable/pull/838#discussion_r3610806265


##########
rfc/rfc-3/rfc-3.md:
##########
@@ -0,0 +1,181 @@
+<!--
+  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.
+-->
+# RFC-3: xtable-spark-runtime - in-job metadata sync via a thin Spark bundle

Review Comment:
   Can we pull out the RFC into its own pull request?



-- 
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: commits-unsubscribe@xtable.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [836] xtable-spark-runtime: thin drop-in bundle (packaging) + resilient target discovery [incubator-xtable]

Posted by "vinishjail97 (via GitHub)" <gi...@apache.org>.
vinishjail97 closed pull request #838: [836] xtable-spark-runtime: thin drop-in bundle (packaging) + resilient target discovery
URL: https://github.com/apache/incubator-xtable/pull/838


-- 
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: commits-unsubscribe@xtable.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [836] xtable-spark-runtime: thin drop-in bundle (packaging) + resilient target discovery [incubator-xtable]

Posted by "vinishjail97 (via GitHub)" <gi...@apache.org>.
vinishjail97 commented on PR #838:
URL: https://github.com/apache/incubator-xtable/pull/838#issuecomment-6067671814

   Closing as the main branch as drifted a lot...will create a new PR on top of latest main.


-- 
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: commits-unsubscribe@xtable.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org