Skip to content

Commit d8c64bb

Browse files
committed
fix
1 parent 89dd885 commit d8c64bb

File tree

13 files changed

+153
-116
lines changed

13 files changed

+153
-116
lines changed

src/query/service/src/pipelines/processors/transforms/sort/bounds.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ impl Bounds {
4848
Ok(Bounds(vec![block.get_last_column().clone()]))
4949
}
5050

51-
pub fn merge<R: Rows>(mut vector: Vec<Bounds>, batch_rows: usize) -> Result<Self> {
51+
pub fn merge<R: Rows>(vector: Vec<Bounds>, batch_rows: usize) -> Result<Self> {
52+
let mut vector: Vec<_> = vector
53+
.into_iter()
54+
.filter(|bounds| !bounds.is_empty())
55+
.collect();
5256
match vector.len() {
5357
0 => Ok(Bounds(vec![])),
5458
1 => Ok(vector.pop().unwrap()),
@@ -95,7 +99,6 @@ impl Bounds {
9599
self.0.iter().map(Column::len).sum()
96100
}
97101

98-
#[expect(dead_code)]
99102
pub fn is_empty(&self) -> bool {
100103
self.0.iter().all(|col| col.len() == 0)
101104
}

src/query/service/src/pipelines/processors/transforms/sort/sort_merge_stream.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -146,36 +146,10 @@ where A: SortAlgorithm + 'static
146146
};
147147

148148
if streams.iter().all(|stream| stream.input.is_finished()) {
149+
self.output.finish();
149150
return Ok(Event::Finished);
150151
}
151152

152-
// {
153-
// for stream in streams.iter_mut() {
154-
// stream.pull()?;
155-
// }
156-
157-
// if streams
158-
// .iter_mut()
159-
// .map(|stream| stream.pull())
160-
// .try_fold(false, |acc, pending| acc || pending?)?
161-
// {
162-
// return Ok(Event::NeedData);
163-
// }
164-
165-
// if bounds.is_empty() {
166-
// return Ok(Event::Finished);
167-
// }
168-
169-
// if bounds.iter().all(|meta| meta.index != self.bound_index) {
170-
// let meta = match bounds.iter().min_by_key(|meta| meta.index) {
171-
// Some(index) => *index,
172-
// None => return Ok(Event::Finished),
173-
// };
174-
// assert!(meta.index > self.bound_index);
175-
// self.bound_index = meta.index;
176-
// }
177-
// }
178-
179153
for stream in streams.iter_mut() {
180154
stream.update_bound_index(self.bound_index);
181155
}

src/query/service/src/pipelines/processors/transforms/sort/sort_route.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,15 @@ impl TransformSortRoute {
4444
}
4545

4646
fn process(&mut self) -> Result<Event> {
47-
for input in &self.inputs {
48-
input.set_need_data();
49-
}
50-
5147
for (input, data) in self.inputs.iter().zip(self.input_data.iter_mut()) {
5248
let meta = match data {
5349
Some((_, meta)) => *meta,
5450
None => {
5551
let Some(mut block) = input.pull_data().transpose()? else {
52+
input.set_need_data();
5653
continue;
5754
};
55+
input.set_need_data();
5856

5957
let meta = block
6058
.take_meta()

tests/sqllogictests/suites/mode/standalone/explain/aggregate.test

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ EvalScalar
227227
query T
228228
explain select avg(b) from explain_agg_t1 group by a order by avg(b);
229229
----
230-
Sort
230+
Sort(Single)
231231
├── output columns: [sum(b) / if(count(b) = 0, 1, count(b)) (#4), sum(b) / if(count(b) = 0, 1, count(b)) (#5)]
232232
├── sort keys: [sum(b) / if(count(b) = 0, 1, count(b)) ASC NULLS LAST]
233233
├── estimated rows: 0.00
@@ -258,7 +258,7 @@ Sort
258258
query T
259259
explain select avg(b) + 1 from explain_agg_t1 group by a order by avg(b);
260260
----
261-
Sort
261+
Sort(Single)
262262
├── output columns: [sum(b) / if(count(b) = 0, 1, count(b)) + 1 (#4), sum(b) / if(count(b) = 0, 1, count(b)) (#5)]
263263
├── sort keys: [sum(b) / if(count(b) = 0, 1, count(b)) ASC NULLS LAST]
264264
├── estimated rows: 0.00
@@ -288,7 +288,7 @@ Sort
288288
query T
289289
explain select avg(b), avg(b) + 1 from explain_agg_t1 group by a order by avg(b);
290290
----
291-
Sort
291+
Sort(Single)
292292
├── output columns: [sum(b) / if(count(b) = 0, 1, count(b)) (#4), sum(b) / if(count(b) = 0, 1, count(b)) + 1 (#5), sum(b) / if(count(b) = 0, 1, count(b)) (#6)]
293293
├── sort keys: [sum(b) / if(count(b) = 0, 1, count(b)) ASC NULLS LAST]
294294
├── estimated rows: 0.00
@@ -318,7 +318,7 @@ Sort
318318
query T
319319
explain select avg(b) + 1, avg(b) from explain_agg_t1 group by a order by avg(b);
320320
----
321-
Sort
321+
Sort(Single)
322322
├── output columns: [sum(b) / if(count(b) = 0, 1, count(b)) + 1 (#4), sum(b) / if(count(b) = 0, 1, count(b)) (#5), sum(b) / if(count(b) = 0, 1, count(b)) (#6)]
323323
├── sort keys: [sum(b) / if(count(b) = 0, 1, count(b)) ASC NULLS LAST]
324324
├── estimated rows: 0.00
@@ -348,7 +348,7 @@ Sort
348348
query T
349349
explain select avg(b), avg(b) + 1 from explain_agg_t1 group by a order by avg(b) + 1;
350350
----
351-
Sort
351+
Sort(Single)
352352
├── output columns: [sum(b) / if(count(b) = 0, 1, count(b)) (#4), sum(b) / if(count(b) = 0, 1, count(b)) + 1 (#5), sum(b) / if(count(b) = 0, 1, count(b)) + 1 (#6)]
353353
├── sort keys: [sum(b) / if(count(b) = 0, 1, count(b)) + 1 ASC NULLS LAST]
354354
├── estimated rows: 0.00
@@ -472,7 +472,7 @@ Limit
472472
├── limit: 10
473473
├── offset: 0
474474
├── estimated rows: 0.00
475-
└── Sort
475+
└── Sort(Single)
476476
├── output columns: [count() (#2), t.referer (#0), t.isrefresh (#1)]
477477
├── sort keys: [referer ASC NULLS LAST, isrefresh DESC NULLS LAST]
478478
├── estimated rows: 0.00
@@ -504,7 +504,7 @@ Limit
504504
├── limit: 10
505505
├── offset: 3
506506
├── estimated rows: 0.00
507-
└── Sort
507+
└── Sort(Single)
508508
├── output columns: [count() (#2), t.referer (#0), t.isrefresh (#1)]
509509
├── sort keys: [referer ASC NULLS LAST, isrefresh ASC NULLS LAST]
510510
├── estimated rows: 0.00

tests/sqllogictests/suites/mode/standalone/explain/eliminate_sort.test

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
query T
22
explain select * from numbers(10) t order by t.number desc
33
----
4-
Sort
4+
Sort(Single)
55
├── output columns: [t.number (#0)]
66
├── sort keys: [number DESC NULLS LAST]
77
├── estimated rows: 10.00
@@ -18,7 +18,7 @@ Sort
1818
query T
1919
explain select * from (select * from numbers(10) t order by t.number desc) order by number desc
2020
----
21-
Sort
21+
Sort(Single)
2222
├── output columns: [t.number (#0)]
2323
├── sort keys: [number DESC NULLS LAST]
2424
├── estimated rows: 10.00
@@ -35,11 +35,11 @@ Sort
3535
query T
3636
explain select * from (select * from numbers(10) t order by t.number desc) order by t.number asc
3737
----
38-
Sort
38+
Sort(Single)
3939
├── output columns: [t.number (#0)]
4040
├── sort keys: [number ASC NULLS LAST]
4141
├── estimated rows: 10.00
42-
└── Sort
42+
└── Sort(Single)
4343
├── output columns: [t.number (#0)]
4444
├── sort keys: [number DESC NULLS LAST]
4545
├── estimated rows: 10.00
@@ -56,11 +56,11 @@ Sort
5656
query T
5757
explain select * from (select * from numbers(10) t order by t.number desc) order by t.number desc, t.number desc
5858
----
59-
Sort
59+
Sort(Single)
6060
├── output columns: [t.number (#0)]
6161
├── sort keys: [number DESC NULLS LAST, number DESC NULLS LAST]
6262
├── estimated rows: 10.00
63-
└── Sort
63+
└── Sort(Single)
6464
├── output columns: [t.number (#0)]
6565
├── sort keys: [number DESC NULLS LAST]
6666
├── estimated rows: 10.00
@@ -77,15 +77,15 @@ Sort
7777
query T
7878
explain select * from (select * from numbers(10) t order by t.number desc) order by t.number+1 desc
7979
----
80-
Sort
80+
Sort(Single)
8181
├── output columns: [t.number (#0), number + 1 (#1)]
8282
├── sort keys: [number + 1 DESC NULLS LAST]
8383
├── estimated rows: 10.00
8484
└── EvalScalar
8585
├── output columns: [t.number (#0), number + 1 (#1)]
8686
├── expressions: [t.number (#0) + 1]
8787
├── estimated rows: 10.00
88-
└── Sort
88+
└── Sort(Single)
8989
├── output columns: [t.number (#0)]
9090
├── sort keys: [number DESC NULLS LAST]
9191
├── estimated rows: 10.00

tests/sqllogictests/suites/mode/standalone/explain/explain.test

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ Limit
535535
├── limit: 3
536536
├── offset: 0
537537
├── estimated rows: 3.00
538-
└── Sort
538+
└── Sort(Single)
539539
├── output columns: [t2.a (#2), t2.b (#3), t1.a (#0), t1.b (#1)]
540540
├── sort keys: [a DESC NULLS LAST]
541541
├── estimated rows: 3.85
@@ -868,7 +868,7 @@ from numbers(10) where number > 5
868868
) a join ( select number , to_yyyymmdd(to_timestamp(number)) as register_at from numbers(10) where number > 5
869869
) b on a.number=b.number order by a.number) where pt = register_at;
870870
----
871-
Sort
871+
Sort(Single)
872872
├── output columns: [numbers.number (#0), pt (#1), register_at (#3)]
873873
├── sort keys: [number ASC NULLS LAST]
874874
├── estimated rows: 0.00
@@ -1079,7 +1079,7 @@ INSERT INTO t2 VALUES (1, 10), (2, 20);
10791079
query T
10801080
EXPLAIN SELECT * FROM t1 LEFT OUTER JOIN t2 ON TRUE AND t1.i = t2.k AND FALSE order by i, j;
10811081
----
1082-
Sort
1082+
Sort(Single)
10831083
├── output columns: [t1.i (#0), t1.j (#1), t2.k (#2), t2.l (#3)]
10841084
├── sort keys: [i ASC NULLS LAST, j ASC NULLS LAST]
10851085
├── estimated rows: 3.00
@@ -1362,7 +1362,7 @@ HashJoin
13621362
├── build join filters:
13631363
│ └── filter id:0, build key:a (#3), probe key:a (#0), filter type:bloom,inlist,min_max
13641364
├── estimated rows: 0.00
1365-
├── Sort(Build)
1365+
├── Sort(Single)(Build)
13661366
│ ├── output columns: [count(a) (#6), t1.c (#5), t1.a (#3)]
13671367
│ ├── sort keys: [count(a) ASC NULLS LAST]
13681368
│ ├── estimated rows: 0.00
@@ -1412,7 +1412,7 @@ HashJoin
14121412
├── build join filters:
14131413
│ └── filter id:0, build key:a (#3), probe key:a (#0), filter type:bloom,inlist,min_max
14141414
├── estimated rows: 0.00
1415-
├── Sort(Build)
1415+
├── Sort(Single)(Build)
14161416
│ ├── output columns: [COUNT(*) (#6), t1.c (#5), t1.a (#3)]
14171417
│ ├── sort keys: [COUNT(*) ASC NULLS LAST]
14181418
│ ├── estimated rows: 0.00

tests/sqllogictests/suites/mode/standalone/explain/explain_like.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Filter
3535
query T
3636
explain select * from t1 where s like 'abcd%' order by s;
3737
----
38-
Sort
38+
Sort(Single)
3939
├── output columns: [t1.s (#0)]
4040
├── sort keys: [s ASC NULLS LAST]
4141
├── estimated rows: 1.00
@@ -62,7 +62,7 @@ abcd
6262
query T
6363
explain select * from t1 where s like 'abcd' order by s;
6464
----
65-
Sort
65+
Sort(Single)
6666
├── output columns: [t1.s (#0)]
6767
├── sort keys: [s ASC NULLS LAST]
6868
├── estimated rows: 1.00

tests/sqllogictests/suites/mode/standalone/explain/lazy_read.test

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ RowFetch
1919
├── limit: 2
2020
├── offset: 0
2121
├── estimated rows: 0.00
22-
└── Sort
22+
└── Sort(Single)
2323
├── output columns: [t_lazy.a (#0), t_lazy._row_id (#7)]
2424
├── sort keys: [a DESC NULLS LAST]
2525
├── estimated rows: 0.00
@@ -94,7 +94,7 @@ RowFetch
9494
├── limit: 10
9595
├── offset: 0
9696
├── estimated rows: 0.00
97-
└── Sort
97+
└── Sort(Single)
9898
├── output columns: [t_11831.uid (#0), t_11831.time (#3), t_11831._row_id (#4)]
9999
├── sort keys: [time DESC NULLS LAST]
100100
├── estimated rows: 0.00
@@ -126,7 +126,7 @@ Limit
126126
├── limit: 2
127127
├── offset: 0
128128
├── estimated rows: 0.00
129-
└── Sort
129+
└── Sort(Single)
130130
├── output columns: [t_lazy.a (#0), t_lazy.b (#1), t_lazy.c (#2), t_lazy.d (#3), t_lazy.e (#6)]
131131
├── sort keys: [a DESC NULLS LAST]
132132
├── estimated rows: 0.00
@@ -194,7 +194,7 @@ Limit
194194
├── limit: 1
195195
├── offset: 0
196196
├── estimated rows: 0.00
197-
└── Sort
197+
└── Sort(Single)
198198
├── output columns: [t_lazy.a (#0), x (#7), y (#8)]
199199
├── sort keys: [x ASC NULLS LAST]
200200
├── estimated rows: 0.00
@@ -221,7 +221,7 @@ Limit
221221
├── limit: 1
222222
├── offset: 0
223223
├── estimated rows: 0.00
224-
└── Sort
224+
└── Sort(Single)
225225
├── output columns: [t_lazy.a (#0), t_lazy._row_id (#9), x (#7), y (#8), t_lazy.b (#1)]
226226
├── sort keys: [x ASC NULLS LAST]
227227
├── estimated rows: 0.00
@@ -234,7 +234,7 @@ Limit
234234
├── limit: 2
235235
├── offset: 0
236236
├── estimated rows: 0.00
237-
└── Sort
237+
└── Sort(Single)
238238
├── output columns: [t_lazy.a (#0), t_lazy._row_id (#9), x (#7), y (#8)]
239239
├── sort keys: [y ASC NULLS LAST]
240240
├── estimated rows: 0.00
@@ -251,7 +251,7 @@ Limit
251251
├── limit: 3
252252
├── offset: 0
253253
├── estimated rows: 0.00
254-
└── Sort
254+
└── Sort(Single)
255255
├── output columns: [t_lazy.a (#0), t_lazy._row_id (#9)]
256256
├── sort keys: [a ASC NULLS LAST]
257257
├── estimated rows: 0.00

tests/sqllogictests/suites/mode/standalone/explain/limit.test

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ Limit
2424
query T
2525
explain select * from (select t.number from numbers(10) as t order by number desc) order by number asc
2626
----
27-
Sort
27+
Sort(Single)
2828
├── output columns: [t.number (#0)]
2929
├── sort keys: [number ASC NULLS LAST]
3030
├── estimated rows: 10.00
31-
└── Sort
31+
└── Sort(Single)
3232
├── output columns: [t.number (#0)]
3333
├── sort keys: [number DESC NULLS LAST]
3434
├── estimated rows: 10.00
@@ -50,7 +50,7 @@ Limit
5050
├── limit: 9
5151
├── offset: 0
5252
├── estimated rows: 8.00
53-
└── Sort
53+
└── Sort(Single)
5454
├── output columns: [t.number (#0)]
5555
├── sort keys: [number ASC NULLS LAST]
5656
├── estimated rows: 8.00
@@ -59,7 +59,7 @@ Limit
5959
├── limit: 8
6060
├── offset: 0
6161
├── estimated rows: 8.00
62-
└── Sort
62+
└── Sort(Single)
6363
├── output columns: [t.number (#0)]
6464
├── sort keys: [number DESC NULLS LAST]
6565
├── estimated rows: 10.00
@@ -81,7 +81,7 @@ Limit
8181
├── limit: 3
8282
├── offset: 0
8383
├── estimated rows: 0.20
84-
└── Sort
84+
└── Sort(Single)
8585
├── output columns: [t.number (#0)]
8686
├── sort keys: [number DESC NULLS LAST]
8787
├── estimated rows: 0.20
@@ -177,7 +177,7 @@ Limit
177177
├── limit: 1
178178
├── offset: 0
179179
├── estimated rows: 1.00
180-
└── Sort
180+
└── Sort(Single)
181181
├── output columns: [c (#4), count(t1.number) (#1)]
182182
├── sort keys: [count(t1.number) ASC NULLS LAST]
183183
├── estimated rows: 2.00

tests/sqllogictests/suites/mode/standalone/explain/prune_column.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Limit
4141
├── limit: 1
4242
├── offset: 0
4343
├── estimated rows: 0.00
44-
└── Sort
44+
└── Sort(Single)
4545
├── output columns: [numbers.number (#0)]
4646
├── sort keys: [number ASC NULLS LAST]
4747
├── estimated rows: 0.00
@@ -186,7 +186,7 @@ HashJoin
186186
query T
187187
explain select name from system.functions order by example
188188
----
189-
Sort
189+
Sort(Single)
190190
├── output columns: [functions.name (#0), functions.example (#4)]
191191
├── sort keys: [example ASC NULLS LAST]
192192
├── estimated rows: 0.00

0 commit comments

Comments
 (0)