Repository navigation
[FEATURE] ParquetDiff: primary-key-keyed, tolerant Parquet table comparison - #9865
Conversation
…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
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds ChangesParquet comparison workflow
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
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (7)
src/topp/ParquetDiff.cpp (2)
111-114: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the OpenMS logging stream for tool output.
Replace direct
std::coutcalls with OpenMS logging macros and replacestd::endlwith'\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 tostd::coutorstd::cerr. Prefer\noverstd::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 winPut control-flow braces on separate aligned lines.
Move the braces for the
ifandforblocks 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 valueUse
\ninstead ofstd::endlin 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
\noverstd::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 winMake the reported message order deterministic.
keys_1andkeys_2arestd::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, andmax_reportedkeeps 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 winPrecompute the sort keys instead of recomputing them per comparison.
key_ofcallsGetScalarandcanonicalString_on every comparator invocation. Eachstable_sorttherefore materialises O(n log n) scalars and strings per list cell, andcanonicalString_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 winAdd coverage for
schema_onlyandmax_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, andmax_reported, which must cap each message vector and incrementParquetDiffResult::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 winUse
NEW_TMP_FILEand assertwriteTableToParquetsucceeds.
ArrowIOHelpers::writeTableToParquetreturns abool, so this helper should expose or assert that result rather than ignoring write failures. Pass the output path into the helper, created per section withNEW_TMP_FILEorNEW_TMP_FILE_EXT, and remove the manualFile::removecleanup.🤖 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
📒 Files selected for processing (8)
src/openms/include/OpenMS/FORMAT/ParquetTableComparator.hsrc/openms/include/OpenMS/FORMAT/sources.cmakesrc/openms/source/FORMAT/ParquetTableComparator.cppsrc/openms/source/FORMAT/sources.cmakesrc/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/ParquetTableComparator_test.cppsrc/topp/ParquetDiff.cppsrc/topp/executables.cmake
| set(TOPP_executables | ||
| ${TOPP_executables} | ||
| ParquetConverter | ||
| ParquetDiff |
There was a problem hiding this comment.
📐 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
| 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); |
There was a problem hiding this comment.
🎯 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.
…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
There was a problem hiding this comment.
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 winReject simultaneous
schemaandin2inputs.When both options are supplied,
view.empty()is false, so schema validation runs andin2is silently ignored. Reject this conflicting invocation before the existing missing-in2check.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 winRoute diagnostic output through OpenMS logging.
Lines 112-113 and 159-181 write directly to
std::coutand flush withstd::endl. TOPP tools must use OpenMS logging macros andOpenMS::LogStream. Prefer\noverstd::endl.Move
printSection_to the standard TOPP logging path, or make it use the appropriate OpenMS logging helper.As per coding guidelines:
src/topp/**/*.cppmust use OpenMS logging macros andOpenMS::LogStream; directstd::cout/std::cerris not allowed, and\nis preferred overstd::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 liftAdd 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
📒 Files selected for processing (4)
doc/doxygen/public/TOPP.doxygensrc/openms/source/APPLICATIONS/ToolHandler.cppsrc/openms/source/FORMAT/ParquetTableComparator.cppsrc/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
- 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
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
src/openms/source/FORMAT/ParquetTableComparator.cppsrc/tests/class_tests/openms/source/ParquetTableComparator_test.cppsrc/tests/topp/CMakeLists.txt
🚧 Files skipped from review as they are similar to previous changes (1)
- src/openms/source/FORMAT/ParquetTableComparator.cpp
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
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
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): 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]>
Why
FuzzyDiffis string-based and cannot read Parquet. The established idiom for testing Parquet output — convert it back to text andFuzzyDiffthat, asTOPP_IDMerger_idparquetdoes — has no route for the QPXpsm/feature/pgviews, because OpenMS has no QPX reader (ParquetConverteronly 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 sha256sumexistence 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
ParquetTableComparatormatches rows by primary key, compares matched rows cell-by-cell with a numeric tolerance, and reports schema drift separately from value drift.FuzzyStringComparator— eitherratioorabsdiffhas to be satisfied, so "zero vs. epsilon" stays expressible.listandstruct, so a float nested inintensities: list<struct{label, intensity}>gets the same tolerance as a top-level float.grouped_runs.For QPX files the key is derived from the file's own
file_typemetadata, so no flags are needed:Exit code is
EXECUTION_OKwhen equal andINCOMPATIBLE_INPUT_DATAotherwise, so it drops into CTest the wayFuzzyDiffdoes.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 -Wallon 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
.idparquetpsm 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 pgis largely redundant for OpenMS's own pg output:ProteinGroupArrowExportbuilds the table fromQPXPgSchema::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, whichArrowSchemaValidationdoes 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
cmakereconfigure before--build --target ParquetTableComparator_testwill resolve.Open design question
ParquetDiffResult::equalcurrently requiresschema_errorsto 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_schemaflag 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