use ant_then to delay parser error
@@ -325,27 +325,30 @@ impl<W: std::io::Write> InteractiveWorkerBase<W> {
let stmts_hints =
DfParser::parse_sql(query, context.get_current_session().get_type());
let mut hints = vec![];
- let is_result_set: bool;
+ let mut is_result_set = false;
let interpreter: Result<Arc<dyn Interpreter>>;
if let Ok((stmts, h)) = stmts_hints {
hints = h;
interpreter = if use_planner_v2(&settings, &stmts)? {
let mut planner = Planner::new(context.clone());
- let (plan, _, _) = planner.plan_sql(query).await?;
- is_result_set = is_result_set_by_plan(&plan);
- InterpreterFactoryV2::get(context.clone(), &plan)
+ planner.plan_sql(query).await.and_then(|v| {
+ is_result_set = is_result_set_by_plan(&v.0);
+ InterpreterFactoryV2::get(context.clone(), &v.0)
+ })
} else {
let (plan, _) = PlanParser::parse_with_hint(query, context.clone()).await;
- let plan = plan?;
- is_result_set = is_result_set_by_plan_node(&plan);
- InterpreterFactory::get(context.clone(), plan)
+ plan.and_then(|v| {
+ is_result_set = is_result_set_by_plan_node(&v);
+ InterpreterFactory::get(context.clone(), v)
+ })
};
} else if settings.get_enable_planner_v2()? != 0 {
// If old parser failed, try new planner
let mut planner = Planner::new(context.clone());
- let (plan, _, _) = planner.plan_sql(query).await?;
- is_result_set = is_result_set_by_plan(&plan);
- interpreter = InterpreterFactoryV2::get(context.clone(), &plan);
+ interpreter = planner.plan_sql(query).await.and_then(|v| {
+ is_result_set = is_result_set_by_plan(&v.0);
+ InterpreterFactoryV2::get(context.clone(), &v.0)
+ });
} else {
return Err(stmts_hints
.err()
