Skip to main content

PySpark library for Slowly Changing Dimension Type 2 (SCD2) transformations

Project description

loadx

A PySpark library for Slowly Changing Dimension Type 2 (SCD2) transformations.

Tracks historical changes to dimensional data using valid/until date ranges, hash-based change detection, and active/delete flags.

Installation

pip install loadx

Quick start

from loadx import SCD2Loader

result_df = SCD2Loader.slowly_changing_dimension(
    source_df=df,
    business_keys=["employee_id"],
    snapshot_date="2024-01-01",
)

Incremental load

result_df = SCD2Loader.slowly_changing_dimension(
    source_df=new_df,
    business_keys=["employee_id"],
    snapshot_date="2024-02-01",
    target_df=existing_df,         # merge with existing history
    ignore_columns=["updated_at"],  # exclude from change detection
)

Output columns

Column Description
valid_from Date the record became active
valid_until Date the record was superseded (9999-12-31 = currently active)
active_flag True for the current version of a record
delete_flag True for records deleted from the source
latest_record_flag True for the most recent record per key
upsert_flag I (insert) or U (update) for downstream merge operations

Documentation

Full documentation at kamathramu87.github.io/loadx.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

loadx-0.1.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

loadx-0.1.1-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file loadx-0.1.1.tar.gz.

File metadata

  • Download URL: loadx-0.1.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for loadx-0.1.1.tar.gz
Algorithm Hash digest
SHA256 44ce018aabfc793dc47a6a532fbbab39d7968f7fd449380b53b304cf4522073b
MD5 671748e27201089d35d7fc2c110f4b13
BLAKE2b-256 b5784bd004d7a665463104661e7b0293b6f3024aabb2b1b12ed9836da3cefabd

See more details on using hashes here.

Provenance

The following attestation bundles were made for loadx-0.1.1.tar.gz:

Publisher: publish.yml on kamathramu87/loadx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file loadx-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: loadx-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for loadx-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1859c913821732b2e068dae813f9b36a88c90b4fe3a97ed7060f19c4a9520e41
MD5 704c89fd712ad9081c0625727fb459ec
BLAKE2b-256 c25e152b30a08a4dd445e0b84a2a9f9811ce26510272cbd4914d5f61fddcc066

See more details on using hashes here.

Provenance

The following attestation bundles were made for loadx-0.1.1-py3-none-any.whl:

Publisher: publish.yml on kamathramu87/loadx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page