Skip to content

v_ahb_diff: cross-product on repeated (path, segment_code) produces extra rows #259

Description

@hf-mrdachner

Problem

When (path, segment_code) appears more than once within the same (pruefidentifikator, format_version) — e.g. two "Name des Kontoinhabers" D_3192 fields under PARTIN FII — the JOIN produces a cross-product: 2 old × 2 new = 4 diff rows instead of 2.

Example: PARTIN/37000, FV2510 → FV2604

Source data: 2 rows with D_3192 in each version (identical content).

Diff result:

diff_status old new
unchanged Name des Kontoinhabers Name des Kontoinhabers
modified Name des Kontoinhabers Name des Kontoinhabers
modified Name des Kontoinhabers Name des Kontoinhabers
unchanged Name des Kontoinhabers Name des Kontoinhabers

Expected: 2 unchanged rows. Actual: 2 unchanged + 2 false modified.

Affected cases (cnt=2 only, non-IFTSTA)

Nachricht Prüfis Segment Element
PARTIN 37000-37014 FII D_3192 (Name des Kontoinhabers)
MSCONS 13017 (segment_group) - (Referenzangaben)
PRICAT 27002 IMD -

Possible fix

Use ROW_NUMBER() OVER (PARTITION BY path, segment_code ORDER BY sort_path) as an additional tiebreaker in the JOIN to prevent cross-matching repeated elements.

Related: #256, #257, #258

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions