aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Functions/UserDefined/IUserDefinedSQLObjectsLoader.h
blob: 4c7850951b585e0d66bfb575be71ced05a4438ec (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
#pragma once

#include <base/types.h>


namespace DB
{
class IAST;
struct Settings;
enum class UserDefinedSQLObjectType;

/// Interface for a loader of user-defined SQL objects.
/// Implementations: UserDefinedSQLLoaderFromDisk, UserDefinedSQLLoaderFromZooKeeper
class IUserDefinedSQLObjectsLoader
{
public:
    virtual ~IUserDefinedSQLObjectsLoader() = default;

    /// Whether this loader can replicate SQL objects to another node.
    virtual bool isReplicated() const { return false; }
    virtual String getReplicationID() const { return ""; }

    /// Loads all objects. Can be called once - if objects are already loaded the function does nothing.
    virtual void loadObjects() = 0;

    /// Stops watching.
    virtual void stopWatching() {}

    /// Immediately reloads all objects, throws an exception if failed.
    virtual void reloadObjects() = 0;

    /// Immediately reloads a specified object only.
    virtual void reloadObject(UserDefinedSQLObjectType object_type, const String & object_name) = 0;

    /// Stores an object (must be called only by UserDefinedSQLFunctionFactory::registerFunction).
    virtual bool storeObject(
        UserDefinedSQLObjectType object_type,
        const String & object_name,
        const IAST & create_object_query,
        bool throw_if_exists,
        bool replace_if_exists,
        const Settings & settings) = 0;

    /// Removes an object (must be called only by UserDefinedSQLFunctionFactory::unregisterFunction).
    virtual bool removeObject(UserDefinedSQLObjectType object_type, const String & object_name, bool throw_if_not_exists) = 0;
};
}