merge_consecutive_projections

Function merge_consecutive_projections 

Source
fn merge_consecutive_projections(
    proj: Projection,
) -> Result<Transformed<Projection>>
Expand description

Merges consecutive projections.

Given a projection proj, this function attempts to merge it with a previous projection if it exists and if merging is beneficial. Merging is considered beneficial when expressions in the current projection are non-trivial and appear more than once in its input fields. This can act as a caching mechanism for non-trivial computations.

§Metadata Handling During Projection Merging

Alias metadata preservation: When merging projections, alias metadata from both the current and previous projections is carefully preserved. The presence of metadata precludes alias trimming.

Schema, Fields, and metadata: If a projection is rewritten, the schema and metadata are preserved. Individual field properties and metadata flows through expression rewriting and are preserved when fields are referenced in the merged projection. Refer to projection_schema for more details.

§Parameters

  • proj - A reference to the Projection to be merged.

§Returns

A Result object with the following semantics:

  • Ok(Some(Projection)): Merge was beneficial and successful. Contains the merged projection.
  • Ok(None): Signals that merge is not beneficial (and has not taken place).
  • Err(error): An error occurred during the function call.