﻿# cuDF joins: define missing-key treatment and row multiplicity before enriching features

Validate cuDF feature joins through explicit key, missing-value and cardinality contracts instead of assuming SQL-like null behavior or one output row per source record.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-cudf-join-missing-key-cardinality-contract/
Language: en

## State the relationship the join should represent

A feature pipeline enriches inference events with account metadata. Some account identifiers are missing, while the metadata table contains repeated snapshots. The [cuDF merge reference](https://docs.nvidia.com/cudf/26.10/cudf/api_docs/api/cudf.merge/) defines key-based join operations. Before selecting an operation, state whether the relationship is a single current account record, a time-specific snapshot or a collection of matching observations. A technically valid match does not establish which business relationship the resulting training row should represent.

## Do not import a missing-key assumption silently

The [pandas merge warning](https://pandas.pydata.org/docs/reference/api/pandas.merge.html) explicitly distinguishes its null-key matching from usual SQL behavior. This is a reason to validate the actual dataframe interface and version instead of assuming every database-style join has identical missing-key semantics. Define the desired application policy directly. An absent account identifier usually does not justify connecting arbitrary missing-identity rows to each other merely because their storage representation is the same.

## Detect missingness through the dataframe contract

The [cuDF missing-data guide](https://docs.nvidia.com/cudf/latest/cudf/missing-data/) explains missing-value detection and why ordinary equality comparisons are not a substitute. Inspect missing keys before the merge and route them according to the chosen policy, such as preserving them as unmatched observations. Avoid replacing every missing key with a shared valid identifier: that manufactures an equivalence class and can turn an intended absence of identity into a large accidental relationship among unrelated events.

## Validate multiplicity independently of missingness

Repeated valid keys on both sides can multiply output rows even after missing keys are handled. Establish uniqueness where the intended relationship requires it, or retain a deliberate temporal or composite key. Compare source coverage, matched identities and resulting multiplicity rather than checking only that the output is nonempty. Do not repair unexpected growth by dropping arbitrary duplicates afterward; that can discard legitimate events while hiding an unresolved definition of which metadata record should apply.

## Check meaning with adversarial identity cases

Include missing keys, repeated snapshots, unmatched valid keys and conflicting metadata in a small example with a manually specified expected relation. Compare outputs by explicit identities rather than incidental row position. The guides on [nullable feature contracts](/journal/data-guide-arrow-nullable-feature-contract/) and [logical table schemas](/journal/data-guide-frictionless-table-schema/) provide related context. Feature enrichment is correct when the resulting relationships match the declared dataset meaning, not simply when the GPU join completes and produces columns with the expected names.
