Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregatefunction any supports changelog #692

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/AggregateFunctions/Streaming/AggregateFunctionAny.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <AggregateFunctions/AggregateFunctionFactory.h>
#include <AggregateFunctions/Streaming/AggregateFunctionMinMaxAny.h>
#include <AggregateFunctions/Streaming/HelpersMinMaxAny.h>

#include <string>

namespace DB
{
namespace Streaming
{
AggregateFunctionPtr createAggregateFunctionAnyLast(
const std::string & name, const DataTypes & argument_types, const Array & parameters, const Settings * settings)
{
return AggregateFunctionPtr(createAggregateFunctionSingleValue<AggregateFunctionsSingleValue, AggregateFunctionAnyLastData>(
name, argument_types, parameters, settings));
}

AggregateFunctionPtr
createAggregateFunctionAny(const std::string & name, const DataTypes & argument_types, const Array & parameters, const Settings * settings)
{
return AggregateFunctionPtr(createAggregateFunctionSingleValue<AggregateFunctionsSingleValue, AggregateFunctionAnyData>(
name, argument_types, parameters, settings));
}

void registerAggregateFunctionsAnyRetract(AggregateFunctionFactory & factory)
{
/// FIXME:actually there is no retraction at all, we just ignore the data whose delta is -1
AggregateFunctionProperties properties = {.returns_default_when_only_null = false, .is_order_dependent = true};
factory.registerFunction("any_last_retract", {createAggregateFunctionAnyLast, properties});
factory.registerFunction("any_retract", {createAggregateFunctionAny, properties});

factory.registerFunction("first_value_retract", {createAggregateFunctionAny, properties}, AggregateFunctionFactory::CaseInsensitive);

factory.registerFunction("last_value_retract", {createAggregateFunctionAnyLast, properties}, AggregateFunctionFactory::CaseInsensitive);

factory.registerFunction("earliest_retract", {createAggregateFunctionAny, properties}, AggregateFunctionFactory::CaseInsensitive);

factory.registerFunction("latest_retract", {createAggregateFunctionAnyLast, properties}, AggregateFunctionFactory::CaseInsensitive);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern const int ILLEGAL_TYPE_OF_ARGUMENT;
namespace Streaming
{
/// Returns the first arg value found for the minimum/maximum value. Example: arg_max(arg, value).
/// There are similar problems and trade off as stated in AggregateFunctionsCountedValue in AggregateFunctionMinMax.h
/// There are similar problems and trade off as stated in AggregateFunctionsCountedValue in AggregateFunctionMinMaxAny.h
/// In changelog mode, we need not only keep track the unique min/max value, but also need keep track the unique argument
/// for each unique value. The following is one example how we keep tracking this in data structure
/// For max sequence (value, arg, delta) and `retract_max = 3`:
Expand Down
2 changes: 1 addition & 1 deletion src/AggregateFunctions/Streaming/AggregateFunctionMax.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "HelpersMinMax.h"
#include "HelpersMinMaxAny.h"

#include <AggregateFunctions/AggregateFunctionFactory.h>

Expand Down
2 changes: 1 addition & 1 deletion src/AggregateFunctions/Streaming/AggregateFunctionMin.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "HelpersMinMax.h"
#include "HelpersMinMaxAny.h"

#include <AggregateFunctions/AggregateFunctionFactory.h>

Expand Down
Loading
Loading