Skip to content

Commit

Permalink
omit some clone when converting sql to logical plan (#1945)
Browse files Browse the repository at this point in the history
* emit some clone

* optimize code with clippy

* make code clearer

* resolve conflicts with #1951

Co-authored-by: xudong.w <wxd963996380@gmail.com>

Co-authored-by: xudong.w <wxd963996380@gmail.com>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
  • Loading branch information
3 people authored Mar 10, 2022
1 parent 0e440ea commit 67b8272
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 88 deletions.
4 changes: 2 additions & 2 deletions datafusion/src/execution/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl ExecutionContext {
///
/// This function is intended for internal use and should not be called directly.
pub fn create_logical_plan(&self, sql: &str) -> Result<LogicalPlan> {
let statements = DFParser::parse_sql(sql)?;
let mut statements = DFParser::parse_sql(sql)?;

if statements.len() != 1 {
return Err(DataFusionError::NotImplemented(
Expand All @@ -308,7 +308,7 @@ impl ExecutionContext {
// create a query planner
let state = self.state.lock().clone();
let query_planner = SqlToRel::new(&state);
query_planner.statement_to_plan(&statements[0])
query_planner.statement_to_plan(statements.pop().unwrap())
}

/// Registers a variable provider within this context.
Expand Down
Loading

0 comments on commit 67b8272

Please sign in to comment.