aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/complete/name/object/schema.h
blob: 687f92d7e8a51beefa1becd3d377a821c97f6366 (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
#pragma once

#include <library/cpp/threading/future/core/future.h>

#include <util/generic/string.h>
#include <util/generic/vector.h>
#include <util/generic/hash_set.h>
#include <util/generic/maybe.h>

namespace NSQLComplete {

    struct TFolderEntry {
        static constexpr const char* Folder = "Folder";
        static constexpr const char* Table = "Table";

        TString Type;
        TString Name;

        friend bool operator==(const TFolderEntry& lhs, const TFolderEntry& rhs) = default;
    };

    struct TListFilter {
        TMaybe<THashSet<TString>> Types;
    };

    struct TListRequest {
        TString Cluster;

        // `Path` structure is defined by a `System`.
        // Can end with a folder entry name hint.
        // For example, `/local/exa` lists a folder `/local`,
        // but can rank and filter entries by a hint `exa`.
        TString Path;

        TListFilter Filter;
        size_t Limit = 128;
    };

    struct TListResponse {
        size_t NameHintLength = 0;
        TVector<TFolderEntry> Entries;
    };

    class ISchema: public TThrRefBase {
    public:
        using TPtr = TIntrusivePtr<ISchema>;

        virtual ~ISchema() = default;
        virtual NThreading::TFuture<TListResponse> List(const TListRequest& request) const = 0;
    };

} // namespace NSQLComplete