MCPcopy Create free account
hub / github.com/apache/datafusion / qualify_join_schema_sides

Function qualify_join_schema_sides

datafusion/core/src/physical_planner.rs:2113–2161  ·  view source on GitHub ↗

Qualifies the fields in a join schema with "left" and "right" qualifiers without mutating the original schema. This function should only be used when the join inputs have already been requalified earlier in `try_new_with_project_input`. The purpose is to avoid ambiguity errors later in planning (e.g., in nullability or data type resolution) when converting expressions to fields.

(
    join_schema: &DFSchema,
    left: &LogicalPlan,
    right: &LogicalPlan,
)

Source from the content-addressed store, hash-verified

2111/// The purpose is to avoid ambiguity errors later in planning (e.g., in nullability or data type resolution)
2112/// when converting expressions to fields.
2113fn qualify_join_schema_sides(
2114 join_schema: &DFSchema,
2115 left: &LogicalPlan,
2116 right: &LogicalPlan,
2117) -> Result<DFSchema> {
2118 let left_fields = left.schema().fields();
2119 let right_fields = right.schema().fields();
2120 let join_fields = join_schema.fields();
2121
2122 // Validate lengths
2123 assert_eq_or_internal_err!(
2124 join_fields.len(),
2125 left_fields.len() + right_fields.len(),
2126 "Join schema field count must match left and right field count."
2127 );
2128
2129 // Validate field names match
2130 for (i, (field, expected)) in join_fields
2131 .iter()
2132 .zip(left_fields.iter().chain(right_fields.iter()))
2133 .enumerate()
2134 {
2135 assert_eq_or_internal_err!(
2136 field.name(),
2137 expected.name(),
2138 "Field name mismatch at index {}",
2139 i
2140 );
2141 }
2142
2143 // qualify sides
2144 let qualifiers = join_fields
2145 .iter()
2146 .enumerate()
2147 .map(|(i, _)| {
2148 if i < left_fields.len() {
2149 Some(TableReference::Bare {
2150 table: Arc::from("left"),
2151 })
2152 } else {
2153 Some(TableReference::Bare {
2154 table: Arc::from("right"),
2155 })
2156 }
2157 })
2158 .collect();
2159
2160 join_schema.with_field_specific_qualified_schema(qualifiers)
2161}
2162
2163fn get_physical_expr_pair(
2164 expr: &Expr,

Callers 1

Calls 7

collectMethod · 0.80
fieldsMethod · 0.45
schemaMethod · 0.45
iterMethod · 0.45
mapMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…