← Open source & case studiesDataComPy · Capital One Open Source
Upstream Architecture Adopted · PR #552Apache Spark · Spark Connect · Capital One · PySpark

Root cause identified.
Architecture adopted.

A Spark Connect compatibility defect in Capital One’s open-source DataComPy exposed an architectural flaw in expression selection. Diagnosed to process-global state assumptions, resolved via object-level runtime dispatch, and credited upstream in Capital One PR #552.

Ribbsaeter Systems DataComPy open-source engineering impact for Capital One

PR #552

Capital One upstream PR crediting @patrickswedish

PR #548

original architectural contribution & root cause fix

100%

passing CI on Capital One upstream repository

2 Runtimes

Classic PySpark & remote Spark Connect unified

01 · The Architectural Defect

Process-global state vs. runtime reality.

A Spark Connect compatibility defect in Capital One’s open-source DataComPy exposed a core architectural issue in how Spark expression APIs were selected.

When SparkSQLCompare received an already-created Connect session, expression selection relied on process-global Spark state rather than the actual DataFrame or Column being compared. As a result, classic Spark expressions could be constructed against Spark Connect DataFrames, causing runtime failures across distributed environments.

02 · Root Cause & Architectural Correction

The correct boundary is the object itself.

Root Cause: The legacy implementation assumed SPARK_CONNECT_MODE_ENABLED accurately represented the runtime environment. That assumption breaks down whenever a Connect session originates outside the library (e.g. in client code, microservices, or enterprise notebook kernels).

Architectural Correction: PR #548 authored by Patrick Ribbsaeter (@patrickswedish) introduced runtime dispatch based on the Spark object being operated on. Instead of trusting global process state, the system dynamically resolves the correct Spark functions and Window implementation from the actual DataFrame or Column object.

03 · Engineering Scope & Implementation

System-wide runtime isolation across comparators

  1. 01

    Identified process-global flag (SPARK_CONNECT_MODE_ENABLED) as root cause of Connect session expression mismatch.

  2. 02

    Engineered runtime-aware object dispatch resolving Spark functions and Window classes directly from actual DataFrame or Column objects.

  3. 03

    Unified compatibility boundary across array, boolean, numeric, and string comparator implementations.

  4. 04

    Covered SparkSQLCompare paths including merge behavior, duplicate handling, mismatch reporting, masking, caching, and window expressions.

  5. 05

    Upstream adoption by Capital One in PR #552 with explicit author credit to @patrickswedish / PR #548, full regression coverage, and green CI.

04 · Upstream Implementation & Credit

Capital One upstream PR #552.

Capital One maintainers integrated the object-level dispatch approach into upstream Pull Request #552, explicitly crediting Patrick Ribbsaeter (@patrickswedish / PR #548) for the dispatch approach and for identifying the process-global flag as the root cause.

Capital One PR #552 description:

“Approach proposed by @patrickswedish / #548 ... This architecture resolves the root cause in Spark Connect.”

Capital One then extended the PR with comprehensive regression coverage, Connect validation, CI integration, and compatibility fixes. PR #552 is open, mergeable, and passing all continuous integration pipelines.

05 · Why It Matters

Distributed systems in banking & fintech.

This pattern is critical to banking, fintech, and large-scale data engineering, where mission-critical reliability depends on predictable behavior across distributed systems, cloud runtimes, data reconciliation pipelines, and remote cluster execution.

Core Engineering Principle

Symptom → Execution Behavior → Architectural Assumption → Root Cause.

Fix the architectural cause, not only the visible failure.

Public Evidence & References

Verified open-source architecture impact recognized upstream by enterprise engineering teams.

Capital One Upstream PR #552 (Crediting @patrickswedish)

https://github.com/capitalone/datacompy/pull/552

Original Architectural Contribution PR #548

https://github.com/capitalone/datacompy/pull/548