Canonicalizing ParquetVariant drops object fields stored only in a wrapper's value column
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start in encodings/parquet-variant/src/array.rs, especially logical_shredded_from_parquet_field and logical_shredded_from_parquet_typed_value; the reproduction test in the issue shows the failing value-only wrapper case. Check how core_storage_without_typed_value and the existing Parquet Variant tests handle wrapper value data. Done means canonicalizing the reproduced array preserves both object fields and matches the original logical values.
由索引模型根據 Issue 內容生成。
描述
This affects the ParquetVariant encoding in vortex-parquet-variant, when Vortex canonicalizes it to a VariantArray. Arrays whose shredded objects give every field a typed_value are not affected.
In Parquet Variant shredding, each object field in typed_value is a wrapper struct with value, typed_value, or both. When a wrapper has only value, the field's data lives in that wrapper's value column. logical_shredded_from_parquet_field in encodings/parquet-variant/src/array.rs returns None for such a wrapper, and logical_shredded_from_parquet_typed_value then leaves the field out of the canonical shredded struct. The canonical core storage from core_storage_without_typed_value keeps only the top-level value, so nothing else holds the field's bytes.
Expected: the canonical VariantArray has the same logical values as the ParquetVariant it came from. Actual: canonicalization drops every object field whose data is only in a wrapper's value column.
The test below reproduces this on develop at bb6c345. It shreds [{"a":"s1","b":"x"}, {"a":"s2","b":"y"}] with a as Int32, so a goes to the wrapper's value column. Then it rebuilds the a wrapper without its typed_value child. arrow-rs unshred_variant and execute_scalar on the ParquetVariant both return {a: "s1", b: "x"} for row 0. After execute::<Canonical>, row 0 is {b: "x"}, and the canonical shredded child is an empty struct. Row 1 loses a the same way.
One effect is in AllNonDistinct after #11976. The ParquetVariant kernel would see that two arrays differing only in such a field are distinct. In a ChunkedArray the kernel does not apply, the accumulator canonicalizes each chunk, and the arrays would compare as equal. I have not run this part.
Reproduction test (add to the tests module in encodings/parquet-variant/src/array.rs)
/// Repro: an object field whose Parquet wrapper holds only `value` (no `typed_value`).
#[test]
fn repro_value_only_object_field_wrapper_survives_canonicalize() -> VortexResult<()> {
// `a` does not conform to Int32, so the shredder stores it in the wrapper's `value`.
let json: ArrowArrayRef = Arc::new(StringArray::from(vec![
Some(r#"{"a":"s1","b":"x"}"#),
Some(r#"{"a":"s2","b":"y"}"#),
]));
let shredding = ShreddedSchemaBuilder::new()
.with_path("a", &DataType::Int32)?
.build();
let shredded = shred_variant(&json_to_variant(&json)?, &shredding)?;
let storage = shredded.inner();
// Rebuild the `a` wrapper with only its `value` child.
let typed = storage
.column_by_name("typed_value")
.ok_or_else(|| vortex_err!("no typed_value"))?
.as_any()
.downcast_ref::<StructArray>()
.ok_or_else(|| vortex_err!("typed_value not struct"))?
.clone();
let a = typed
.column_by_name("a")
.ok_or_else(|| vortex_err!("no a"))?
.as_any()
.downcast_ref::<StructArray>()
.ok_or_else(|| vortex_err!("a not struct"))?
.clone();
let (_, a_value_field) = a.fields().find("value").ok_or_else(|| vortex_err!("no a.value"))?;
let a_value = a.column_by_name("value").ok_or_else(|| vortex_err!("no a.value"))?.clone();
let a_only_value = StructArray::try_new(
Fields::from(vec![a_value_field.clone()]),
vec![a_value],
a.nulls().cloned(),
)?;
let (_, a_field) = typed.fields().find("a").ok_or_else(|| vortex_err!("no a field"))?;
let new_typed = StructArray::try_new(
Fields::from(vec![Arc::new(Field::new(
"a",
a_only_value.data_type().clone(),
a_field.is_nullable(),
))]),
vec![Arc::new(a_only_value) as ArrowArrayRef],
typed.nulls().cloned(),
)?;
let mut fields = Vec::new();
let mut columns = Vec::new();
for (field, column) in storage.fields().iter().zip(storage.columns()) {
if field.name() == "typed_value" {
fields.push(Arc::new(Field::new(
"typed_value",
new_typed.data_type().clone(),
field.is_nullable(),
)));
columns.push(Arc::new(new_typed.clone()) as ArrowArrayRef);
} else {
fields.push(field.clone());
columns.push(column.clone());
}
}
let value_only_storage =
StructArray::try_new(Fields::from(fields), columns, storage.nulls().cloned())?;
let arrow_value_only = ArrowVariantArray::try_new(&value_only_storage)?;
let unshredded = parquet_variant_compute::unshred_variant(&arrow_value_only)?;
for i in 0..unshredded.len() {
eprintln!("arrow-rs unshredded row {i}: {:?}", unshredded.value(i));
}
let original = ParquetVariant::from_arrow_variant(&shredded, &SESSION.arrow())?;
let value_only = ParquetVariant::from_arrow_variant(&arrow_value_only, &SESSION.arrow())?;
let mut ctx = SESSION.create_execution_ctx();
let Canonical::Variant(canonical) = value_only.clone().execute::<Canonical>(&mut ctx)? else {
return Err(vortex_err!("expected canonical variant"));
};
eprintln!(
"canonical shredded dtype: {:?}",
canonical.shredded().map(|s| s.dtype().clone())
);
let canonical = canonical.into_array();
let mut mismatches = 0;
for idx in 0..original.len() {
let want = original.execute_scalar(idx, &mut ctx)?;
let pv = value_only.execute_scalar(idx, &mut ctx)?;
let got = canonical.execute_scalar(idx, &mut ctx)?;
eprintln!("row {idx}\n fully shredded: {want}\n value-only ParquetVariant: {pv}\n canonical of value-only: {got}");
if got != want {
mismatches += 1;
}
}
assert_eq!(mismatches, 0, "canonicalization changed row values");
Ok(())
}
🤖 Generated with Claude Code
- 主要語言
- Rust
- 星號
- 3.2k
- 分支
- 239
- 平均合併
- 1 天 4 小時
- 30 天內合併 PR
- 684
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
vortex-data/vortex 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 70/100
vortex-data/vortex#12633 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 77/100
vortex-data/vortex#12628 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 88/100
vortex-data/vortex#12491 ·
維護者通常 1 天內回覆
-
Fallible constructor for nested_case_when可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
vortex-data/vortex#11425 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 67/100
vortex-data/vortex#12635 ·
維護者通常 1 天內回覆
查看 vortex-data/vortex 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 83/100
valkey-io/valkey-glide#7975 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
marklauter/tsong#110 ·
-
docs enhancement
難度 2/5 1-3 小時 新手友好度 78/100
wasm-bindgen/wasm-bindgen#5503 · 1 則留言 ·
維護者通常 1 天內回覆
-
needs-triage
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆