Skip to content

Commit 63e1302

Browse files
committed
cleanup
1 parent 3854a70 commit 63e1302

3 files changed

Lines changed: 36 additions & 33 deletions

File tree

tsl/src/nodes/vector_agg/exec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,8 @@ vector_slot_evaluate_expression(DecompressContext *dcontext, TupleTableSlot *slo
738738
case T_CaseExpr:
739739
{
740740
CaseExpr const *c = (CaseExpr const *) argument;
741-
return vector_slot_evaluate_case(dcontext, slot, filter, c, expr_cache);
741+
result = vector_slot_evaluate_case(dcontext, slot, filter, c, expr_cache);
742+
break;
742743
}
743744
default:
744745
Ensure(false,

tsl/test/expected/vector_agg_expr.out

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,25 +2120,6 @@ select sum(abs(v - 500)), count(abs(v - 500)) from aggexpr where abs(v) > 3 AND
21202120
-------+-------
21212121
14820 | 30
21222122

2123-
-- CASE statement with cached parts
2124-
select sum(case when i > 0 then abs(v)::int2 else length(x)::int4 end)
2125-
from aggexpr
2126-
where abs(v) < 10 and length(x) < 10
2127-
;
2128-
sum
2129-
-----
2130-
120
2131-
2132-
-- CASE statement that is itself cached
2133-
select sum(x) from (
2134-
select (case when i > 0 then abs(v)::int2 else length(x)::int4 end) as x
2135-
from aggexpr) t
2136-
where x > 0
2137-
;
2138-
sum
2139-
---------
2140-
3321885
2141-
21422123
reset timescaledb.debug_require_vector_agg;
21432124
reset timescaledb.enable_vectorized_aggregation;
21442125
-- Some CASE statements are vectorized.
@@ -2193,6 +2174,26 @@ select count(*), case when v > 503 then x else 'something-else' end from aggexpr
21932174
1 | 141016
21942175
1 | 141018
21952176

2177+
-- CASE statement with different types and common subexpressions. They can't
2178+
-- actually be cached, because the evaluation context is different.
2179+
select sum(case when i > 0 then abs(v)::int2 else length(x)::int4 end)
2180+
from aggexpr
2181+
where abs(v) < 10 and length(x) < 10
2182+
;
2183+
sum
2184+
-----
2185+
120
2186+
2187+
-- CASE statement that is itself a common subexpression.
2188+
select sum(x) from (
2189+
select (case when i > 0 then abs(v)::int2 else length(x)::int4 end) as x
2190+
from aggexpr) t
2191+
where x > 0
2192+
;
2193+
sum
2194+
---------
2195+
3321885
2196+
21962197
-- The short circuit semantics for CASE is not implemented at the moment.
21972198
\set ON_ERROR_STOP 0
21982199
select count(*), case when i = 12 then 12 else throw_on_twelve(i) end from aggexpr group by 2 order by 1, 2 limit 10;

tsl/test/sql/vector_agg_expr.sql

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,6 @@ select sum((b = (i > 0))::int), count(b = (i > 0)) from aggexpr;
225225
-- Multiple qual evaluation with caching.
226226
select sum(abs(v - 500)), count(abs(v - 500)) from aggexpr where abs(v) > 3 AND abs(v) < 9;
227227

228-
-- CASE statement with cached parts
229-
select sum(case when i > 0 then abs(v)::int2 else length(x)::int4 end)
230-
from aggexpr
231-
where abs(v) < 10 and length(x) < 10
232-
;
233-
234-
-- CASE statement that is itself cached
235-
select sum(x) from (
236-
select (case when i > 0 then abs(v)::int2 else length(x)::int4 end) as x
237-
from aggexpr) t
238-
where x > 0
239-
;
240-
241228
reset timescaledb.debug_require_vector_agg;
242229
reset timescaledb.enable_vectorized_aggregation;
243230

@@ -255,6 +242,20 @@ select avg(case when v > 500 then v - 500 else 500 - v end) from aggexpr group b
255242

256243
select count(*), case when v > 503 then x else 'something-else' end from aggexpr group by 2 order by 1, 2 limit 10;
257244

245+
-- CASE statement with different types and common subexpressions. They can't
246+
-- actually be cached, because the evaluation context is different.
247+
select sum(case when i > 0 then abs(v)::int2 else length(x)::int4 end)
248+
from aggexpr
249+
where abs(v) < 10 and length(x) < 10
250+
;
251+
252+
-- CASE statement that is itself a common subexpression.
253+
select sum(x) from (
254+
select (case when i > 0 then abs(v)::int2 else length(x)::int4 end) as x
255+
from aggexpr) t
256+
where x > 0
257+
;
258+
258259
-- The short circuit semantics for CASE is not implemented at the moment.
259260
\set ON_ERROR_STOP 0
260261
select count(*), case when i = 12 then 12 else throw_on_twelve(i) end from aggexpr group by 2 order by 1, 2 limit 10;

0 commit comments

Comments
 (0)