Skip to content

[FEATURE] ParquetDiff: primary-key-keyed, tolerant Parquet table comparison - #9865

Merged
timosachsenberg merged 9 commits into
developfrom
feat/parquet-diff
Aug 5, 2026
Merged

timosachsenberg merged 9 commits into
developfrom
feat/parquet-diff

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Why

FuzzyDiff is string-based and cannot read Parquet. The established idiom for testing Parquet output — convert it back to text and FuzzyDiff that, as TOPP_IDMerger_idparquet does — has no route for the QPX psm/feature/pg views, because OpenMS has no QPX reader (ParquetConverter only handles the native feature/consensus Arrow format).

The consequence, from the audit in #9864: every QPX assertion in the test suite is a cmake -E sha256sum existence check. No value on the QPX exchange surface is compared against anything.

A byte comparison does not work either: two Parquet files holding the same logical result may legitimately differ in row order and in the low-order bits of float columns.

What

ParquetTableComparator matches rows by primary key, compares matched rows cell-by-cell with a numeric tolerance, and reports schema drift separately from value drift.

  • Tolerance mirrors FuzzyStringComparator — either ratio or absdiff has to be satisfied, so "zero vs. epsilon" stays expressible.
  • Recurses into list and struct, so a float nested in intensities: list<struct{label, intensity}> gets the same tolerance as a top-level float.
  • List-valued key columns are canonicalised by sorting, matching how QPX treats set-valued keys such as grouped_runs.
  • Duplicate primary keys are errors in their own right — a QPX primary key must be unique.
  • Two NaNs compare equal, which is what regression comparison wants.

For QPX files the key is derived from the file's own file_type metadata, so no flags are needed:

ParquetDiff -in1 ref/quantms.pg.parquet -in2 new/quantms.pg.parquet
ParquetDiff -in1 ref/quantms.feature.parquet -in2 new/quantms.feature.parquet -ratio 1.0001
ParquetDiff -in1 a.parquet -in2 b.parquet -pk sample_id run_id     # any table
ParquetDiff -in1 quantms.pg.parquet -schema pg                     # single-file schema check

Exit code is EXECUTION_OK when equal and INCOMPATIBLE_INPUT_DATA otherwise, so it drops into CTest the way FuzzyDiff does.

All Arrow/Parquet API use stays inside libOpenMS, per the constraint documented at ArrowIOHelpers.h:36-40, so the TOPP tool imports no Arrow symbols.

What is verified, and what is not

Verified: -fsyntax-only -Wall on the library class, the TOPP tool and the class test, using flags taken from an existing build. All clean.

Not verified — please treat as review-blocking:

  • No build or run. The 11 class-test sections assert specific counts (e.g. schema_errors.size() == 2) that were reasoned out, not executed. Those are the most likely thing to need adjustment on first run.

  • TOPP tests use the checked-in .idparquet psm tables, not QPX output: no QPX reference table is checked in anywhere. Pointing this at the QPX surface is the follow-up, and belongs to issue Quantification audit: OpenMS → QPX 1.1, the experimental-design axis, and the LFQ numeric pipeline #9864 Phase 0.1.

    -schema pg is largely redundant for OpenMS's own pg output: ProteinGroupArrowExport builds the table from QPXPgSchema::schema() (:828) and already Strict-validates against it at write time (:904), covering field count, names, type compatibility and nullability. The validation mode earns its place elsewhere — on files from other producers, on files after a round trip through qpx, on a file on disk rather than an in-memory table, and for primary-key uniqueness, which ArrowSchemaValidation does not check at all.

  • A value-regression TOPP test additionally needs a checked-in reference .parquet, which has to be generated from a build.

Adding the class test requires a cmake reconfigure before --build --target ParquetTableComparator_test will resolve.

Open design question

ParquetDiffResult::equal currently requires schema_errors to be empty, so an extra column always means "differ". That is right for regression testing but strict if you ever want to diff across schema versions — an -ignore_schema flag would relax it. Happy to add if reviewers prefer.

Relates to #9864.

🤖 Generated with Claude Code

https://claude.ai/code/session_0116KfSuJaXf4izEGg79PgM4

Summary by CodeRabbit

  • New Features
    • Added a command-line tool to compare Parquet tables or validate them against QPX schemas.
    • Supports primary-key matching, numeric tolerances, schema-only validation, ignored columns, configurable list ordering, verbosity/report limits, and QPX view/key resolution.
    • Produces detailed difference reports, including schema mismatches, missing/duplicate primary keys, and value mismatches (with NaN-aware numeric handling).
  • Tests
    • Added unit and integration coverage for comparisons, tolerances, ordering rules, schema-only mode, ignored columns, diagnostics limits, and QPX error cases.

…arison

FuzzyDiff is string-based and cannot read Parquet. The existing idiom for
testing Parquet output -- convert it back to a text format and FuzzyDiff that,
as TOPP_IDMerger_idparquet does -- has no route for the QPX psm/feature/pg
views, because OpenMS has no QPX reader. Consequently every QPX assertion in
the test suite is a `cmake -E sha256sum` existence check: no value on the QPX
exchange surface is compared against anything.

Two Parquet files holding the same logical result may legitimately differ in
row order and in the low-order bits of float columns, so neither a byte
comparison nor a text diff of a serialised form answers "is this the same
result?".

ParquetTableComparator matches rows by primary key, compares matched rows
cell-by-cell with a numeric tolerance, and reports schema drift separately
from value drift:

- tolerance mirrors FuzzyStringComparator -- either `ratio` or `absdiff` has
  to be satisfied, so "zero vs. epsilon" stays expressible
- the comparison recurses into list and struct values, so a float nested in
  `intensities: list<struct{label, intensity}>` gets the same tolerance as a
  top-level float
- list-valued key columns are canonicalised by sorting, matching how QPX
  treats set-valued keys such as `grouped_runs`
- duplicate primary keys are reported as errors in their own right, since a
  QPX primary key must be unique
- two NaNs compare equal, which is what regression comparison wants

`ParquetDiff -schema psm|feature|pg` checks a single file against the built-in
QPX schema in ArrowSchemaRegistry instead of comparing two files, reporting
missing/extra columns, wrong Arrow types and wrong nullability.

All Arrow/Parquet API use stays inside libOpenMS, per the constraint documented
in ArrowIOHelpers.h, so the TOPP tool imports no Arrow symbols.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0116KfSuJaXf4izEGg79PgM4
@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds ParquetTableComparator, Parquet comparison and QPX validation logic, the ParquetDiff TOPP tool, and test coverage for comparison rules, validation rules, and command behavior.

Changes

Parquet comparison workflow

Layer / File(s) Summary
Comparator contract and Parquet access
src/openms/include/OpenMS/FORMAT/ParquetTableComparator.h, src/openms/include/OpenMS/FORMAT/sources.cmake, src/openms/source/FORMAT/ParquetTableComparator.cpp, src/openms/source/FORMAT/sources.cmake
Defines comparison settings, results, public operations, and Parquet access helpers.
Table comparison and diagnostics
src/openms/source/FORMAT/ParquetTableComparator.cpp, src/tests/class_tests/openms/source/ParquetTableComparator_test.cpp, src/tests/class_tests/openms/executables.cmake
Compares schemas, keys, rows, nested values, lists, and numeric values. Tests cover tolerances, ordering, missing rows, duplicates, schema differences, ignored columns, NaN values, integer precision, and diagnostic limits.
QPX mapping and schema validation
src/openms/source/FORMAT/ParquetTableComparator.cpp, src/tests/class_tests/openms/source/ParquetTableComparator_test.cpp
Adds QPX file-type mappings, default primary keys, schema validation, and validation error tests.
ParquetDiff command integration
src/topp/ParquetDiff.cpp, src/topp/executables.cmake, src/openms/source/APPLICATIONS/ToolHandler.cpp, doc/doxygen/public/TOPP.doxygen, src/tests/topp/CMakeLists.txt
Adds command-line comparison and validation modes, result reporting, TOPP registration, documentation, and command tests.

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant ParquetDiff
  participant ParquetTableComparator
  participant ArrowTable
  User->>ParquetDiff: provide paths and options
  ParquetDiff->>ParquetTableComparator: compare or validate
  ParquetTableComparator->>ArrowTable: read Parquet data
  ArrowTable-->>ParquetTableComparator: return tables and schemas
  ParquetTableComparator-->>ParquetDiff: return result and diagnostics
  ParquetDiff-->>User: print report and exit status
Loading

Possibly related PRs

Poem

I sniffed the tables, byte by byte,
And checked the keys in morning light.
Lists and numbers held their place,
Then ParquetDiff kept the pace.
A bunny hops, the report is clear,
With QPX schemas checked right here.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: tolerant, primary-key-based Parquet table comparison through the new ParquetDiff feature.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/parquet-diff

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (7)
src/topp/ParquetDiff.cpp (2)

111-114: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the OpenMS logging stream for tool output.

Replace direct std::cout calls with OpenMS logging macros and replace std::endl with '\n'. Direct standard output bypasses the configured OpenMS logging path.

As per coding guidelines, “Use OpenMS logging macros and OpenMS::LogStream; do not write directly to std::cout or std::cerr. Prefer \n over std::endl.”

Also applies to: 157-181

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/topp/ParquetDiff.cpp` around lines 111 - 114, The output helper around
the verbose message loop should use OpenMS logging macros or OpenMS::LogStream
instead of direct std::cout writes. Update both the shown output block and the
additional output paths around the related code to route messages through the
configured OpenMS logging stream, replacing every std::endl with '\n' while
preserving the existing verbosity and message formatting.

Source: Coding guidelines


111-114: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Put control-flow braces on separate aligned lines.

Move the braces for the if and for blocks to their own aligned lines. This keeps the file consistent with the required C++ formatting rule.

As per coding guidelines, “braces on their own aligned lines; always use braces for blocks.”

Also applies to: 137-144

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/topp/ParquetDiff.cpp` around lines 111 - 114, Update the control-flow
blocks in the messages-printing helper in ParquetDiff.cpp so the if and for
braces are placed on their own aligned lines, and ensure the same brace style is
applied to the other matching block around the second referenced section. Keep
the existing logic unchanged, but rewrite these control structures to always use
braces and align them consistently with the project’s C++ formatting rule.

Source: Coding guidelines

src/openms/source/FORMAT/ParquetTableComparator.cpp (3)

36-37: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use \n instead of std::endl in the log statements.

The same change applies to lines 45, 54 and 64.

♻️ Proposed change
         OPENMS_LOG_ERROR << "ParquetTableComparator: cannot open '" << filename
-                         << "': " << infile_result.status().ToString() << std::endl;
+                         << "': " << infile_result.status().ToString() << "\n";

As per coding guidelines: "Prefer \n over std::endl."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/source/FORMAT/ParquetTableComparator.cpp` around lines 36 - 37,
Update the error log statements in ParquetTableComparator to use "\n" instead of
std::endl, including the logs at all referenced locations, while preserving
their existing messages and formatting.

Source: Coding guidelines


501-518: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Make the reported message order deterministic.

keys_1 and keys_2 are std::unordered_map, so the iteration order varies with the hash implementation and the insertion history. The key-difference and value-difference messages therefore appear in an arbitrary order, and max_reported keeps an arbitrary subset. Two identical runs can produce different output.

Sort the keys before reporting, or sort each message vector before returning the result. <map> is already included.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/source/FORMAT/ParquetTableComparator.cpp` around lines 501 - 518,
Make reporting deterministic in the key-difference loops around keys_1 and
keys_2 by ordering the keys before calling report_. Preserve the existing
message text, suppression behavior, and max_reported limit, ensuring the same
sorted order determines which messages are retained.

251-261: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Precompute the sort keys instead of recomputing them per comparison.

key_of calls GetScalar and canonicalString_ on every comparator invocation. Each stable_sort therefore materialises O(n log n) scalars and strings per list cell, and canonicalString_ recurses for nested lists. Build the keys once, then sort the index vectors by the cached keys.

♻️ Proposed change
         if (settings.unordered_lists)
         {
-          auto key_of = [](const std::shared_ptr<arrow::Array>& arr, int64_t i) {
-            auto s = arr->GetScalar(i);
-            return s.ok() ? canonicalString_(*s) : std::string("<err>");
-          };
+          auto keys_of = [](const std::shared_ptr<arrow::Array>& arr) {
+            std::vector<std::string> out;
+            out.reserve(static_cast<size_t>(arr->length()));
+            for (int64_t i = 0; i < arr->length(); ++i)
+            {
+              auto s = arr->GetScalar(i);
+              out.push_back(s.ok() ? canonicalString_(*s) : std::string("<err>"));
+            }
+            return out;
+          };
+          const std::vector<std::string> keys_a = keys_of(av_list);
+          const std::vector<std::string> keys_b = keys_of(bv_list);
           std::stable_sort(order_a.begin(), order_a.end(),
-                           [&](int64_t l, int64_t r) { return key_of(av_list, l) < key_of(av_list, r); });
+                           [&](int64_t l, int64_t r) { return keys_a[l] < keys_a[r]; });
           std::stable_sort(order_b.begin(), order_b.end(),
-                           [&](int64_t l, int64_t r) { return key_of(bv_list, l) < key_of(bv_list, r); });
+                           [&](int64_t l, int64_t r) { return keys_b[l] < keys_b[r]; });
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/source/FORMAT/ParquetTableComparator.cpp` around lines 251 - 261,
Update the unordered-list branch around key_of and the two stable_sort calls to
precompute one canonical sort-key vector for av_list and one for bv_list,
indexed by each element position. Have both comparators reuse the cached keys
while sorting order_a and order_b, preserving stable ordering and the existing
"<err>" fallback for failed GetScalar calls.
src/tests/class_tests/openms/source/ParquetTableComparator_test.cpp (2)

76-230: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for schema_only and max_reported.

The sections cover tolerances, keys, lists, ignored columns and schema differences. Two public settings remain untested: schema_only, which must skip key building and value comparison, and max_reported, which must cap each message vector and increment ParquetDiffResult::suppressed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tests/class_tests/openms/source/ParquetTableComparator_test.cpp` around
lines 76 - 230, Add tests near the existing ParquetTableComparator::compare
coverage for both public settings: verify schema_only reports schema differences
without requiring key building or value comparison, and verify max_reported
limits each diagnostic vector to the configured count while
ParquetDiffResult::suppressed records omitted messages. Use intentionally
differing tables that exercise key, schema, and value diagnostics, and assert
the resulting equal status and counters.

60-66: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use NEW_TMP_FILE and assert writeTableToParquet succeeds.

ArrowIOHelpers::writeTableToParquet returns a bool, so this helper should expose or assert that result rather than ignoring write failures. Pass the output path into the helper, created per section with NEW_TMP_FILE or NEW_TMP_FILE_EXT, and remove the manual File::remove cleanup.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tests/class_tests/openms/source/ParquetTableComparator_test.cpp` around
lines 60 - 66, Update the ParquetTableComparator_test writeTemp helper so it
takes a per-section temp path from NEW_TMP_FILE or NEW_TMP_FILE_EXT instead of
building and deleting files manually, and assert or otherwise check the bool
returned by ArrowIOHelpers::writeTableToParquet in writeTemp. Keep the existing
call sites in the ParquetTableComparator tests aligned with the new helper
signature, and remove the explicit File::remove cleanup once the
framework-managed temp file is used.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/openms/source/FORMAT/ParquetTableComparator.cpp`:
- Around line 520-535: Update the column-selection logic in the comparator
around the columns and column_names construction to exclude fields used as key
columns from value comparison. Reuse the existing key-column configuration or
symbol used by canonicalString_ so list-valued keys are not compared again with
sequence semantics, while retaining the current filtering for ignored, missing,
and type-incompatible columns.

In `@src/topp/executables.cmake`:
- Line 166: Add a TOPP-level test suite for ParquetDiff to cover the executable
end to end, including equal files, different files, QPX schema validation, and
the documented exit codes. Use the existing ParquetDiff registration in
executables.cmake and the corresponding ToolHandler/ registerOptionsAndFlags_
entry points as the target behavior to exercise, and make sure the new test
verifies both success and failure paths rather than only basic invocation.

In `@src/topp/ParquetDiff.cpp`:
- Around line 132-148: Update ParquetTableComparator::validate to skip
buildKeys_ when settings.schema_only is true, while preserving key construction
for normal validation. Ensure schema-only validation does not report
duplicate-key errors and follows the ParquetDiffSettings contract.

---

Nitpick comments:
In `@src/openms/source/FORMAT/ParquetTableComparator.cpp`:
- Around line 36-37: Update the error log statements in ParquetTableComparator
to use "\n" instead of std::endl, including the logs at all referenced
locations, while preserving their existing messages and formatting.
- Around line 501-518: Make reporting deterministic in the key-difference loops
around keys_1 and keys_2 by ordering the keys before calling report_. Preserve
the existing message text, suppression behavior, and max_reported limit,
ensuring the same sorted order determines which messages are retained.
- Around line 251-261: Update the unordered-list branch around key_of and the
two stable_sort calls to precompute one canonical sort-key vector for av_list
and one for bv_list, indexed by each element position. Have both comparators
reuse the cached keys while sorting order_a and order_b, preserving stable
ordering and the existing "<err>" fallback for failed GetScalar calls.

In `@src/tests/class_tests/openms/source/ParquetTableComparator_test.cpp`:
- Around line 76-230: Add tests near the existing
ParquetTableComparator::compare coverage for both public settings: verify
schema_only reports schema differences without requiring key building or value
comparison, and verify max_reported limits each diagnostic vector to the
configured count while ParquetDiffResult::suppressed records omitted messages.
Use intentionally differing tables that exercise key, schema, and value
diagnostics, and assert the resulting equal status and counters.
- Around line 60-66: Update the ParquetTableComparator_test writeTemp helper so
it takes a per-section temp path from NEW_TMP_FILE or NEW_TMP_FILE_EXT instead
of building and deleting files manually, and assert or otherwise check the bool
returned by ArrowIOHelpers::writeTableToParquet in writeTemp. Keep the existing
call sites in the ParquetTableComparator tests aligned with the new helper
signature, and remove the explicit File::remove cleanup once the
framework-managed temp file is used.

In `@src/topp/ParquetDiff.cpp`:
- Around line 111-114: The output helper around the verbose message loop should
use OpenMS logging macros or OpenMS::LogStream instead of direct std::cout
writes. Update both the shown output block and the additional output paths
around the related code to route messages through the configured OpenMS logging
stream, replacing every std::endl with '\n' while preserving the existing
verbosity and message formatting.
- Around line 111-114: Update the control-flow blocks in the messages-printing
helper in ParquetDiff.cpp so the if and for braces are placed on their own
aligned lines, and ensure the same brace style is applied to the other matching
block around the second referenced section. Keep the existing logic unchanged,
but rewrite these control structures to always use braces and align them
consistently with the project’s C++ formatting rule.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c94ad4b-fc27-497e-b1ac-a481538555aa

📥 Commits

Reviewing files that changed from the base of the PR and between 240cc58 and bd05dc4.

📒 Files selected for processing (8)
  • src/openms/include/OpenMS/FORMAT/ParquetTableComparator.h
  • src/openms/include/OpenMS/FORMAT/sources.cmake
  • src/openms/source/FORMAT/ParquetTableComparator.cpp
  • src/openms/source/FORMAT/sources.cmake
  • src/tests/class_tests/openms/executables.cmake
  • src/tests/class_tests/openms/source/ParquetTableComparator_test.cpp
  • src/topp/ParquetDiff.cpp
  • src/topp/executables.cmake

set(TOPP_executables
${TOPP_executables}
ParquetConverter
ParquetDiff

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift

Add a TOPP-level test for ParquetDiff.

Add coverage for equal and different files, QPX schema validation, and the documented exit codes. The PR currently adds no TOPP-level test for this new executable.

As per coding guidelines, “New TOPP tools must be registered in src/topp/executables.cmake and ToolHandler.cpp, define options in registerOptionsAndFlags_(), and add relevant documentation and tests.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/topp/executables.cmake` at line 166, Add a TOPP-level test suite for
ParquetDiff to cover the executable end to end, including equal files, different
files, QPX schema validation, and the documented exit codes. Use the existing
ParquetDiff registration in executables.cmake and the corresponding ToolHandler/
registerOptionsAndFlags_ entry points as the target behavior to exercise, and
make sure the new test verifies both success and failure paths rather than only
basic invocation.

Source: Coding guidelines

Comment thread src/topp/ParquetDiff.cpp
Comment on lines +132 to +148
settings.schema_only = getFlag_("schema_only");
settings.unordered_lists = getFlag_("unordered_lists");
settings.max_reported = static_cast<Size>(getIntOption_("max_reported"));

// An empty StringList parameter arrives as one empty string; drop it.
for (const auto& c : getStringList_("pk"))
{
if (!c.empty()) { settings.primary_key.push_back(c); }
}
for (const auto& c : getStringList_("ignore"))
{
if (!c.empty()) { settings.ignore_columns.push_back(c); }
}

const ParquetDiffResult result = view.empty()
? ParquetTableComparator::compare(in1, in2, settings)
: ParquetTableComparator::validate(in1, view, settings);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Honor schema_only during QPX validation.

ParquetTableComparator::validate always calls buildKeys_. Therefore, -schema_only still reports duplicate-key errors in schema mode. Skip key building when settings.schema_only is true, as required by ParquetDiffSettings.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/topp/ParquetDiff.cpp` around lines 132 - 148, Update
ParquetTableComparator::validate to skip buildKeys_ when settings.schema_only is
true, while preserving key construction for normal validation. Ensure
schema-only validation does not report duplicate-key errors and follows the
ParquetDiffSettings contract.

timosachsenberg and others added 3 commits August 5, 2026 16:32
…ides

The Result-returning nullary FileReader::ReadTable() is newer than the Arrow
shipped in contrib: /contrib-build/include/parquet/arrow/reader.h declares only
the pointer-out overloads, so the wheel builds failed to compile.

Use the pointer-out form, which is what ConsensusMapArrowIO already does. It is
deprecated in recent Arrow, hence the -Wdeprecated-declarations warning on newer
system installs; portability across the supported Arrow range wins.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0116KfSuJaXf4izEGg79PgM4
Codex review of the branch found one false-equality path and several defects
that would have made the tool report "equal" or "differ" wrongly.

- cellAt_ indexed chunk(0) with a global row index. CombineChunks documents that
  "binary columns may be combined into multiple chunks" to avoid offset overflow,
  so a large string column can legitimately span several chunks; rows past the
  first chunk resolved to nullptr, and two nullptrs then compared EQUAL. Index
  the ChunkedArray globally and distinguish "null" from "unreadable".
- Primary-key columns were compared twice: canonically (order-insensitive) when
  forming the key, then again as ordinary value columns, so a reordered
  grouped_runs matched as a key but still produced a value error. Exclude key
  columns from the value comparison.
- The key encoding was not collision-proof: \x1f can occur in a UTF-8 string,
  ["a,b"] and ["a","b"] encoded identically, and a literal "<null>" collided
  with the null marker. Replaced with a length-prefixed, self-delimiting
  encoding.
- Duplicate keys collapsed to their first occurrence, so a multiplicity
  difference was never reported. Keys now map to all their rows.
- The tolerance applied only to floating-point cells; integers fell through to
  exact comparison despite the documented "numeric cell" contract. Integers are
  included, with a guard so two unequal 64-bit integers are never accepted on a
  zero difference caused by widening to double.
- Recursion covered LIST/LARGE_LIST only; MAP and FIXED_SIZE_LIST are also
  BaseListScalar, so nested floats there compared exactly.
- validate() checked nullability in one direction only.
- max_ratio was not updated when absdiff accepted first, contradicting its
  "largest ratio observed" contract.
- unordered_map iteration made which differences survive max_reported
  unspecified; use std::map.
- An unresolvable primary key was reported as schema drift rather than key drift.
- Register in ToolHandler and TOPP.doxygen, as adding-new-tool-to-topp.md requires.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0116KfSuJaXf4izEGg79PgM4
No QPX reference table is checked in, but the .idparquet bundles are: their
psms.parquet tables share a 29-column schema, (peptidoform, precursor_charge)
is unique in each, and the two files share no key at all. That is enough to
cover the tool end to end without generating a reference from a build:

- _1 self-comparison must report equal (read, schema, key and value paths)
- _2 schema-only mode on identical schemas
- _3 two different tables -> non-zero exit (WILL_FAIL)
- _4 a primary-key column that does not exist -> non-zero exit
- _5 neither 'in2' nor 'schema' given -> illegal parameters

The fixtures carry no QPX file_type metadata, so these also exercise the
explicit -pk path rather than metadata-derived key resolution.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0116KfSuJaXf4izEGg79PgM4

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/topp/ParquetDiff.cpp (3)

123-127: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reject simultaneous schema and in2 inputs.

When both options are supplied, view.empty() is false, so schema validation runs and in2 is silently ignored. Reject this conflicting invocation before the existing missing-in2 check.

Proposed fix
+    if (!view.empty() && !in2.empty())
+    {
+      writeLogError_("Error: 'in2' cannot be used with 'schema'.");
+      return ILLEGAL_PARAMETERS;
+    }
+
     if (view.empty() && in2.empty())
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/topp/ParquetDiff.cpp` around lines 123 - 127, In the input validation
flow of ParquetDiff, add a check before the existing `view.empty() &&
in2.empty()` condition to reject invocations where both `schema`/`view` and
`in2` are supplied. Log an appropriate error and return `ILLEGAL_PARAMETERS`;
preserve the existing missing-`in2` validation for cases where no schema is
provided.

107-114: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Route diagnostic output through OpenMS logging.

Lines 112-113 and 159-181 write directly to std::cout and flush with std::endl. TOPP tools must use OpenMS logging macros and OpenMS::LogStream. Prefer \n over std::endl.

Move printSection_ to the standard TOPP logging path, or make it use the appropriate OpenMS logging helper.

As per coding guidelines: src/topp/**/*.cpp must use OpenMS logging macros and OpenMS::LogStream; direct std::cout/std::cerr is not allowed, and \n is preferred over std::endl.

Also applies to: 157-181

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/topp/ParquetDiff.cpp` around lines 107 - 114, Replace direct
std::cout/std::endl output in printSection_ and the related diagnostic output
around the main reporting block with the standard OpenMS TOPP logging mechanism,
using OpenMS logging macros or OpenMS::LogStream as appropriate. Preserve the
existing verbosity and message formatting while using "\n" instead of std::endl,
and remove all direct std::cout/std::cerr usage in the affected paths.

Source: Coding guidelines


116-185: 📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift

Add a TOPP-level test for ParquetDiff.

The coding guidelines require tests for new TOPP tools. The PR objectives state that this change has no TOPP-level test or checked-in Parquet fixture. Add an integration test that covers equal results, differences, schema validation, conflicting options, tolerance handling, and exit codes.

As per coding guidelines: new TOPP tools must add relevant tests. The PR objectives state that no TOPP-level test or checked-in Parquet reference file is included.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/topp/ParquetDiff.cpp` around lines 116 - 185, Add a TOPP-level
integration test for ParquetDiff covering equal comparisons, detected
differences, schema validation, conflicting options, tolerance handling, and
expected exit codes; include any required checked-in Parquet fixtures and follow
existing TOPP test conventions without changing ParquetDiff behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/topp/ParquetDiff.cpp`:
- Around line 123-127: In the input validation flow of ParquetDiff, add a check
before the existing `view.empty() && in2.empty()` condition to reject
invocations where both `schema`/`view` and `in2` are supplied. Log an
appropriate error and return `ILLEGAL_PARAMETERS`; preserve the existing
missing-`in2` validation for cases where no schema is provided.
- Around line 107-114: Replace direct std::cout/std::endl output in
printSection_ and the related diagnostic output around the main reporting block
with the standard OpenMS TOPP logging mechanism, using OpenMS logging macros or
OpenMS::LogStream as appropriate. Preserve the existing verbosity and message
formatting while using "\n" instead of std::endl, and remove all direct
std::cout/std::cerr usage in the affected paths.
- Around line 116-185: Add a TOPP-level integration test for ParquetDiff
covering equal comparisons, detected differences, schema validation, conflicting
options, tolerance handling, and expected exit codes; include any required
checked-in Parquet fixtures and follow existing TOPP test conventions without
changing ParquetDiff behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 243dac2f-212c-4e45-9814-13fb346a12a1

📥 Commits

Reviewing files that changed from the base of the PR and between a58230f and 37057e3.

📒 Files selected for processing (4)
  • doc/doxygen/public/TOPP.doxygen
  • src/openms/source/APPLICATIONS/ToolHandler.cpp
  • src/openms/source/FORMAT/ParquetTableComparator.cpp
  • src/topp/ParquetDiff.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/openms/source/FORMAT/ParquetTableComparator.cpp

The collision-proof key encoding leaked into the human-facing output, so a
value difference read

  V6:P02769L2;V7:BSA1_F1V7:BSA1_F2V3:LFQ intensity: 1000 vs. 1100

The canonical form is an identity for matching, not a label. Build a readable
rendering alongside it and use that in every message:

  [anchor_protein=P02769, grouped_runs=[BSA1_F1, BSA1_F2], label=LFQ] intensity: ...

Also replace std::to_string for the absdiff/ratio report, which printed six
fixed decimals and turned small float differences into "absdiff 0.000000".

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0116KfSuJaXf4izEGg79PgM4
timosachsenberg and others added 2 commits August 5, 2026 17:06
- validate() now skips buildKeys_ under schema_only, which the settings
  contract defines as "schemas only". It was reporting duplicate-key errors in
  a mode that is documented not to build keys.
- The unordered-list branch built each element's canonical key inside the sort
  comparator, re-deriving it O(log n) times per element through a recursive
  function. Precompute one key vector per side.
- Class test uses NEW_TMP_FILE_EXT instead of hand-rolled temp paths, so the
  framework cleans up, and asserts the bool returned by writeTableToParquet
  rather than discarding it.
- Two uncovered public settings now have sections: schema_only (schema drift
  reported, no key building, no value comparison) and max_reported (each
  diagnostic capped, remainder counted in ParquetDiffResult::suppressed).

Not changed, with reasons:
- key columns are already excluded from value comparison (:635)
- key iteration is already deterministic: buildKeys_ returns std::map
- TOPP tests already exist (5, covering equal/differing/bad-key/bad-args);
  a QPX schema-validation test still needs a QPX fixture, which no checked-in
  file provides
- std::endl matches the codebase (409 uses vs 18 of "\n" in FORMAT)
- std::cout matches FuzzyStringComparator, whose default log destination is
  std::cout and which is the model this tool follows
- single-line braces are used throughout the Arrow sources

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0116KfSuJaXf4izEGg79PgM4
Second adversarial review found that the integer-collapse guard added in the
previous round introduced a regression, plus three defects that survived it.

- NaN equality was broken. The guard used Scalar::Equals as a tie-breaker, and
  Arrow defaults nans_equal_ = false (compare.h:135), so two NaNs -- which the
  tolerance contract says are equal -- were reported different. The guard is
  replaced by an exact integer difference, so floating point never reaches it.
- Wide integers did not honour tolerance. 2^53 and 2^53+1 collapse to the same
  double; the old guard rejected them even when absdiff allowed the difference.
  integerAbsDiff_ now subtracts in integer space (unsigned, so INT64_MIN cannot
  overflow) and the tolerance is re-evaluated on the exact value.
- Unordered numeric lists were paired by canonical TEXT. "10","20" against
  "9.99","20.1" sorts to pair 10 with 20.1, reporting a difference for lists
  that match within tolerance. Numeric elements now sort numerically.
- A nested unreadable element encoded as "E;" like any other, so two different
  unreadable rows could share a primary key and compare equal -- the same class
  of false equality as the original chunk-indexing bug. canonicalKey_ now
  propagates failure and buildKeys_ aborts with a diagnostic.

Also: max_ratio no longer discards an infinite observed ratio; KeyEntry::display
now comes from the first occurrence, matching the .front() row that is compared;
readTable_ comment no longer claims a single-chunk table.

Regression sections added for all three numeric fixes. The NaN one fails
against the previous commit.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0116KfSuJaXf4izEGg79PgM4

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/tests/topp/CMakeLists.txt`:
- Around line 201-206: Update the TOPP_ParquetDiff_2 test to compare the two
different same-schema fixtures with disjoint keys, rather than passing the same
psms.parquet path for both -in1 and -in2. Keep -schema_only enabled so the test
succeeds only when schema-only behavior is honored; a full comparison of these
inputs must fail.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 75938b38-c0ee-481b-a460-925a467f8d70

📥 Commits

Reviewing files that changed from the base of the PR and between 37057e3 and 3a33d98.

📒 Files selected for processing (3)
  • src/openms/source/FORMAT/ParquetTableComparator.cpp
  • src/tests/class_tests/openms/source/ParquetTableComparator_test.cpp
  • src/tests/topp/CMakeLists.txt
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/openms/source/FORMAT/ParquetTableComparator.cpp

Comment thread src/tests/topp/CMakeLists.txt Resolved
timosachsenberg and others added 2 commits August 5, 2026 17:38
First CI run of the class test failed. Cause: when two int64 values collapse to
the same double, numbersAcceptable_ returns early on `a == b` and leaves ratio
at its initial 1.0. The exact-integer override then re-evaluated

  ok = absdiff <= acceptable_absdiff || ratio <= acceptable_ratio

and `1.0 <= 1.0` accepted, so 2^53 vs 2^53+1 compared EQUAL under the default
tolerance -- the exact case the override was added to catch.

Recomputing the ratio does not fix it either: 1 + 1/2^53 rounds back to exactly
1.0. The ratio test is therefore applied without forming the ratio:

  absdiff <= (acceptable_ratio - 1) * min_magnitude

integerAbsDiff_ now also yields the smaller magnitude and whether the signs
match. The reported ratio is still computed for the message, where the rounding
is cosmetic.

Verified against every expectation in the test: 2^53 pair rejected by default
and accepted at absdiff 1; 100/101 rejected by default and accepted at ratio
1.02; NaN/NaN equal; NaN/number not equal at any tolerance.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0116KfSuJaXf4izEGg79PgM4
Windows build-and-test failed to LINK ParquetTableComparator_test with 51
unresolved externals -- arrow::Status, arrow::int64(), arrow::float32() and
friends, all dllimport, pulled in by instantiating arrow::NumericBuilder<T> in
the fixture builders.

The test executables link only OpenMS.lib and OpenSwathAlgo.lib. Every class
test that constructs Arrow objects directly already has an explicit
target_link_libraries entry; this one was missing. The comment above
QPXValueValidation_test describes the identical failure: on Linux/macOS the
symbols happen to be reachable through libOpenMS, on Windows they are dllimport
and the link fails -- which is exactly why the other four platforms were green.

Compilation was never the problem: build-wheels-windows, which compiles
libOpenMS with MSVC, passed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0116KfSuJaXf4izEGg79PgM4
@timosachsenberg
timosachsenberg merged commit afcbb5d into develop Aug 5, 2026
34 of 35 checks passed
@timosachsenberg
timosachsenberg deleted the feat/parquet-diff branch August 5, 2026 21:09
timosachsenberg added a commit that referenced this pull request Aug 7, 2026
Rebased onto the restructured 3.6.0 changelog (#9881), which moved from a
flat "General:" list to per-tool sections. Both entries were therefore
re-placed rather than replayed:

- ParquetDiff now sits under "TOPP tools: New tools:", alongside the other
  tools added in 3.6.0. The existing "Build System: Tests:" paragraph only
  referenced it in passing while announcing the QPX value references; the
  tool itself was never announced.
- The mzTab assay-grain change becomes a new "MzTabExporter:" subsection
  under "TOPP tools: Changes:", next to the ProteinQuantifier assay-grain
  entry it mirrors. MzTabExporter had no section at all.

Neither #9865 nor #9868 was cited anywhere in the changelog before this.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
timosachsenberg added a commit that referenced this pull request Sep 25, 2026
Rebased onto the restructured 3.6.0 changelog (#9881), which moved from a
flat "General:" list to per-tool sections. Both entries were therefore
re-placed rather than replayed:

- ParquetDiff now sits under "TOPP tools: New tools:", alongside the other
  tools added in 3.6.0. The existing "Build System: Tests:" paragraph only
  referenced it in passing while announcing the QPX value references; the
  tool itself was never announced.
- The mzTab assay-grain change becomes a new "MzTabExporter:" subsection
  under "TOPP tools: Changes:", next to the ProteinQuantifier assay-grain
  entry it mirrors. MzTabExporter had no section at all.

Neither #9865 nor #9868 was cited anywhere in the changelog before this.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
timosachsenberg added a commit that referenced this pull request Sep 25, 2026
* docs(CHANGELOG): add entries for #9865 and #9868

Rebased onto the restructured 3.6.0 changelog (#9881), which moved from a
flat "General:" list to per-tool sections. Both entries were therefore
re-placed rather than replayed:

- ParquetDiff now sits under "TOPP tools: New tools:", alongside the other
  tools added in 3.6.0. The existing "Build System: Tests:" paragraph only
  referenced it in passing while announcing the QPX value references; the
  tool itself was never announced.
- The mzTab assay-grain change becomes a new "MzTabExporter:" subsection
  under "TOPP tools: Changes:", next to the ProteinQuantifier assay-grain
  entry it mirrors. MzTabExporter had no section at all.

Neither #9865 nor #9868 was cited anywhere in the changelog before this.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx

* docs(CHANGELOG): ParquetDiff's exit code also depends on -min_rows

ParquetDiff returns EXECUTION_OK only when the comparison or schema check
passes and, if -min_rows is set, every input holds at least that many rows
(ParquetDiff.cpp:245); otherwise it returns INCOMPATIBLE_INPUT_DATA. Found by
CodeRabbit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YC1T2K9HQEUk2kQMZqC8h7

* docs(CHANGELOG): an unmatched MzTabExporter assay key gives null

applyAssayProteinQuantification (MzTab.cpp) warns and keeps the previous
abundance columns only for missing or unequal-length arrays, keys that
are not 1-based, and duplicated keys. An assay whose key the array lacks
gets a null abundance, without a warning. The entry said that a
mismatched key also warns and falls back. Found by CodeRabbit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YC1T2K9HQEUk2kQMZqC8h7

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant