Skip to main content
Dependencies:
  • ProphecySparkBasicsPython 0.0.1+
  • ProphecySparkBasicsScala 0.0.1+
Cluster requirements:
  • UC dedicated clusters 14.3+ supported
  • UC standard clusters 14.3+ supported
  • Livy clusters not supported
A Delta (Delta Lake) file type:
  • Is an optimized storage layer that allows you to store data and tables in the Databricks lakehouse.
  • Extends Parquet data files with a file-based transaction log for ACID transactions and scalable metadata handling.
  • Has a tight integration with structured streaming, which allows you to use a single copy of data for both batch and streaming operations and provides incremental processing at scale.

Parameters

Source

The Source gem reads data from Delta files and allows you to optionally specify the following additional properties.

Source properties

You can only select Read Timestamp or Read Version, not both.

Example

Delta source example

Compiled code

To see the compiled code of your project, switch to the Code view in the project header.

Without time travel

Timestamp-based time travel

Version-based time travel


Target

The Target gem writes data to Delta files and allows you to optionally specify the following additional properties.

Target properties

Supported write modes

Target Example

Delta Target Example

Compiled code

To see the compiled code of your project, switch to the Code view in the project header.

Delta MERGE

You can upsert data from a source DataFrame into a target Delta table by using the MERGE operation. Delta MERGE supports Insert, Update, and Delete operations and modifies records of the most common slowly changing dimension (SCD) cases in one of the following ways:
  • SCD1: Delta tables do not retain history.
  • SCD2: Delta tables retain history at the row level.
  • SCD3: Delta tables retain history at the column level.

SCD1

The following lists the properties in an SCD1 MERGE condition where Delta tables do not retain historical data.

Properties

  1. You must set at least one action out of update, delete or insert.
  2. A merge operation fails if multiple rows of the source DataFrame matches and the merge attempts to update the same rows of the target Delta table. You can place deduplicate gems before your Target gem if you expect duplicate rows in your Source gem.
When possible, provide predicates on the partition columns for a partitioned Delta table because predicates can significantly speed up the operations.

Example

Assume you have the following customers table: Initial customer table And, you want to make the following updates to the table: Customer table updates The following shows the output and configurations for an SCD1 merge:

Compiled code

To see the compiled code of your project, switch to the Code view in the project header.

SCD2

The following lists the properties in an SCD2 MERGE condition where Delta tables retain history at the row level.

Parameters

Example

Continuing from the SCD1 example, you can use the Delta log to capture the historical customer_zip_code at the row-level. The following shows the output and configurations for an SCD2 merge:

Compiled code

To see the compiled code of your project, switch to the Code view in the project header.

SCD3

Continuing from the SCD2 example, you use the Delta log to capture the historical customer_zip_code at the column-level. The following shows the output and configurations for an SCD3 merge:
To see the compiled code of your project, switch to the Code view in the project header.
To learn more about how Prophecy uses the Delta file type, see Prophecy with Delta — making data lakehouses easier.