mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
first_value and last_value
This commit is contained in:
parent
ecbcf47f28
commit
d8f9a8d3cd
@ -34,6 +34,14 @@ void registerAggregateFunctionsAny(AggregateFunctionFactory & factory)
|
||||
factory.registerFunction("any", { createAggregateFunctionAny, properties });
|
||||
factory.registerFunction("anyLast", { createAggregateFunctionAnyLast, properties });
|
||||
factory.registerFunction("anyHeavy", { createAggregateFunctionAnyHeavy, properties });
|
||||
|
||||
// Synonyms for use as window functions.
|
||||
factory.registerFunction("first_value",
|
||||
{ createAggregateFunctionAny, properties },
|
||||
AggregateFunctionFactory::CaseInsensitive);
|
||||
factory.registerFunction("last_value",
|
||||
{ createAggregateFunctionAnyLast, properties },
|
||||
AggregateFunctionFactory::CaseInsensitive);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1367,7 +1367,7 @@ struct WindowFunctionLagLead final : public WindowFunction
|
||||
// or track a separate frame for these functions, which would make the
|
||||
// window transform completely impenetrable to human mind. Our best bet
|
||||
// is probably rewriting, say, `lag(value, offset)` to
|
||||
// `any(value) over rows between offset preceding and offset preceding`,
|
||||
// `any(value) over (rows between offset preceding and offset preceding)`,
|
||||
// at the query planning stage. We can keep this class as a stub for
|
||||
// parsing, anyway.
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED,
|
||||
|
@ -968,3 +968,21 @@ select
|
||||
lead(2)(number) over (),
|
||||
lag(number) over ()
|
||||
from numbers(2); -- { serverError 48 }
|
||||
select
|
||||
number,
|
||||
fIrSt_VaLue(number) over w,
|
||||
lAsT_vAlUe(number) over w
|
||||
from numbers(10)
|
||||
window w as (order by number range between 1 preceding and 1 following)
|
||||
order by number
|
||||
;
|
||||
0 0 1
|
||||
1 0 2
|
||||
2 1 3
|
||||
3 2 4
|
||||
4 3 5
|
||||
5 4 6
|
||||
6 5 7
|
||||
7 6 8
|
||||
8 7 9
|
||||
9 8 9
|
||||
|
@ -334,3 +334,12 @@ select
|
||||
lead(2)(number) over (),
|
||||
lag(number) over ()
|
||||
from numbers(2); -- { serverError 48 }
|
||||
|
||||
select
|
||||
number,
|
||||
fIrSt_VaLue(number) over w,
|
||||
lAsT_vAlUe(number) over w
|
||||
from numbers(10)
|
||||
window w as (order by number range between 1 preceding and 1 following)
|
||||
order by number
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user