dwsmith1983 commented on code in PR #5654:
URL: https://github.com/apache/datafusion-comet/pull/5654#discussion_r4100241893


##########
native/core/src/parquet/schema_adapter.rs:
##########
@@ -1009,10 +1083,84 @@ impl PhysicalExprAdapterFactory for 
SparkPhysicalExprAdapterFactory {
             id_duplicate_roots,
             logical_folded,
             physical_folded,
+            nested_mappings,
+            root_id_ambiguities,
         }))
     }
 }
 
+/// Per logical field name, the mapping of its nested type against its 
physical counterpart,
+/// or the ambiguity Spark reports for it. Only fields whose type holds a 
struct are listed.
+type NestedMappings = HashMap<String, Result<Arc<FieldMapping>, SparkError>>;
+
+/// Per logical field name, the `_LEGACY_ERROR_TEMP_2094` ambiguity of a root 
field whose id
+/// matches more than one physical root field. Only ambiguous fields are 
listed.
+type RootIdAmbiguities = HashMap<String, SparkError>;
+
+fn type_holds_struct(data_type: &DataType) -> bool {
+    // The resolver and converter in `parquet_support` decide which types are 
lists through
+    // the same helper, so this walk descends into exactly the lists they map.
+    if let Some(element) = list_element_field(data_type) {
+        return type_holds_struct(element.data_type());
+    }
+    match data_type {
+        DataType::Struct(_) => true,
+        DataType::Map(f, _) => type_holds_struct(f.data_type()),
+        _ => false,
+    }
+}
+
+/// Resolve the nested mapping of every logical field whose type holds a 
struct and that has
+/// a physical counterpart. Returns `None` when no field qualifies, so flat 
reads build
+/// nothing here. Ambiguities are kept per field rather than raised: Spark 
validates only
+/// the fields a read requests, and `rewrite` sees which ones those are.
+fn resolve_nested_mappings(

Review Comment:
   Dropped, with `NestedMappings`, `type_holds_struct`, `field_mapping_for`, 
`check_opaque_decode` and the nested block in `rewrite`. `check_conversion` on 
main already runs `match_struct_fields` before every non-Variant cast, and with 
#6004 declining repeated requested ids an ambiguous read always gets a cast, so 
the nested duplicate-id error fires from there at plan time. The follow-up PR 
will build the once-per-file mapping where `CometCastColumnExpr` is built, from 
its own `(input_field, target_field)`.
   



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to