Extracts the root expression and access chain from a compound expression. This function attempts to identify if a compound expression (like `a.b.c`) should be treated as a column reference with a qualifier (like `table.column`) or as a field access expression. # Arguments `root` - The root SQL expression (e.g., the first part of `a.b.c`) `access_chain` - Vector of access expressions (e.g., `.b`
(
&self,
root: SQLExpr,
mut access_chain: Vec<AccessExpr>,
schema: &DFSchema,
planner_context: &mut PlannerContext,
)
| 1085 | /// * The resolved root expression |
| 1086 | /// * The remaining access chain that should be processed as field accesses |
| 1087 | fn extract_root_and_access_chain( |
| 1088 | &self, |
| 1089 | root: SQLExpr, |
| 1090 | mut access_chain: Vec<AccessExpr>, |
| 1091 | schema: &DFSchema, |
| 1092 | planner_context: &mut PlannerContext, |
| 1093 | ) -> Result<(Expr, Vec<AccessExpr>)> { |
| 1094 | let SQLExpr::Identifier(root_ident) = root else { |
| 1095 | let root = self.sql_expr_to_logical_expr(root, schema, planner_context)?; |
| 1096 | return Ok((root, access_chain)); |
| 1097 | }; |
| 1098 | |
| 1099 | let mut compound_idents = vec![root_ident]; |
| 1100 | let first_non_ident = access_chain |
| 1101 | .iter() |
| 1102 | .position(|access| !matches!(access, AccessExpr::Dot(SQLExpr::Identifier(_)))) |
| 1103 | .unwrap_or(access_chain.len()); |
| 1104 | for access in access_chain.drain(0..first_non_ident) { |
| 1105 | if let AccessExpr::Dot(SQLExpr::Identifier(ident)) = access { |
| 1106 | compound_idents.push(ident); |
| 1107 | } else { |
| 1108 | return internal_err!("Expected identifier in access chain"); |
| 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | let root = if compound_idents.len() == 1 { |
| 1113 | self.sql_identifier_to_expr( |
| 1114 | compound_idents.pop().unwrap(), |
| 1115 | schema, |
| 1116 | planner_context, |
| 1117 | )? |
| 1118 | } else { |
| 1119 | self.sql_compound_identifier_to_expr( |
| 1120 | compound_idents, |
| 1121 | schema, |
| 1122 | planner_context, |
| 1123 | )? |
| 1124 | }; |
| 1125 | Ok((root, access_chain)) |
| 1126 | } |
| 1127 | |
| 1128 | fn sql_compound_field_access_to_expr( |
| 1129 | &self, |
no test coverage detected