Skip to content

[OpenSWATH] Make Parquet score exporter throw instead of abort on Arrow errors - #9778

Merged
timosachsenberg merged 1 commit into
OpenMS:developfrom
aliviahossain:openswath-parquet-exporter-throw-9739
Jul 24, 2026
Merged

timosachsenberg merged 1 commit into
OpenMS:developfrom
aliviahossain:openswath-parquet-exporter-throw-9739

Conversation

@aliviahossain

@aliviahossain aliviahossain commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Description:

@singjc , @jcharkow Please review:

OpenSwathParquetExporter finalized every Arrow builder with Finish().ValueOrDie(), which calls std::abort() on an Arrow error and kills the process. It was also inconsistent internally: Append() failures already threw, but finalization aborted.

This routes both appending and finalization through the shared ParquetFile::appendOrThrow() and ParquetFile::finishArray() helpers, so a failure now throws Exception::InvalidValue naming the column instead of aborting. That matches how OpenSwathOSWParquetWriter already behaves. The duplicate local appendOrThrow_ helper is removed.

Output schema and data are unchanged, so existing readers are unaffected.

Screenshot 2026-07-21 230136

Tested locally: OpenSwathParquetExporter_test and OpenSwathExport_test both pass.

The footer schema-version metadata and column naming are tracked separately, as discussed in the issue.

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

Closes #9739

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where Apache Arrow write errors could unexpectedly terminate the process during Parquet export.
    • Parquet export failures now produce recoverable, informative errors identifying the affected column.
    • Preserved the existing output schema and exported data format.

…rrow errors (OpenMS#9739)

The flat feature-score/transition-score Parquet exporter finalized every
Arrow array builder with Finish().ValueOrDie(), which calls std::abort() on
an Arrow error and terminates the process. This was also internally
inconsistent: builder Append() failures were already routed through a
throwing helper while finalization aborted.

Route both appending and finalization through the shared
ParquetFile::appendOrThrow() and ParquetFile::finishArray() helpers
(matching OpenSwathOSWParquetWriter), so an Arrow failure throws
Exception::InvalidValue naming the offending column instead of aborting.
The duplicate local appendOrThrow_ helper is removed. Output schema and
data are unchanged.
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

OpenSwathParquetExporter now uses shared ParquetFile helpers for Arrow appends and array finalization, converting write failures into Exception::InvalidValue errors while preserving the existing schema and data output.

Changes

OpenSWATH Parquet error handling

Layer / File(s) Summary
Shared throwing append paths
src/openms/source/ANALYSIS/OPENSWATH/OpenSwathParquetExporter.cpp
Required and optional feature and transition fields now append values or nulls through ParquetFile::appendOrThrow.
Throwing array finalization
src/openms/source/ANALYSIS/OPENSWATH/OpenSwathParquetExporter.cpp, CHANGELOG
Feature and transition score builders now use ParquetFile::finishArray, replacing Finish().ValueOrDie() and the duplicate local helper. The changelog records the change.

Possibly related PRs

  • OpenMS/OpenMS#9681: Adds round-trip tests covering the refactored feature and transition score export methods.

Suggested reviewers: cbielow, singjc

Poem

A rabbit found Arrow errors near,
And taught them how to reappear.
No sudden thumps, no process fright,
Just InvalidValue, clear and right.
The parquet path now hops along!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: making the OpenSWATH Parquet exporter throw on Arrow errors instead of aborting.
Linked Issues check ✅ Passed The PR fulfills the linked issue's error-handling objective by routing Arrow append and finish failures through throwing helpers.
Out of Scope Changes check ✅ Passed The changes stay within scope, focusing on exporter error handling and helper cleanup without unrelated feature work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

🧹 Nitpick comments (1)
src/openms/source/ANALYSIS/OPENSWATH/OpenSwathParquetExporter.cpp (1)

109-120: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Per-row column-name string is rebuilt on every row/column iteration.

column is concatenated fresh for every row × MS1/MS2 column, then .c_str() forces an extra implicit std::string reconstruction when passed into ParquetFile::appendOrThrow(const std::string&, ...). For large exports this adds avoidable allocations on the hot path.

⚡ Precompute column names once before the row loop
+    std::vector<std::string> ms1_columns(table.feature_ms1_column_names.size());
+    for (Size i = 0; i < ms1_columns.size(); ++i) ms1_columns[i] = "FEATURE_MS1_" + table.feature_ms1_column_names[i];
+    std::vector<std::string> ms2_columns(table.feature_ms2_column_names.size());
+    for (Size i = 0; i < ms2_columns.size(); ++i) ms2_columns[i] = "FEATURE_MS2_" + table.feature_ms2_column_names[i];
+
     for (const auto& row : table.rows)
     {
       ...
       for (Size i = 0; i < table.feature_ms1_column_names.size(); ++i)
       {
-        const std::string column = "FEATURE_MS1_" + table.feature_ms1_column_names[i];
-        if (i < row.feature_ms1_values.size()) ParquetFile::appendOrThrow(ms1_builders[i].Append(row.feature_ms1_values[i]), column.c_str());
-        else ParquetFile::appendOrThrow(ms1_builders[i].AppendNull(), column.c_str());
+        if (i < row.feature_ms1_values.size()) ParquetFile::appendOrThrow(ms1_builders[i].Append(row.feature_ms1_values[i]), ms1_columns[i]);
+        else ParquetFile::appendOrThrow(ms1_builders[i].AppendNull(), ms1_columns[i]);
       }
🤖 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/ANALYSIS/OPENSWATH/OpenSwathParquetExporter.cpp` around
lines 109 - 120, Precompute the prefixed MS1 and MS2 column-name strings once
before the row-processing loop, then reuse the cached names in both
appendOrThrow calls. Update the loops in OpenSwathParquetExporter to index those
cached names instead of constructing a new std::string for every row and column.
🤖 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.

Nitpick comments:
In `@src/openms/source/ANALYSIS/OPENSWATH/OpenSwathParquetExporter.cpp`:
- Around line 109-120: Precompute the prefixed MS1 and MS2 column-name strings
once before the row-processing loop, then reuse the cached names in both
appendOrThrow calls. Update the loops in OpenSwathParquetExporter to index those
cached names instead of constructing a new std::string for every row and column.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 353c2951-dad3-4584-8422-83737ea4c41c

📥 Commits

Reviewing files that changed from the base of the PR and between 3c02693 and 32b470a.

📒 Files selected for processing (2)
  • CHANGELOG
  • src/openms/source/ANALYSIS/OPENSWATH/OpenSwathParquetExporter.cpp

@singjc singjc 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.

Thanks, this looks good to me.

@aliviahossain

Copy link
Copy Markdown
Contributor Author

@timosachsenberg You may merge this PR now.

@timosachsenberg
timosachsenberg merged commit e7a4612 into OpenMS:develop Jul 24, 2026
39 of 41 checks passed
@timosachsenberg

Copy link
Copy Markdown
Contributor

Thanks!

timosachsenberg added a commit that referenced this pull request Jul 25, 2026
… fix (#9791)

#9790 (14 boundary/serialization/state-consistency fixes from the #9767
audit) had no changelog entry. The existing Arrow-abort entry cited only
the tracking issue #9739; #9778 is the PR that actually implemented and
merged that fix, so it's now credited alongside it.


Claude-Session: https://claude.ai/code/session_01J7SjScz96yXHb7HnBuezhk

Co-authored-by: Claude <[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.

Align the two OpenSWATH Parquet writers: schema versioning, error handling, and column naming

3 participants