ClickHouse/src/Interpreters/AggregateDescription.h

73 lines
2.1 KiB
C++
Raw Normal View History

#pragma once
2020-12-09 11:14:40 +00:00
#include <AggregateFunctions/IAggregateFunction.h>
#include <DataTypes/IDataType.h>
#include <Core/ColumnNumbers.h>
#include <Core/Names.h>
2020-12-09 11:14:40 +00:00
#include <Core/SortDescription.h>
#include <Parsers/IAST_fwd.h>
namespace DB
{
2020-12-09 11:14:40 +00:00
class ASTFunction;
struct AggregateDescription
{
AggregateFunctionPtr function;
2017-06-02 21:37:28 +00:00
Array parameters; /// Parameters of the (parametric) aggregate function.
ColumnNumbers arguments;
2017-06-02 21:37:28 +00:00
Names argument_names; /// used if no `arguments` are specified.
String column_name; /// What name to use for a column with aggregate function values
2020-07-07 19:51:32 +00:00
void explain(WriteBuffer & out, size_t indent) const; /// Get description for EXPLAIN query.
};
using AggregateDescriptions = std::vector<AggregateDescription>;
2020-12-09 11:14:40 +00:00
struct WindowFunctionDescription
{
2020-12-18 17:13:28 +00:00
// According to the standard, a window function can refer to a window declared
// elsewhere, using its name. We haven't implemented this yet: all windows
// are declared in OVER clause, but they still get an auto-generated name,
// and this name is used to find the window that corresponds to a function.
2020-12-09 11:14:40 +00:00
std::string window_name;
2020-12-18 17:13:28 +00:00
2020-12-09 11:14:40 +00:00
std::string column_name;
const ASTFunction * function_node;
AggregateFunctionPtr aggregate_function;
Array function_parameters;
DataTypes argument_types;
Names argument_names;
std::string dump() const;
};
struct WindowDescription
{
std::string window_name;
2020-12-18 17:13:28 +00:00
// We don't care about the particular order of keys for PARTITION BY, only
// that they are sorted. For now we always require ASC, but we could be more
// flexible and match any direction, or even different order of columns.
SortDescription partition_by;
2020-12-18 17:13:28 +00:00
SortDescription order_by;
2020-12-18 17:13:28 +00:00
// To calculate the window function, we sort input data first by PARTITION BY,
// then by ORDER BY. This field holds this combined sort order.
SortDescription full_sort_description;
2020-12-18 17:13:28 +00:00
2020-12-09 11:14:40 +00:00
// No frame info as of yet.
std::string dump() const;
2020-12-09 11:14:40 +00:00
};
using WindowFunctionDescriptions = std::vector<WindowFunctionDescription>;
using WindowDescriptions = std::unordered_map<std::string, WindowDescription>;
}