(
&self,
ids: Vec<Ident>,
schema: &DFSchema,
planner_context: &mut PlannerContext,
)
| 114 | } |
| 115 | |
| 116 | pub(crate) fn sql_compound_identifier_to_expr( |
| 117 | &self, |
| 118 | ids: Vec<Ident>, |
| 119 | schema: &DFSchema, |
| 120 | planner_context: &mut PlannerContext, |
| 121 | ) -> Result<Expr> { |
| 122 | assert_or_internal_err!(ids.len() >= 2, "Not a compound identifier: {ids:?}"); |
| 123 | |
| 124 | let ids_span = Span::union_iter( |
| 125 | ids.iter() |
| 126 | .filter_map(|id| Span::try_from_sqlparser_span(id.span)), |
| 127 | ); |
| 128 | |
| 129 | if ids[0].value.starts_with('@') && ids[0].quote_style.is_none() { |
| 130 | let var_names: Vec<_> = ids |
| 131 | .into_iter() |
| 132 | .map(|id| self.ident_normalizer.normalize(id)) |
| 133 | .collect(); |
| 134 | let field = self |
| 135 | .context_provider |
| 136 | .get_variable_field(&var_names) |
| 137 | .or_else(|| { |
| 138 | self.context_provider |
| 139 | .get_variable_type(&var_names) |
| 140 | .map(|ty| ty.into_nullable_field_ref()) |
| 141 | }) |
| 142 | .ok_or_else(|| { |
| 143 | exec_datafusion_err!("variable {var_names:?} has no type information") |
| 144 | })?; |
| 145 | Ok(Expr::ScalarVariable(field, var_names)) |
| 146 | } else { |
| 147 | let ids = ids |
| 148 | .into_iter() |
| 149 | .map(|id| self.ident_normalizer.normalize(id)) |
| 150 | .collect::<Vec<_>>(); |
| 151 | |
| 152 | let search_result = search_dfschema(&ids, schema); |
| 153 | match search_result { |
| 154 | // Found matching field with spare identifier(s) for nested field(s) in structure |
| 155 | Some((field, qualifier, nested_names)) if !nested_names.is_empty() => { |
| 156 | // Found matching field with spare identifier(s) for nested field(s) in structure |
| 157 | for planner in self.context_provider.get_expr_planners() { |
| 158 | if let Ok(planner_result) = planner.plan_compound_identifier( |
| 159 | field, |
| 160 | qualifier, |
| 161 | nested_names, |
| 162 | ) { |
| 163 | match planner_result { |
| 164 | PlannerResult::Planned(expr) => { |
| 165 | return Ok(expr); |
| 166 | } |
| 167 | PlannerResult::Original(_args) => {} |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | plan_err!("could not parse compound identifier from {ids:?}") |
| 172 | } |
| 173 | // Found matching field with no spare identifier(s) |
no test coverage detected