@@ -225,19 +225,6 @@ select sum((b = (i > 0))::int), count(b = (i > 0)) from aggexpr;
225225-- Multiple qual evaluation with caching.
226226select 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-
241228reset timescaledb .debug_require_vector_agg ;
242229reset 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
256243select 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
260261select 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