| layout | page |
|---|---|
| title | NVIDIA cuDF plugin for Apache Spark Distribution Packaging |
| nav_order | 1 |
| parent | Developer Overview |
The distribution module creates a jar with support for the Spark versions you need combined into a single jar.
See the CONTRIBUTING.md doc for details on building and profiles available to build an uber jar.
Note that when you use the profiles to build an uber jar there are currently some hardcoded service provider files that get put into place. One file for each of the above profiles. Please note that you will need to update these if adding or removing support for a Spark version.
Files are: com.nvidia.spark.rapids.SparkShimServiceProvider.sparkNonSnapshot, com.nvidia.spark.rapids.SparkShimServiceProvider.sparkSnapshot, com.nvidia.spark.rapids.SparkShimServiceProvider.sparkNonSnapshotDB, and com.nvidia.spark.rapids.SparkShimServiceProvider.sparkSnapshotDB.
The new uber jar is structured like:
- Base common classes are user visible classes. For these we use Spark 3.3.0 versions because they are assumed to be bitwise-identical to the other shims, this assumption is subject to the future automatic validation.
- META-INF/services. This is a file that has to list all the shim versions supported by this jar. The files talked about above for each profile are put into place here for uber jars. Although we currently do not use ServiceLoader API we use the same service provider discovery mechanism
- META-INF base files are from 3.3.0 - maven, LICENSE, NOTICE, etc
- Spark specific directory (aka Parallel World in the jargon of ParallelWorldClassloader) for each version of Spark supported in the jar, i.e., spark330/, spark341/, etc.
If you have to change the contents of the uber jar, the packaging flow can optionally promote common classes to the base jar when binary dedupe proves they are bitwise-identical across shims. That default promotion path is gated by UNSHIM_PROMOTE_DEFAULT_SPARK_SHARED_CLASSES=1; normal packaging still uses the explicit allowlists below.
keep-in-spark-shared.txt- Patterns for bitwise-identical commonspark-sharedclass files that must stay inspark-sharedwhen optional default promotion is enabled. This should stay small; add entries only for compatibility or packaging exceptions.keep-in-spark-shim-dirs.txt- Patterns for bitwise-identical class files that must remain duplicated in each Spark-version directory instead of being consolidated intospark-sharedor, when optional default promotion is enabled, promoted to the base jar. This is for classes that are loaded through a selected shim and need same-loader visibility to other shim-only classes.root-safe-module-classes.txt- Module artifactIds whose classes are safe to promote from the shaded aggregator output into the base jar. Use this for helper modules whose complete class set should stay root-visible; implementations may be Java or Scala.unshimmed-common-from-single-shim.txt- Files that must go into the base jar from one representative shim, such as rootMETA-INFresources and Python worker files. Avoid adding class files here unless they need special root-layout treatment outside optional bitwise-identical promotion or module-level class promotion.unshimmed-from-each-spark3xx.txt- This is applied to all the individual Spark specific version jars to pull any files that need to go into the base of the jar and not into the Spark specific directory. These are per-shim root artifacts rather than commonspark-sharedclasses.
The dist package phase runs scripts/check-iceberg-package-private-access.py against
the assembled parallel-world layout and every Iceberg runtime selected by the build. The
audit fails when a cuDF Plugin class that accesses an Iceberg package-private class or
member, or relies on same-runtime-package access to a protected member, is stored outside
the jar root. A separate classloader would give that caller a different runtime package.
build/package-parallel-worlds.py discovers each Spark aggregator's Iceberg dependency
with build/iceberg_runtime.py, resolves the runtime jars, and writes the generated
target/iceberg-audit-runtimes.txt manifest consumed by the audit. Do not edit that
manifest. Fix failures by making the caller root-safe through
root-safe-module-classes.txt or, for exceptional per-class placement, the applicable
unshimmed-*.txt input above.
The same package-phase audit also checks package-private and runtime-package-dependent
protected accesses to Spark classes. It inspects the Spark jars for each selected build
version, including class and member references from org/apache/spark/ plugin classes.
For upstream Spark, packaging resolves a fixed set of Spark modules for each version;
the audit does not depend on which jars happen to be in the local Maven cache.
For Databricks classifiers, it reads the Spark jars from the generated system-scope
dependency BOM under shim-deps/databricks instead of the Maven repository. That BOM
must identify the single Databricks build version being audited. Off-cluster distribution
jobs may explicitly skip unavailable Databricks runtimes with
-Drapids.spark.audit.skip.buildvers=350db143,400db173. The two off-cluster
Databricks distribution profiles use databricks to skip all included Databricks
classifiers; Databricks cluster builds
run the audit against their own runtime. The generated
target/spark-audit-runtimes.txt records the selected jars. Direct access to a
Spark package-private class or member fails the audit even at the JAR root:
--jars can load that root through a different classloader from Spark. The Parquet
cache reader uses reflection for ParquetColumnVector to work in either layout.
To exercise this access through a local Spark cache scan, run
SPARK_HOME=/path/to/spark dist/scripts/tests/run-spark-cache-root-safety.sh dist/target/rapids-4-spark_2.12-<version>-cuda12.jar after assembling the
distribution JAR. Use a Spark installation matching one of the JAR's shims and
Scala binary version. The test checks cached table and view reads, builds a
derived cache to exercise the CPU columnar read, then executes the columnar
cache scan that calls ShimCurrentBatchIterator.
Single-shim builds where every real Iceberg integration module uses the same non-Maven
runtime can add its absolute local jar path with
-Drapids.iceberg.audit.runtime.path=.... This replaces Maven-coordinate discovery for
the selected aggregator: every real Iceberg integration module must declare zero Maven
Iceberg runtime dependencies, and the supplied path is used to audit all of them. Missing,
empty, or otherwise ambiguous runtime inputs fail the build.