fix: include parameter columns in CSV header when using --reference#869
Open
YoshKoz wants to merge 1 commit intosharkdp:masterfrom
Open
fix: include parameter columns in CSV header when using --reference#869YoshKoz wants to merge 1 commit intosharkdp:masterfrom
YoshKoz wants to merge 1 commit intosharkdp:masterfrom
Conversation
When --reference and --parameter-scan are combined, the reference command has no parameters. The CSV header was built from results.first(), which is the reference run, so no parameter_* columns were written. The subsequent parameterised rows contained more fields, causing: Error: CSV error: found record with 9 fields, but the previous record has 8 fields Fix: build the header from the first result that actually has parameters. Also fix the per-row serialisation to emit an empty string for each parameter column when a result (the reference) has no parameters, so every row has the same number of fields as the header. Adds a regression test (test_csv_with_reference) that covers this case. Fixes sharkdp#852 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #852
Problem
When
--referenceand--parameter-scanare combined, the CSV export fails:The root cause: the CSV header was built from
results.first(), which is the reference command. The reference has an emptyparametersmap, so noparameter_*columns were written to the header. The subsequent parameterised rows have one extra field per parameter, causing a field-count mismatch.Fix
Two changes to
src/export/csv.rs:Header: find the first result that actually has parameters (
results.iter().find(|r| !r.parameters.is_empty())) instead of blindly using.first().Data rows: iterate over the collected parameter names in order and look up each value with a fallback to empty string, so the reference row emits empty strings for parameter columns rather than zero fields.
Expected CSV output with
--reference "sleep 1" --parameter-scan secs 2 3:A regression test (
test_csv_with_reference) is included.