Repository navigation
Extract from Variants in bulk and push variant_get into the scan - #11505
robert3005 wants to merge 16 commits into
Conversation
8fb436a to
6845a93
Compare
- vortex-datafusion converts `variant_get(variant, path, type)` to the Vortex expression, so that the scan extracts the path, and folds filter equalities into the scan projection. - `variant_get` brings chunked, masked and other lazy inputs to the Variant encodings before it falls back to extracting row by row. - A shredded Variant child holds the rest of a path. The rows that the shredded child does not hold are extracted from the core storage on their own and scattered back, so that the core storage is not read when none of them holds a value. - Parquet Variant storage extracts strings and integers from unshredded values in place, reads fixed-width integers with a single load, and resolves field names to ids once per metadata. - Add `decode_unshredded_storage`, which decodes the storage of an unshredded Variant once for many extractions. - Add the `variant_pack` expression, which packs core storage and a shredded child into a Variant. `variant_get` reads a shredded path from its shredded child without reading the core storage. - `CascadingCompressor` can compress the storage of Variant arrays with another compressor. The default BtrBlocks preset uses one that keeps the binary Zstd scheme, since unshredded values are opaque binary blobs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Robert Kruszewski <github@robertk.io>
The in-place extraction turned the whole column down at the first row whose value it could not read as is, such as a JSON null or an integer at a string path. The general kernel then extracted every row again. Such a value now converts with the `Variant` method that the general kernel converts it with, `as_string` or `as_int64`, and a value that does not convert is a null. Objects and arrays convert to neither, so they are null without being decoded. The extraction falls back to the general kernel only for bytes that do not decode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Robert Kruszewski <github@robertk.io>
The in-place extraction covered strings and 64-bit integers. A struct or a list target went to the general kernel, which builds an Arrow array of the storage and a `Variant` over every row. The extraction is now a tree of builders, one for each node of the target dtype. A struct reads the object at the path once and each of its fields from the object's field of the same name, so it extracts several paths in one pass. A list reads each element of the array at the path. A value that is not an object or an array is a null, as it is for the general kernel. Field names of every struct in the target resolve to dictionary ids once per metadata, as the names of the path do. Structs and lists are covered when their fields and elements are nullable and covered themselves. A struct without fields is left to the general kernel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Robert Kruszewski <github@robertk.io>
When the requested type was not the type of the shredded leaf, the Variant kernel extracted the path from the core storage. The core storage holds no value of a row that the shredded child holds, so all such rows were null. An INT extraction over the I64 leaf that inferred shredding writes, or a BIGINT extraction over an I32 leaf, returned only nulls. The typed values now convert to the requested type, as a single value converts in the general path: a value that does not convert is a null. The kernel reads the core storage only for the rows that the shredded child does not hold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Robert Kruszewski <github@robertk.io>
0a1d453 to
621fab9
Compare
|
Posted by Claude Opus 5.5 on Will's behalf. This is from a review of the open PR backlog. The bulk extraction and the
What stays is the extraction kernels and the DataFusion conversion, which is the change the description leads with. |
|
Posted by Claude Opus 5.5 on Will's behalf. @devin-ai-integration, Will withdraws my earlier request to move the BtrBlocks Zstd change for Variant storage into its own PR. Keep it in this PR, and do not open a separate PR for it. The other review points still stand. |
|
Posted by Claude Opus 5.5 on Will's behalf. @devin-ai-integration, Will withdraws my request to move
Will will ask Joe Isaacs to review it. |
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
Deduplicating scan projections by Vortex expression alone collapsed columns with different planned Arrow layouts (such as Utf8 and Utf8View), causing schema mismatches on output batches. Include the planned output DataType in the deduplication key. Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
…t_get Defer partially shredded struct/list extraction and remaining paths through shredded lists to scalar extraction, recursively cast Variant struct/list scalars, normalize nullable Variant list elements, and execute filtered shredded list/struct values before converting Parquet Variant metadata. Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com> Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
…ariant casts Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
…ariant nulls in casts Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
|
Posted by Claude Opus 5.5 on Will's behalf. @devin-ai-integration, please make these fixes in this PR, and nothing else:
Do not act on new Devin Review findings in this PR. Leave them as comments for Will. |
…hredded validity Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
|
Applied all three fixes in
Left the new Devin Review findings untouched as requested. |
Restore the Arrow export to develop's version. Exporting non-null constant Variants and shredded overrides is a gap that develop already has, and nothing in this PR produces such arrays, so it moves to its own PR. Canonicalize shredded lists from a ListArray, and give each element its row's metadata from the list offsets, as the Variant layout PR does. This replaces the special case for list views that share elements. Keep object fields whose shell has only a `value` column. The shredding spec stores such a field's value in its shell, not in the parent residual, so dropping it lost the value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Will Manning <will@spiraldb.com>
A Vortex cast does not convert numbers to Booleans, so variant_get returned null for a shredded number read as a Boolean, while the unshredded path follows Arrow and reads zero as false and other numbers as true. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Will Manning <will@spiraldb.com>
There was a problem hiding this comment.
Devin Review found 2 new potential issues.
6 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
The fallback that converts a shredded number to a Boolean took only a plain number. A partially shredded field holds its values as nested Variants, and the scalar path that converts unread values ended in a Vortex cast, so in both cases a number read as a Boolean was null, where Arrow's `Variant::as_boolean` returns whether it is not zero. `number_as_bool` now unwraps a Variant, and the scalar path falls back to it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Will Manning <will@spiraldb.com>
#11505 now converts only `try_variant_get` with a `$.` path to the Vortex `variant_get`, as datafusion-variant parses paths from `$` and raises an error from `variant_get` when a value does not cast. The stand-in that datafusion-bench registers was `variant_get` with bare paths, so its queries no longer pushed down. It is now `try_variant_get`, it takes paths from `$.`, and the DataFusion queries call it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Will Manning <will@spiraldb.com>
… Arrow does A canonicalized chunk of unshredded Variants pads the shredded child with nulls, so an extraction through a nested Variant child lost the values that only the core storage holds. Rows without the nested child now read the core storage, as rows without a typed leaf already did. The shredded and row-by-row paths also read strings as Booleans with the spellings that Arrow's Variant conversion accepts, so shredding a string field does not change what a Boolean extraction returns. Signed-off-by: Robert Kruszewski <github@robertk.io>
Signed-off-by: Robert Kruszewski <github@robertk.io>
Develop moved the scalar functions out of vortex-array into vortex-functions (#10762). The Variant layout was written before that move, so this ports it: `variant_shred` and its strict and union forms are registered by vortex-functions, the `variant_shred` expression is in `vortex_functions::expr`, and `decode_for_repeated_extraction` moves next to `variant_get`, because vortex-array cannot name `VariantGet`. It also drops a second copy of `element_metadata` in the Parquet Variant array, which the rebase onto #11505 left behind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Will Manning <will@spiraldb.com>
#11505 now converts only `try_variant_get` with a `$.` path to the Vortex `variant_get`, as datafusion-variant parses paths from `$` and raises an error from `variant_get` when a value does not cast. The stand-in that datafusion-bench registers was `variant_get` with bare paths, so its queries no longer pushed down. It is now `try_variant_get`, it takes paths from `$.`, and the DataFusion queries call it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Will Manning <will@spiraldb.com>
This changes how Vortex extracts paths from Variant columns: the
variant_getexpression, the Parquet Variant encoding and the DataFusion scan. The Arrow export of Variants is unchanged.Before, a query over a Variant column read the whole column, and DataFusion extracted each path row by row. After, vortex-datafusion converts
try_variant_get(variant, '$.a.b', type)to the Vortexvariant_get, so the scan extracts the path. Parquet Variant storage extracts scalars, structs and lists from unshredded values in place, and a shredded child answers its paths without reading the core storage. Only paths of plain object fields convert. Plainvariant_getstays in DataFusion, because datafusion-variant raises an error when a value does not cast, and the Vortex extraction returns null.It also adds the pieces that the Variant layout in the next PR uses: the
variant_packexpression anddecode_unshredded_storage. Canonical shredded storage now keeps object fields whose shell has only avaluecolumn, which it used to drop.Behaviour change: the default BtrBlocks preset now compresses Variant storage with Zstd, so files with Variant columns are written differently.
On 1M unshredded Bluesky rows (single thread), one path extracts in 38–69 ms. A struct of all five JSONBench paths extracts in one pass in 0.71 of the time of five separate extractions. These numbers are from the 16 Nov head.
This is the bottom of a stack: #11814 adds the Variant layout on top of it, and #11390 adds JSONBench on top of that.
🤖 Generated with Claude Code