Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Spark

Technical guide to building and running a Data Product on Apache Spark with Iceberg: connection setup, materialization, tuning, and troubleshooting.

Apache Spark is a unified analytics engine for large-scale data processing. Vulcan integrates with Spark to manage transformations as Apache Iceberg tables over object storage, with version control and safe deployments. This page is the full manual: platform dependencies, connection and storage setup, local development, how each model kind materializes to Iceberg, the semantic layer, data quality, deployment recipes, driver and executor tuning, and the failure modes you hit in real projects.

When to use

Choose Spark when you run a lakehouse: large batch transforms, shuffle-heavy joins, multi-year backfills, and Iceberg-backed marts over S3 or ABFSS. Spark is a batch/lakehouse engine, not a sub-second serving engine. If your downstream SLO is sub-second on arbitrary semantic queries, pre-aggregate into a serving store or use a lower-latency engine for that surface.

Spark performance is workload-shaped: a 10 GB dimension update, a 100 GB shuffle-heavy join, and a 1 TB backfill have different ceilings. Use Limits & Performance to size from the data shape, not from row count alone.

Supported model kinds

FULL, SEED / EMBEDDED, INCREMENTAL_BY_TIME_RANGE, INCREMENTAL_BY_PARTITION, INCREMENTAL_BY_UNIQUE_KEY (requires Iceberg physical_properties), and SCD_TYPE_2.

Engine characteristics

Property
Value

Engine adapter type

spark

Model dialect

spark2

Support level

GA for S3 and ABFSS lakehouse deployments

Table format

Apache Iceberg through a REST catalog

Object storage

Amazon S3 and Azure ABFSS

Tested Vulcan image

tmdcio/vulcan-spark:0.228.1.30

Serving images

tmdcio/vulcan-graphql:0.228.1.30, tmdcio/mysql-wire:0.228.1.30

Tested DataOS release

Draco 1.38 series

Unsupported and out-of-scope capabilities

Feature
Why not supported
Alternative

Spark compute lifecycle (create / resize / stop)

Vulcan has no compute pool management API

Provision compute pools via DataOS admin or Terraform

Materialized views

Not the default Spark/Iceberg path; version-dependent

Use kind FULL incremental models as materialized equivalents

Sub-second API serving for arbitrary queries

Spark/Iceberg is a batch/lakehouse engine, not optimized for point lookups

Pre-aggregate into a serving store or use a lower-latency engine for that surface

Concurrent writes to the same Iceberg table

Optimistic commit; concurrent MERGE writers can conflict

Use concurrencyPolicy: Forbid, stagger heavy writers, configure commit retry

DLT / streaming tables

Separate concern; not in Vulcan's model kinds

Build streaming pipelines natively; land results as Iceberg tables for Vulcan to read

Once Spark fits your Data Product, follow the stages below: Authorize, Connect, Build models, Serve, Operate safely, and Troubleshoot.

Start at the stage that matches your current progress. Complete each preceding stage before deployment.

Authorize

Access setup is required before gateway configuration.

Provision the Spark-capable compute pool, the lakehouse and its depot, and the DataOS roles and permissions before deployment. See Permissions and grants for the role breakdown, object-storage grant templates, and required DataOS permissions.

Connect

This is the first hands-on step. Configure the gateway connection, then load the JVM and Python dependencies Spark needs.

Spark is single-catalog: all models must be defined under one catalog. For gateway configuration properties and dependency loading, see Connect to Spark.

Build models

Choose a model kind only after the connection validates successfully.

Review Materialization behaviour for model-kind mappings to Spark/Iceberg operations, Python models, identifier casing, the semantic layer, and business metrics.

Serve

Choose a consumption endpoint and confirm the catalog and lineage are current.

Endpoints

The Spark stack serves API traffic through three dedicated serving images on the deployed api track:

Endpoint
Runtime image

REST

Vulcan API (tmdcio/vulcan-spark:0.228.1.30)

GraphQL

tmdcio/vulcan-graphql:0.228.1.30

MySQL-wire

tmdcio/mysql-wire:0.228.1.30 (port 3306)

Endpoint queries read the semantic layer and push execution to Spark/Iceberg. Size the API track separately from the workflow cluster, but remember that expensive semantic queries still consume Spark compute. Keep api.resources.limits.memory at or above 1.5 GiB (recommended 2 GiB) to avoid OOM on large result sets.

MCP tools

MCP tool
Spark behavior

about

Static; no engine call

lineage

Parsed graph; no live Spark job

quality

Last check/audit results; typically no live call

data

Live Spark/Iceberg query; consumes compute

run

Triggers workflow; same cost as a scheduled run

activity

Reads workflow history from DataOS; no engine call

Treat agent-driven data tool queries like production dashboard queries: they can trigger Spark scans, shuffles, and Iceberg reads through the semantic layer.

Metadata scanning and catalog

DataOS scans two Spark/Iceberg sources: the Iceberg REST catalog (real-time structural metadata: tables, schemas, columns, and partition specs) and object-storage scan logs or Iceberg history (lineage).

Object
Catalog
Lineage

Namespaces (schemas)

✓

Not applicable

Iceberg tables

✓

✓ as nodes

Columns with types

✓

✓ column-level

Partition specs

✓ as metadata

Not applicable

Lineage edges (from parsed models)

Not applicable

✓ from Vulcan parse

Iceberg snapshots / history

Partially shown

Used internally

Lineage is primarily Vulcan-computed: DataOS parses the model SQL graph and inputs.yaml. Iceberg metadata contributes snapshot and schema evolution history.

The scanner role is read-only and separate from the Vulcan service role. Grant the scanner principal purpose: scan on the lakehouse depot, with:

The scanner runs every 6 to 12 hours (configurable); structural changes (new tables, columns) appear after the next scan. Lineage from model runs is computed from Vulcan's SQL parse and is available immediately after a successful vulcan run. Iceberg snapshot-level lineage (for example partition evolution) may lag behind the catalog scan cycle.

Lineage and version rollback

Spark does not infer missing lineage from the Iceberg catalog automatically. Declare external tables in inputs.yaml:

Without the declaration, the linter throws Table not found and lineage stops at the model boundary. Keep fully qualified lakehouse names consistent across models, DQ files, and semantic files.

Rollback replays the previous materialization strategy and produces new Iceberg snapshots. For INCREMENTAL_BY_UNIQUE_KEY, plan rollbacks carefully. The MERGE path is not a cheap metadata pointer flip. It consumes Spark compute and Iceberg commits.

Engine-native feature support

Spark / Iceberg feature
Vulcan pattern
Notes

Spark runtime

Tenant-level vulcan-spark stack

Configured once per tenant by SRE

Spark driver

spec.workflow.resources.driver

Runs migrate, plan, run

Spark executors

spec.workflow.resources.executor

Distributed scan, shuffle, join, write

Iceberg REST catalog

Lakehouse depot in spec.depots[]

Stack generates spark.sql.catalog.* automatically

S3 object storage

Lakehouse with storageType: s3

Not applicable

ABFSS object storage

Lakehouse with storageType: abfss

May need Azure bundle JAR

Full-refresh Iceberg table

kind FULL + physical_properties(format = 'iceberg')

Rebuildable; good for aggregates and marts

Time-range incremental

INCREMENTAL_BY_TIME_RANGE

Insert overwrite by interval partition

Partition incremental

INCREMENTAL_BY_PARTITION

Insert overwrite by partition key

Unique-key upsert

INCREMENTAL_BY_UNIQUE_KEY + physical_properties(format = 'iceberg')

Compiles to Iceberg MERGE INTO

Conditional delete/update in MERGE

when_matched inside unique-key model

Uses source. and target. aliases

SCD Type 2

SCD_TYPE_2 kind

Dimension history with current and historical rows

SEED / EMBEDDED

kind SEED or EMBEDDED

File-backed reference data

Python models (Spark DataFrame)

.py model returning SparkDataFrame

Return Spark DataFrames; avoid Pandas for large outputs

JVM dependencies

dependencies/java/

JARs auto-loaded by stack for driver + executors

Python wheel dependencies

dependencies/python/

Wheels auto-loaded by stack

Spark tuning - workflow

spec.workflow.sparkConf

Merged with generated catalog config

Spark tuning - API track

spec.sparkConf

Separate Spark session; set matching keys in both if the API needs the same classpath/catalog config

Serving

spec.api + sidecar images

REST, GraphQL, MySQL-wire

Spark compute lifecycle

Boundary

Provision compute pools via DataOS admin

DLT / Streaming tables

Boundary

Separate concern; land results as Iceberg tables

Operate safely

Set workload limits before scaling consumers or production schedules.

For driver and executor sizing, Spark tuning, API replicas, scheduling, and performance baselines, see Limits & Performance.

Before production

  • Confirm least-privilege grants for the service and consumer roles.

  • Validate the gateway locally with vulcan plan and vulcan run.

  • Set concurrencyPolicy: Forbid and size drivers/executors for your workload tier.

  • Test recovery procedures before scheduling production workloads.

Troubleshoot

For common failures, log locations, and recovery procedures, see Troubleshooting.

Start faster with a recipe

Skip tuning from a blank slate. Deployment recipes has ready-to-copy sparkConf and resource sizing for a daily incremental project, a medium lakehouse mart, a large backfill, and a MERGE-heavy CDC project.

Full implementation example

Use this complete Spark Data Product as a production-shaped starting point.

archive · 71KB
Open

Last updated

Was this helpful?