Skip to content

✨ feat(mq-lang): add native _csv_parse builtin using csv crate#1456

Merged
harehare merged 3 commits intomainfrom
feat/native-csv-parse
Mar 16, 2026
Merged

✨ feat(mq-lang): add native _csv_parse builtin using csv crate#1456
harehare merged 3 commits intomainfrom
feat/native-csv-parse

Conversation

@harehare
Copy link
Copy Markdown
Owner

No description provided.

Replace the pure-mq CSV parsing implementation in csv.mq with a native
Rust builtin `_csv_parse(csv, delimiter?, has_header?)` backed by the
`csv` crate.

- Signature: `_csv_parse(csv: String, delimiter?: String, has_header?: Boolean)`
  - `delimiter` defaults to `","` when omitted
  - `has_header` defaults to `false` when omitted
- Returns `Array<Dict>` when `has_header` is true (keys from header row)
- Returns `Array<Array>` when `has_header` is false
- Handles RFC 4180 quoting and escaping via the csv crate
- Update csv.mq wrappers (csv_parse, tsv_parse, psv_parse,
  csv_parse_with_delimiter) to delegate to the new builtin
- Add rstest parameterized tests covering no-header, with-header,
  quoted fields, custom delimiter (TSV), and invalid argument types
Copilot AI review requested due to automatic review settings March 16, 2026 14:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a native CSV parsing implementation to mq-lang by introducing an internal _csv_parse builtin backed by the Rust csv crate, and rewires the csv module to use it.

Changes:

  • Introduces _csv_parse builtin (1–3 args) that parses CSV/TSV/PSV into runtime arrays/dicts.
  • Updates crates/mq-lang/modules/csv.mq parse helpers to delegate to _csv_parse.
  • Adds the csv dependency to the workspace and mq-lang, plus new unit tests for _csv_parse.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
crates/mq-lang/src/eval/builtin.rs Adds _csv_parse builtin, hash registration, internal docs entry, and Rust unit tests.
crates/mq-lang/modules/csv.mq Switches module-level parsing functions to call the new builtin.
crates/mq-lang/Cargo.toml Adds csv as a crate dependency via workspace.
Cargo.toml Adds csv to workspace dependency versions.
Cargo.lock Locks csv + transitive deps.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 16, 2026

Merging this PR will improve performance by 50.97%

⚡ 3 improved benchmarks
✅ 26 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
eval_qualified_access_to_csv_module 11.4 ms 7.6 ms +50.97%
eval_variable_assignment_chain 948.8 µs 813.7 µs +16.6%
eval_csv_parse 11.3 ms 7.6 ms +49.54%

Comparing feat/native-csv-parse (340f145) with main (b8d308d)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (21cb04f) during the generation of this report, so b8d308d was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@harehare harehare merged commit 5d4b5a1 into main Mar 16, 2026
8 checks passed
@harehare harehare deleted the feat/native-csv-parse branch March 16, 2026 15:03
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.

2 participants