(
&self,
table_name: &ObjectName,
predicate_expr: Option<SQLExpr>,
limit: Option<SQLExpr>,
)
| 2189 | } |
| 2190 | |
| 2191 | fn delete_to_plan( |
| 2192 | &self, |
| 2193 | table_name: &ObjectName, |
| 2194 | predicate_expr: Option<SQLExpr>, |
| 2195 | limit: Option<SQLExpr>, |
| 2196 | ) -> Result<LogicalPlan> { |
| 2197 | // Do a table lookup to verify the table exists |
| 2198 | let table_ref = self.object_name_to_table_reference(table_name.clone())?; |
| 2199 | let table_source = self.context_provider.get_table_source(table_ref.clone())?; |
| 2200 | let schema = DFSchema::try_from_qualified_schema( |
| 2201 | table_ref.clone(), |
| 2202 | &table_source.schema(), |
| 2203 | )?; |
| 2204 | let scan = |
| 2205 | LogicalPlanBuilder::scan(table_ref.clone(), Arc::clone(&table_source), None)? |
| 2206 | .build()?; |
| 2207 | let mut planner_context = PlannerContext::new(); |
| 2208 | |
| 2209 | let mut source = match predicate_expr { |
| 2210 | None => scan, |
| 2211 | Some(predicate_expr) => { |
| 2212 | let filter_expr = |
| 2213 | self.sql_to_expr(predicate_expr, &schema, &mut planner_context)?; |
| 2214 | let schema = Arc::new(schema); |
| 2215 | let mut using_columns = HashSet::new(); |
| 2216 | expr_to_columns(&filter_expr, &mut using_columns)?; |
| 2217 | let filter_expr = normalize_col_with_schemas_and_ambiguity_check( |
| 2218 | filter_expr, |
| 2219 | &[&[&schema]], |
| 2220 | &[using_columns], |
| 2221 | )?; |
| 2222 | LogicalPlan::Filter(Filter::try_new(filter_expr, Arc::new(scan))?) |
| 2223 | } |
| 2224 | }; |
| 2225 | |
| 2226 | if let Some(limit) = limit { |
| 2227 | let empty_schema = DFSchema::empty(); |
| 2228 | let limit = self.sql_to_expr(limit, &empty_schema, &mut planner_context)?; |
| 2229 | source = LogicalPlanBuilder::from(source) |
| 2230 | .limit_by_expr(None, Some(limit))? |
| 2231 | .build()? |
| 2232 | } |
| 2233 | |
| 2234 | let plan = LogicalPlan::Dml(DmlStatement::new( |
| 2235 | table_ref, |
| 2236 | table_source, |
| 2237 | WriteOp::Delete, |
| 2238 | Arc::new(source), |
| 2239 | )); |
| 2240 | Ok(plan) |
| 2241 | } |
| 2242 | |
| 2243 | fn update_to_plan( |
| 2244 | &self, |
no test coverage detected