(
&self,
sql: SQLExpr,
schema: &DFSchema,
planner_context: &mut PlannerContext,
)
| 204 | /// [`Self::sql_expr_to_logical_expr`] to plan exprs. |
| 205 | #[cfg_attr(feature = "recursive_protection", recursive::recursive)] |
| 206 | fn sql_expr_to_logical_expr_internal( |
| 207 | &self, |
| 208 | sql: SQLExpr, |
| 209 | schema: &DFSchema, |
| 210 | planner_context: &mut PlannerContext, |
| 211 | ) -> Result<Expr> { |
| 212 | // NOTE: This function is called recursively, so each match arm body should be as |
| 213 | // small as possible to decrease stack requirement. |
| 214 | // Follow the common pattern of extracting into a separate function for |
| 215 | // non-trivial arms. See https://github.com/apache/datafusion/pull/12384 for |
| 216 | // more context. |
| 217 | match sql { |
| 218 | SQLExpr::Value(value) => { |
| 219 | self.parse_value(value.into(), planner_context.prepare_param_data_types()) |
| 220 | } |
| 221 | SQLExpr::Extract { field, expr, .. } => { |
| 222 | let mut extract_args = vec![ |
| 223 | Expr::Literal(ScalarValue::from(format!("{field}")), None), |
| 224 | self.sql_expr_to_logical_expr(*expr, schema, planner_context)?, |
| 225 | ]; |
| 226 | |
| 227 | for planner in self.context_provider.get_expr_planners() { |
| 228 | match planner.plan_extract(extract_args)? { |
| 229 | PlannerResult::Planned(expr) => return Ok(expr), |
| 230 | PlannerResult::Original(args) => { |
| 231 | extract_args = args; |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | not_impl_err!("Extract not supported by ExprPlanner: {extract_args:?}") |
| 237 | } |
| 238 | |
| 239 | SQLExpr::Array(arr) => self.sql_array_literal(arr.elem, schema), |
| 240 | SQLExpr::Interval(interval) => self.sql_interval_to_expr(false, interval), |
| 241 | SQLExpr::Identifier(id) => { |
| 242 | self.sql_identifier_to_expr(id, schema, planner_context) |
| 243 | } |
| 244 | |
| 245 | // <expr>["foo"], <expr>[4] or <expr>[4:5] |
| 246 | SQLExpr::CompoundFieldAccess { root, access_chain } => self |
| 247 | .sql_compound_field_access_to_expr( |
| 248 | *root, |
| 249 | access_chain, |
| 250 | schema, |
| 251 | planner_context, |
| 252 | ), |
| 253 | |
| 254 | SQLExpr::CompoundIdentifier(ids) => { |
| 255 | self.sql_compound_identifier_to_expr(ids, schema, planner_context) |
| 256 | } |
| 257 | |
| 258 | SQLExpr::Case { |
| 259 | operand, |
| 260 | conditions, |
| 261 | else_result, |
| 262 | case_token: _, |
| 263 | end_token: _, |
no test coverage detected