Handle scalar rows in CSV export - #224
Merged
Merged
Conversation
Add a value column for non-object CSV export rows so scalar and mixed query results keep their data while preserving existing object row behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mike Krüger (mkrueger)
requested review from
a team
and
a balanced review from Copilot
September 29, 2026 12:56
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The targeted implementation matches existing rendering behavior and is adequately documented and tested.
Review effort: Balanced
Findings: None
What changed in this PR
Adds CSV export support for scalar and mixed query results.
Changes:
- Writes non-object rows to a
valuecolumn. - Preserves object-only behavior and supports mixed rows.
- Adds documentation and comprehensive tests.
| File | Description |
|---|---|
docs/commands.md |
Documents scalar and mixed CSV output. |
ExportCommand.cs |
Adds scalar-value column generation. |
ExportCommandTests.cs |
Covers scalar, object, array, and mixed rows. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code Coverage OverviewLanguages: C# C# / code-coverage/dotnetThe overall line coverage in commit 754d082 in the Show a line coverage summary of the most impacted files.
Updated |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Vsevolod Kukol (sevoku)
approved these changes
Oct 2, 2026
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.

Problem
export --format=csvcollected CSV headers only from JSON object properties. Rows whose value is not an object (for exampleexport out.csv --format=csv --query="SELECT VALUE c.id FROM c", or numbers, booleans, null, arrays) were written as empty lines, while the command still reported the exported row count.Change
COSMOSDB_SHELL_CSV_SCALAR_COLUMNto name it, matching the existing scalar CSV rendering inCommandState.Table.cs(JsonElement.ToString()escaped withCommandState.EscapeCSV).docs/commands.mddescribes the empty default header, environment-variable override, and mixed results. Header collisions produce an error instead of combining values.Tests in
ExportCommandTestscover scalar strings that need escaping, numbers, booleans, null, arrays, object-only rows, mixed rows, and the default/environment-variable lookup.Examples
CSV output below uses the default
;separator.1. Scalar-only results
Container documents:
{"id":"1"},{"id":"2"},{"id":"3"}Before (no header, one empty line per row, while the command still reported 3 exported rows):
After:
2. Mixed object and scalar results
Container documents:
{"id":"1","address":{"city":"Berlin","zip":"10115"}} {"id":"2","address":"Hamburg; Hafen"} {"id":"3","address":{"city":"Munich"}}Before (the string address from document 2 was lost):
After (object columns are kept and the scalar goes into the empty-header column, escaped as usual):