Skip to content

Commit 7226fa1

Browse files
authored
fix(join): project build columns for fast returning left join (#19539)
1 parent dddffbd commit 7226fa1

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/query/service/src/pipelines/processors/transforms/new_hash_join/memory/left_join.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ impl Join for OuterLeftHashJoin {
111111
.map(|x| x.data_type().clone())
112112
.collect::<Vec<_>>();
113113

114-
let build_block = null_block(&types, data.num_rows());
114+
let build_block = match null_block(&types, data.num_rows()) {
115+
None => None,
116+
Some(data_block) => Some(data_block.project(&self.desc.build_projection)),
117+
};
118+
115119
let probe_block = Some(data.project(&self.desc.probe_projection));
116120
let result_block = final_result_block(&self.desc, probe_block, build_block, num_rows);
117121
return Ok(Box::new(OneBlockJoinStream(Some(result_block))));
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
query IIII
2+
with g as (
3+
select
4+
'sapp'::string as a,
5+
'ios'::string as os,
6+
to_date('2026-03-02') as week_start,
7+
1::decimal(38, 15) as bi_cost
8+
),
9+
target as (
10+
select
11+
week_start,
12+
a,
13+
os,
14+
1.234567890123456::decimal(38, 15) as target_d6_roi
15+
from (
16+
select
17+
'sapp'::string as a,
18+
'ios'::string as os,
19+
to_date('2026-03-02') as week_start
20+
) t
21+
where false
22+
),
23+
cte_a as (
24+
select g.*, target_d6_roi
25+
from g
26+
left join target
27+
on g.os = target.os
28+
and g.week_start = target.week_start
29+
and target.a = g.a
30+
)
31+
select typeof(target_d6_roi) from cte_a order by week_start;
32+
----
33+
DECIMAL(38, 15) NULL

0 commit comments

Comments
 (0)