Skip to content

Commit

Permalink
Merge pull request databendlabs#6572 from youngsofun/fix
Browse files Browse the repository at this point in the history
fix(query): catchup planner update in http handler.
  • Loading branch information
BohuTANG authored Jul 12, 2022
2 parents 05a6528 + 6691a5d commit bc3f6fc
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 8 deletions.
9 changes: 3 additions & 6 deletions query/src/servers/http/clickhouse_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ pub async fn clickhouse_handler_post(
.await
.map_err(InternalServerError)?;

session
.get_settings()
let settings = ctx.get_settings();
settings
.set_batch_settings(&params.settings, false)
.map_err(BadRequest)?;

Expand All @@ -325,11 +325,8 @@ pub async fn clickhouse_handler_post(
.map_err(InternalServerError);
}

let stmt_sql = params.query();
let (stmts, _) = DfParser::parse_sql(stmt_sql.as_str(), ctx.get_current_session().get_type())
let (stmts, _) = DfParser::parse_sql(sql.as_str(), ctx.get_current_session().get_type())
.unwrap_or_else(|_| (vec![], vec![]));

let settings = ctx.get_settings();
if settings
.get_enable_new_processor_framework()
.map_err(InternalServerError)?
Expand Down
3 changes: 3 additions & 0 deletions query/src/servers/http/v1/query/execute_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,12 @@ impl HttpQueryHandle {
) -> Result<SendableDataBlockStream> {
let executor = self.executor.clone();
let block_buffer = self.block_buffer.clone();
let last_schema = physical_plan.output_schema()?;
let mut pb = PipelineBuilder::new();
let mut root_pipeline = NewPipeline::create();
pb.build_pipeline(ctx.clone(), physical_plan, &mut root_pipeline)?;
pb.render_result_set(last_schema, result_columns, &mut root_pipeline)?;

let mut pipelines = pb.pipelines;
let async_runtime = ctx.get_storage_runtime();

Expand Down
37 changes: 37 additions & 0 deletions tests/logictest/suites/query/render_result.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
statement ok
set enable_planner_v2 = 1;

statement ok
drop table if exists t1 all;

statement ok
create table t1(a integer, b integer, c integer, d integer, e integer);

statement ok
insert into t1(e,c,b,d,a) values(103,102,100,101,104);

statement ok
insert into t1(a,c,d,e,b) values(107,106,108,109,105);

statement query IIIII
select c as col1,
abs(d-e) as col2,
case a+1 when b then 111 when c then 222
when d then 333 when e then 444 else 555 end as col3,
a+b*2+c*3+d*4 as col4,
e as col5
from t1
where d not between 110 and 150
or c between b-2 and d+2
or (e>c or e<d)
order by col1,col5,col3,col2,col4;

----
102 2 111 1014 103
106 1 111 1067 109

statement ok
drop table if exists t1 all;

statement ok
set enable_planner_v2 = 0;
4 changes: 2 additions & 2 deletions tests/logictest/suites/select_0
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ statement ok
drop table if exists t4;

statement ok
create table if not exists t4(a float, b float, c text, d bool);
create table if not exists t4(a float, b float, c varchar, d bool);

statement ok
insert into t4(a,b,c,d) values(1.0, 10.224, 'xxdsfs', false );
Expand Down Expand Up @@ -37,7 +37,7 @@ statement ok
drop table t4;

statement ok
create table if not exists t5(a text);
create table if not exists t5(a varchar);

statement ok
insert into t5(a) values ('abcd\nabcd')
Expand Down

0 comments on commit bc3f6fc

Please sign in to comment.