AdamGS commented on code in PR #27259:
URL: https://github.com/apache/datafusion/pull/27259#discussion_r4538508904
##########
datafusion/datasource-parquet/src/projection_read_plan.rs:
##########
@@ -223,21 +223,40 @@ impl<'schema> PushdownChecker<'schema> {
///
/// - `column_name` = `"s"` (the root struct column)
/// - `file_schema.index_of("s")` returns `1`
- /// - We push `1` into `required_columns`
+ /// - We record `1` and `["foo"]` in `struct_field_accesses`
/// - Return `None` (no issue — traversal continues in the caller)
///
/// If `"s"` is not in the file schema (e.g. a projected-away column), we
set
/// `projected_columns = true` and return `Jump` to skip the subtree.
fn check_struct_field_column(
&mut self,
column_name: &str,
- field_path: Vec<String>,
+ mut field_path: Vec<String>,
) -> Option<TreeNodeRecursion> {
let Ok(idx) = self.file_schema.index_of(column_name) else {
self.projected_columns = true;
return Some(TreeNodeRecursion::Jump);
};
+ let root_type = self.file_schema.field(idx).data_type();
+ let struct_prefix_len = field_path
+ .iter()
+ .scan(root_type, |data_type, name| {
+ let DataType::Struct(fields) = *data_type else {
+ return None;
+ };
+ let (_, field) = fields.find(name)?;
+ *data_type = field.data_type();
+ Some(())
+ })
+ .count();
+
+ // Drop runtime lookup keys.
+ // For example, ["common", "en"] becomes ["common"],
+ // selecting the Map's entire subtree
+ // so the key lookup can be evaluated at runtime.
Review Comment:
maybe better to use the example from the rustdoc
--
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]