mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 10:52:30 +00:00
264cff6415
TODO (suggested by Nikolai) 1. Build query plan fro current query (inside storage::read) up to WithMergableState 2. Check, that plan is simple enough: Aggregating - Expression - Filter - ReadFromStorage (or simplier) 3. Check, that filter is the same as filter in projection, and also expression calculates the same aggregation keys as in projection 4. Return WithMergableState if projection applies 3 will be easier to do with ActionsDAG, cause it sees all functions, and dependencies are direct (but it is possible with ExpressionActions also) Also need to figure out how prewhere works for projections, and row_filter_policies. wip
61 lines
1.5 KiB
C++
61 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <Common/SipHash.h>
|
|
#include <common/types.h>
|
|
#include <unordered_set>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/// Represents dependency from other column.
|
|
/// Used to determine, which columns we have to read, if we want to update some other column.
|
|
/// Necessary, because table can have some dependencies, which requires several columns for calculation.
|
|
struct ColumnDependency
|
|
{
|
|
enum Kind : UInt8
|
|
{
|
|
/// Exists any skip index, that requires @column_name
|
|
SKIP_INDEX,
|
|
|
|
/// Exists any projection, that requires @column_name
|
|
PROJECTION,
|
|
|
|
/// Exists any TTL expression, that requires @column_name
|
|
TTL_EXPRESSION,
|
|
|
|
/// TTL is set for @column_name.
|
|
TTL_TARGET
|
|
};
|
|
|
|
ColumnDependency(const String & column_name_, Kind kind_)
|
|
: column_name(column_name_), kind(kind_) {}
|
|
|
|
String column_name;
|
|
Kind kind;
|
|
|
|
bool isReadOnly() const
|
|
{
|
|
return kind == SKIP_INDEX || kind == PROJECTION || kind == TTL_EXPRESSION;
|
|
}
|
|
|
|
bool operator==(const ColumnDependency & other) const
|
|
{
|
|
return kind == other.kind && column_name == other.column_name;
|
|
}
|
|
|
|
struct Hash
|
|
{
|
|
UInt64 operator()(const ColumnDependency & dependency) const
|
|
{
|
|
SipHash hash;
|
|
hash.update(dependency.column_name);
|
|
hash.update(dependency.kind);
|
|
return hash.get64();
|
|
}
|
|
};
|
|
};
|
|
|
|
using ColumnDependencies = std::unordered_set<ColumnDependency, ColumnDependency::Hash>;
|
|
|
|
}
|