Skip to content

Add convert to DataBytes and materialize for plain vectors of values - #2

Merged
quinnj merged 1 commit into
mainfrom
jq/convert-materialize-vectors
Sep 9, 2026
Merged

quinnj merged 1 commit into
mainfrom
jq/convert-materialize-vectors

Conversation

@quinnj

@quinnj quinnj commented Sep 9, 2026

Copy link
Copy Markdown
Member

Two gaps found while making MySQL.jl 2.0 return DataString/DataBytes values:

  • convert(DataBytes, ::AbstractVector{UInt8}) did not exist, so a Vector{DataBytes} (or Vector{Union{Missing, DataBytes}}) could not be built from byte vectors the way Vector{DataString} is built from strings. Added, together with the identity method for a DataBytes argument (no ambiguity with Base's array convert; the existing detect_ambiguities test covers it).
  • materialize applied only to StringVector/BytesVector columns. A plain Vector of values, such as a column a data source handed out, had no single call to copy every element out and detach it from the buffers the values reference. materialize now accepts AbstractVector{DataString}, AbstractVector{Union{Missing, DataString}}, and the DataBytes counterparts, returning Vector{String} / Vector{Union{String, Missing}} (or Vector{UInt8} variants), missing preserved.

Tests cover the conversions, the four materialize element types, and that a materialized copy survives the source buffer being overwritten. The README's API list mentions the new materialize inputs. Version bumped to 1.1.0 (new API); drop that commit hunk if you prefer to bump at release time.

🤖 Generated with Claude Code

- `convert(DataBytes, ::AbstractVector{UInt8})` (and the identity for a `DataBytes`), so
  `Vector{DataBytes}` and `Vector{Union{Missing, DataBytes}}` accept byte vectors the way
  `DataString` already accepts strings.
- `materialize` on a plain `Vector` of `DataString`/`DataBytes` values (with or without
  `missing`): copies every element out to an owned `String`/`Vector{UInt8}`, detaching it
  from the buffers the values reference. Until now it applied only to `StringVector` /
  `BytesVector` columns; a column a data source handed out (MySQL.jl 2.0 results, for
  example) had no way to be detached in one call.
- Version 1.1.0.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@quinnj
quinnj merged commit 9fd71dd into main Sep 9, 2026
9 checks passed
@quinnj
quinnj deleted the jq/convert-materialize-vectors branch September 9, 2026 16:58
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.

1 participant