Urgent.News

What's breaking now, across hundreds of outlets.

Tech

A two-row test that catches a broken CSV diff

A CSV comparison can pass every test until the same SKU appears at a second warehouse. This is the smallest regression case from the TallyRill warehouse example that exposes the problem. It takes two snapshots, two records per snapshot and one deliberately reversed sort order. The false six-unit drop CL-101 has 18 units at North and 12 at South. In the second snapshot South comes first. Pairing…

A CSV comparison test fails when the same stock keeping unit (SKU) appears in both warehouses. This issue is demonstrated in a small regression example from the TallyRill warehouse scenario. The test uses two snapshots, each containing two records for the SKU CL-101, with prices and stock levels changing. The issue occurs when pairing by row number, as North's 18 units are paired with South's 12 units.

Looking up only the SKU loses track of the position if the map keeps just one value per key. The actual change at North is from 18 units to 15, and its price increased from 34.00 to 36.00.

To verify the comparison, an executable test is defined using a function called `by_position`. This function creates a dictionary where the keys are tuples containing the SKU and depot, and the values are tuples of stock and price. The function checks for missing or duplicate keys and raises an error if any are found.

Before and after the comparison, the keys and values in the dictionary are compared to ensure they match. Any differences are stored in a `changes` dictionary, which should contain only the changed records.

In the full eight-row example, the key sets differ between the old and new snapshots. Keys present only in the old snapshot represent removals, while keys present only in the new snapshot represent additions. Comparing field values only in the intersection of the two snapshots preserves the text when leading zeros belong to identifiers. The test checks the number of records and fields that were changed, with North being responsible for two of the changes. One record was added, one removed, and four stayed the same.

An additional regression test is suggested, which involves reordering both snapshots without changing any fields. In this case, the edit count should be zero. Another test involves duplicating a full key to verify that the comparison stops rather than silently discarding one record.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

DYPE on a Flux-Krea base: direct 4K generation instead of a tiled upscale

DYPE lets a Flux-family model generate at very high resolution directly - 4K-class - while keeping both overall structure and local detail consistent.

  • DYPE enables direct 4K generation without tiled upscale
  • Krea, a Flux 2.0-like model, preserves structure and details
  • DYPE avoids tiling seams but requires heavy VRAM and time

Google Preannounces December 2026 Core Update With Focus on Complex Queries

Google has preannounced a December 2026 core update that it says will make multiple improvements to how its Search systems understand and rank relevant content.

  • Google plans December 2026 core update to improve complex query handling
  • Update aims to enhance personalized results for enabled users
  • Focus on extended, intricate questions with multiple constraints

More from Tuesday 24 November →