Execute the [`LogicalPlan`], return a [`DataFrame`]. This API is not featured limited (so all SQL such as `CREATE TABLE` and `COPY` will be run). If you wish to limit the type of plan that can be run from SQL, see [`Self::sql_with_options`] and [`SQLOptions::verify_plan`].
(&self, plan: LogicalPlan)
| 684 | /// SQL, see [`Self::sql_with_options`] and |
| 685 | /// [`SQLOptions::verify_plan`]. |
| 686 | pub async fn execute_logical_plan(&self, plan: LogicalPlan) -> Result<DataFrame> { |
| 687 | match plan { |
| 688 | LogicalPlan::Ddl(ddl) => { |
| 689 | // Box::pin avoids allocating the stack space within this function's frame |
| 690 | // for every one of these individual async functions, decreasing the risk of |
| 691 | // stack overflows. |
| 692 | match ddl { |
| 693 | DdlStatement::CreateExternalTable(cmd) => { |
| 694 | (Box::pin(async move { self.create_external_table(&cmd).await }) |
| 695 | as std::pin::Pin<Box<dyn Future<Output = _> + Send>>) |
| 696 | .await |
| 697 | } |
| 698 | DdlStatement::CreateMemoryTable(cmd) => { |
| 699 | Box::pin(self.create_memory_table(cmd)).await |
| 700 | } |
| 701 | DdlStatement::CreateView(cmd) => { |
| 702 | Box::pin(self.create_view(cmd)).await |
| 703 | } |
| 704 | DdlStatement::CreateCatalogSchema(cmd) => { |
| 705 | Box::pin(self.create_catalog_schema(cmd)).await |
| 706 | } |
| 707 | DdlStatement::CreateCatalog(cmd) => { |
| 708 | Box::pin(self.create_catalog(cmd)).await |
| 709 | } |
| 710 | DdlStatement::DropTable(cmd) => Box::pin(self.drop_table(cmd)).await, |
| 711 | DdlStatement::DropView(cmd) => Box::pin(self.drop_view(cmd)).await, |
| 712 | DdlStatement::DropCatalogSchema(cmd) => { |
| 713 | Box::pin(self.drop_schema(cmd)).await |
| 714 | } |
| 715 | DdlStatement::CreateFunction(cmd) => { |
| 716 | Box::pin(self.create_function(cmd)).await |
| 717 | } |
| 718 | DdlStatement::DropFunction(cmd) => { |
| 719 | Box::pin(self.drop_function(cmd)).await |
| 720 | } |
| 721 | ddl => Ok(DataFrame::new(self.state(), LogicalPlan::Ddl(ddl))), |
| 722 | } |
| 723 | } |
| 724 | // TODO what about the other statements (like TransactionStart and TransactionEnd) |
| 725 | LogicalPlan::Statement(Statement::SetVariable(stmt)) => { |
| 726 | self.set_variable(stmt).await?; |
| 727 | self.return_empty_dataframe() |
| 728 | } |
| 729 | LogicalPlan::Statement(Statement::ResetVariable(stmt)) => { |
| 730 | self.reset_variable(stmt).await?; |
| 731 | self.return_empty_dataframe() |
| 732 | } |
| 733 | LogicalPlan::Statement(Statement::Prepare(Prepare { |
| 734 | name, |
| 735 | input, |
| 736 | fields, |
| 737 | })) => { |
| 738 | // The number of parameters must match the specified data types length. |
| 739 | if !fields.is_empty() { |
| 740 | let param_names = input.get_parameter_names()?; |
| 741 | if param_names.len() != fields.len() { |
| 742 | return plan_err!( |
| 743 | "Prepare specifies {} data types but query has {} parameters", |