JingsongLi commented on code in PR #1405:
URL: https://github.com/apache/paimon-rust/pull/1405#discussion_r4665698369


##########
crates/paimon/src/arrow/format/parquet.rs:
##########
@@ -932,7 +932,66 @@ fn variant_metadata_child(children: &arrow_schema::Fields) 
-> Option<usize> {
     })
 }
 
-/// File schema with `metadata: Dictionary(Int32, Binary)` for Variant columns 
read for extraction.
+/// Keep Variant metadata dictionary-encoded for extraction and shredded full 
reads,
+/// including Variant fields inside logical ROW columns.
+fn dictionary_variant_metadata_field(
+    field: &arrow_schema::FieldRef,
+    read_type: &DataType,
+) -> Option<arrow_schema::FieldRef> {
+    let arrow_schema::DataType::Struct(children) = field.data_type() else {
+        return None;
+    };
+    let variant = crate::spec::is_variant_extraction_row_type(read_type)
+        || (matches!(read_type, DataType::Variant(_))
+            && children.iter().any(|child| child.name() == "typed_value"));
+    if variant {
+        let metadata = variant_metadata_child(children)?;
+        let mut children = children
+            .iter()
+            .map(|child| child.as_ref().clone())
+            .collect::<Vec<_>>();
+        children[metadata] =
+            children[metadata]
+                .clone()
+                .with_data_type(arrow_schema::DataType::Dictionary(

Review Comment:
   **[P2] Preserve a fast full-read path when Parquet metadata spills to plain 
pages**
   
   This schema override requests Arrow dictionary output for every shredded 
metadata child. Arrow can reuse the Parquet keys for dictionary-encoded pages. 
After a plain page it materializes the bytes and builds a new Arrow dictionary. 
With a distinct directory of keys per row, the new compact rebuild also 
validates each source dictionary once even when the row is fully typed and has 
no residual.
   
   I wrote the fixtures with current `main` and ran `new_scan().plan()` through 
`new_read().to_arrow()` on the same persisted files with both builds. Output 
rows matched. For 512 rows of `{"age":27}` rotating through 18 wide 
dictionaries, the Parquet footer shows one dictionary-encoded data page and 56 
plain data pages. Median full scan time increased from **154.56 ms to 162.68 
ms** at the top level and from **156.39 ms to 159.99 ms** inside a nested ROW. 
With 512 distinct metadata dictionaries of roughly 9 KiB, one 
dictionary-encoded data page and four plain data pages, it increased from 
**14.04 ms to 18.16 ms** (**29%**). These are 11 warm local scans per build 
with Paimon, Parquet, Arrow Array and Arrow Buffer at `opt-level=2`.
   
   Please preserve a comparable full-read path for files with plain metadata 
pages and cover both repeated and distinct dictionaries in the scan benchmark. 
A dictionary-shaped Arrow output alone can also come from rebuilding a 
dictionary during the read.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to