alamb commented on a change in pull request #1945:
URL: https://github.com/apache/arrow-datafusion/pull/1945#discussion_r821972537
##########
File path: datafusion/src/sql/planner.rs
##########
@@ -2053,8 +2058,8 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
select_list, where_clause
);
- let rewrite = DFParser::parse_sql(&query)?;
- self.statement_to_plan(&rewrite[0])
+ let mut rewrite = DFParser::parse_sql(&query)?;
+ self.statement_to_plan(rewrite.remove(0))
Review comment:
I realize this was not added in this PR, but I wonder if we could add an
`assert_eq!(rewrite.len(), 1)` here to make sure we don't accidentally lose one
of these statements later on
##########
File path: datafusion/src/execution/context.rs
##########
@@ -311,7 +311,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.remove(0))
Review comment:
I think it is to take ownership of the 1 item from `statements`.
`statements.len() == 1` is verified on line 305 above
I think `statements.pop().unwrap()` is equivalent and might be clearer what
is going on, though I think `remove(0)` is also fine
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]