timsaucer commented on code in PR #24670:
URL: https://github.com/apache/datafusion/pull/24670#discussion_r3927068478
##########
datafusion/physical-plan/src/projection.rs:
##########
@@ -270,6 +278,33 @@ impl ProjectionExec {
))
}
+ /// Returns whether `projector`'s output metadata differs from the metadata
+ /// derived from its expressions and `input_schema`.
+ fn compute_overrides_metadata(
+ projector: &Projector,
+ input_schema: &Schema,
+ ) -> Result<bool> {
+ let output_schema = projector.output_schema();
+ if input_schema.metadata() != output_schema.metadata() {
+ return Ok(true);
+ }
+ for (projection, output_field) in
+ projector.projection().iter().zip(output_schema.fields())
+ {
+ let derived_field = projection.expr.return_field(input_schema)?;
+ if derived_field.metadata() != output_field.metadata() {
+ return Ok(true);
+ }
+ }
+ Ok(false)
Review Comment:
Can we instead just reuse `projection.project_schema(input_schema)` and
compare. the metadata?
##########
datafusion/physical-plan/src/projection.rs:
##########
@@ -83,6 +83,9 @@ pub struct ProjectionExec {
metrics: ExecutionPlanMetricsSet,
/// Cache holding plan properties like equivalences, output partitioning
etc.
cache: Arc<PlanProperties>,
+ /// Whether the output metadata differs from the metadata derived from the
+ /// projection expressions and input schema.
+ overrides_metadata: bool,
Review Comment:
Agent picked up on something I overlooked: We are doing a `Clone` when we
call `replace_children` so it's possible that `overrides_metadata` becomes
inconsistent with the new children.
--
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]