Documentation / Pipelines

Data lake export (Apache® Spark)

Copy the vault into Delta Lake, Iceberg or Parquet tables and keep them up to date.

Export to a data lake (Apache Spark) is an egress pipeline that runs on an Apache Spark cluster instead of NiFi™. Each run reads the new and changed resources from PostgreSQL® straight into the cluster (several connections in parallel) and writes them to the data lake. Choose Add Egress, then the tile Export to a data lake. The integration server step then lists the Apache Spark servers.

SettingChoose
ExportThe raw vault, the MDM golden records or an anonymized vault of the data source.
Table formatDelta Lake or Apache Iceberg: a changes table and, unless you untick it, a current table. Parquet: the changes table only.
Folder in the data lake or Iceberg namespaceWhere the tables go, as the cluster sees it: for example s3a://lake/fhir/hospital-a (tables in /changes and /current) or lake.fhir (tables fhir_changes and fhir_current). The cluster needs write access there; the suite stores no storage keys.
The first run exportsThe current version of every resource, every stored version (the full history), or nothing (only later changes).
RunEvery 15 minutes, every hour, every day, or only by hand. A run starts only when the previous one has ended.
TriggerThe resource types to export (or all), optionally with search criteria. Search criteria are not available for the MDM golden records.
SparkParallel reads from the database (1 to 64), rows per fetch, and when to stop a run that takes too long.

The tables

Both tables have one row per resource version: resource_type, fhir_server_id, fhir_id, hub_hk, load_dts (when the vault stored it), version_id, last_updated, record_source, is_deleted, resource_json (the resource as JSON text), fhir_version, source_layer, source_vault, export_run_id, exported_at and load_date. changes keeps every version and every delete. current holds the latest version of each resource; a deleted resource is removed from it.

Buttons

Deploy checks the Spark server and the settings; nothing is installed on the cluster. Start and Stop switch the schedule on and off. Run now starts a run at once. Runs lists the runs with their status, duration, the number of versions exported and the steps. Undeploy stops the runs and keeps the tables; deploying again continues where the last run ended.

Note

A run never loses or doubles a row: it takes the rows stored since the end of the last run, up to a moment just before it started, and never past a load that is still busy. If a run fails, the next run takes the same rows again.

Careful

Needs, on the Spark cluster: a Spark Connect server, the PostgreSQL JDBC driver, and the Delta Lake or Iceberg packages for those formats. The cluster connects to the database itself, so a data source that connects to localhost needs the database host as the cluster sees it (Advanced: database connection). On the suite server: Python 3 and the Spark Connect client of the cluster's Spark version (pip install "pyspark-client==4.0.2"); its place can be set in Pipelines > Settings.