comphead commented on code in PR #24680:
URL: https://github.com/apache/datafusion/pull/24680#discussion_r3866858148
##########
datafusion/datasource-parquet/src/projection_read_plan.rs:
##########
@@ -248,6 +256,56 @@ impl<'schema> PushdownChecker<'schema> {
None
}
+ /// Preserve a Struct cast retained by schema adaptation and read its full
+ /// root. Pruning siblings or moving the cast could change errors or nulls.
+ fn check_cast_struct_field_access(
+ &mut self,
+ func: &ScalarFunctionExpr,
+ ) -> Option<TreeNodeRecursion> {
+ if !self.allow_struct_casts {
+ return None;
+ }
+ let (source, field_names) = func.args().split_first()?;
+ if field_names.is_empty() {
+ return None;
+ }
+ let cast = source.downcast_ref::<CastExpr>()?;
+ let column = cast.expr().downcast_ref::<Column>()?;
+ let index = self.file_schema.index_of(column.name()).ok()?;
+ if !matches!(
+ self.file_schema.field(index).data_type(),
+ DataType::Struct(_)
+ ) {
+ return None;
+ }
+ let return_type = func.return_type();
+ if DataType::is_nested(return_type) &&
!self.is_nested_type_supported(return_type)
+ {
+ return None;
Review Comment:
kind of optional, but when we have multiple early returns maybe its good to
debug the reason of None?
--
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]