aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Storages/StorageMaterializedMySQL.h
blob: e5e9cadb202f036226c0e6c20cc354d9bd4107aa (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once

#include "clickhouse_config.h"

#if USE_MYSQL

#include <Storages/StorageProxy.h>

namespace DB
{

namespace ErrorCodes
{
    extern const int NOT_IMPLEMENTED;
}

class StorageMaterializedMySQL final : public StorageProxy
{
public:
    StorageMaterializedMySQL(const StoragePtr & nested_storage_, const IDatabase * database_);

    String getName() const override { return "MaterializedMySQL"; }

    bool needRewriteQueryWithFinal(const Names & column_names) const override;

    void read(
        QueryPlan & query_plan,
        const Names & column_names,
        const StorageSnapshotPtr & metadata_snapshot,
        SelectQueryInfo & query_info,
        ContextPtr context,
        QueryProcessingStage::Enum processed_stage,
        size_t max_block_size, size_t num_streams) override;

    SinkToStoragePtr write(const ASTPtr &, const StorageMetadataPtr &, ContextPtr, bool) override { throwNotAllowed(); }

    NamesAndTypesList getVirtuals() const override;
    ColumnSizeByName getColumnSizes() const override;

    StoragePtr getNested() const override { return nested_storage; }

    void drop() override { nested_storage->drop(); }

    bool supportsTrivialCountOptimization() const override { return false; }

    IndexSizeByName getSecondaryIndexSizes() const override
    {
        return nested_storage->getSecondaryIndexSizes();
    }

private:
    [[noreturn]] static void throwNotAllowed()
    {
        throw Exception(ErrorCodes::NOT_IMPLEMENTED, "This method is not allowed for MaterializedMySQL");
    }

    StoragePtr nested_storage;
    const IDatabase * database;
};

}

#endif