aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Interpreters/TableOverrideUtils.h
blob: 810ffecd57357550c84ec9f822a2830b424fa55f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once

#include <Common/assert_cast.h>
#include <Core/Names.h>
#include <Core/NamesAndTypes.h>
#include <Parsers/ASTTableOverrides.h>

namespace DB
{

struct StorageInMemoryMetadata;

using NameToTypeMap = std::map<String, DataTypePtr>;

struct TableOverrideAnalyzer
{
    struct Result
    {
        NameToTypeMap existing_types;
        NamesAndTypes order_by_columns;
        NamesAndTypes primary_key_columns;
        NamesAndTypes partition_by_columns;
        NamesAndTypes sample_by_columns;
        NamesAndTypes ttl_columns;
        NamesAndTypes added_columns;
        NamesAndTypes modified_columns;

        void appendTo(WriteBuffer &);
    };

    ASTTableOverride * override;

    explicit TableOverrideAnalyzer(ASTPtr ast) : override(assert_cast<ASTTableOverride *>(ast.get())) { }

    void analyze(const StorageInMemoryMetadata & metadata, Result & result) const;
};

}