Repository navigation
Let file writers choose a shredding schema for each Variant column - #12524
robert3005 wants to merge 6 commits into
Conversation
Give a policy the logical field path and the first nonempty unshredded batch. Reuse its decision for the column stream and let the encoding move matching values into typed children. Preserve incoming shredding and use the Variant layout to group consecutive compatible batches. Signed-off-by: Will Manning <will@spiraldb.com> Signed-off-by: Robert Kruszewski <github@robertk.io>
Let the policy request a bounded prefix of unshredded rows for each logical column. Replay buffered input in order so a small leading batch cannot determine the schema by itself. Fixed and path-based policies can choose a schema immediately. Signed-off-by: Robert Kruszewski <github@robertk.io>
Signed-off-by: Robert Kruszewski <github@robertk.io>
Develop replaced SizeScope with Backpressure. Sampled Variant chunks now reserve pending bytes through it. Signed-off-by: Robert Kruszewski <github@robertk.io>
roborev: Combined Review (
|
| if let Some(schema) = &schema { | ||
| variant = | ||
| VariantShred::try_new(variant.core_storage().clone(), schema.clone())? | ||
| .into_array() | ||
| .execute::<VariantArray>(&mut exec)?; | ||
| } |
There was a problem hiding this comment.
Medium: Once a schema is chosen, every unshredded chunk is passed to VariantShred::try_new, but only Parquet Variant registers a shred kernel. A constant Variant chunk canonicalizes to VariantArray(core = Constant), so VariantShred::execute fails with "has no kernel to shred it" and the whole write fails. Without a policy, the same input is written fine as an unshredded run.
// ParquetVariant chunk, then:
ConstantArray::new(Scalar::null(DType::Variant(Nullable)), n)Fix: Skip shredding for chunks whose storage has no shred kernel and send them to the unshredded fallback run, but still return errors from supported kernels. Add a round-trip test with FixedShredding/InferredShredding on the mixed stream above.
Signed-off-by: Robert Kruszewski <github@robertk.io>
Route unshredded Variant chunks without a VariantShred kernel to the fallback writer instead of failing the write, split sample EOF pointers lazily when buffering across chunks, and avoid inferring struct schemas over mixed scalar-and-object paths. Signed-off-by: Robert Kruszewski <github@robertk.io>
| let sample_eof = eof.split_off(); | ||
| let (sample, replay) = sample_prefix( | ||
| chunk, | ||
| rows, | ||
| stream, | ||
| sample_eof, | ||
| ctx.backpressure(), | ||
| &mut exec, | ||
| ) | ||
| .await?; | ||
| schema = policy.schema(column, &sample, &mut exec)?; | ||
| stream = replay; | ||
| continue; |
There was a problem hiding this comment.
High: Replayed sample chunks can join the open run with sequence IDs that come after that run's run_eof. sample_eof is split from eof only after the open run has taken its run_eof (line 176), and active stays set after the continue. A data segment collapse() then waits on an EOF that the same writer still holds, so the write probably deadlocks.
InferredShredding: [ConstantArray chunk, small ParquetVariant chunk, no common fields]
Existing tests don't cover this case.
Fix: Set active = None right after stream = replay; so replayed chunks start a new run, and add a regression test (leading constant or pre-shredded chunk, then a sample that reaches EOF with the same shredding) that checks the write finishes and the values round-trip.
Merging this PR will degrade performance by 15.4%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
The Variant layout stores shredded fields as separate columns, but the file writer can only keep the shredding that the input already has. This PR adds
WriteStrategyBuilder::with_variant_shredding, which takes aVariantShreddingPolicy. The writer asks the policy for a schema once per Variant column, with the column's field path. The policy can return a fixed schema, choose by path, or infer a schema from a bounded sample of rows. The sample can span input chunks, so a small first batch does not decide the schema alone. The writer then sends matching values to typed children through the newvortex.variant_shredfunction, and the storage encoding supplies the kernel. Parquet Variant has one kernel and an inferring policy. Input that is already shredded keeps its schema. If the edition does not allow the Variant layout, the policy is not used.Stacked on #12247
🤖 Generated with Claude Code