Skip to content

feat: download query results as CSV#420

Open
shaunpatterson wants to merge 1 commit into
dgraph-io:mainfrom
shaunpatterson:sp/result-export-csv
Open

feat: download query results as CSV#420
shaunpatterson wants to merge 1 commit into
dgraph-io:mainfrom
shaunpatterson:sp/result-export-csv

Conversation

@shaunpatterson

Copy link
Copy Markdown
Contributor

What

Adds a Download CSV action to the frame toolbar (shown only for query frames with response data), exporting the current result as a spreadsheet-ready CSV named ratel-results-<YYYY-MM-DD-HHMM>.csv.

Flattening rules (lib/csvExport.js)

  • Each object in a top-level response block becomes one row; nested objects flatten to dot-notation columns (friend.name).
  • Arrays of scalars join with ; ; arrays of objects are JSON-stringified into the cell (no row explosion).
  • A __block column is added only when the response has multiple top-level blocks.
  • Header is the first-seen union of keys; RFC-4180 quoting (commas/quotes/newlines, doubled embedded quotes), CRLF line endings.

Testing

16 unit tests: nesting, array handling, multi-block, header union/order, quoting edge cases, download-link lifecycle (createObjectURL → click → revoke), no-op on empty data. npm run build passes.

Complements #411 (graph PNG/JSON export) on the tabular side.

🤖 Generated with Claude Code

Adds a Download CSV action to the frame results toolbar for query
frames with response data. Query responses are flattened into rows
(dot-notation for nested objects, '; '-joined scalar arrays,
JSON-stringified object arrays, __block column for multi-block
responses) and serialized as RFC-4180 CSV, downloaded as
ratel-results-<YYYY-MM-DD-HHMM>.csv.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@shaunpatterson shaunpatterson requested a review from a team as a code owner June 12, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant