aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/core/yql_udf_resolver.h
blob: 9b6bf4f8eec7e4c4d23e153e558dfa373f2d87d6 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once

#include "yql_user_data.h"
#include <yql/essentials/providers/common/proto/udf_resolver.pb.h>

#include <yql/essentials/public/issue/yql_issue.h>

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

namespace NYql {

class TTypeAnnotationNode;
struct TUserDataBlock;
struct TExprContext;

struct TFilePathWithMd5 {
    TString Path;
    TString Md5;

    explicit TFilePathWithMd5(const TString& path = "", const TString& md5 = "")
        : Path(path)
        , Md5(md5)
    {
    }

    TFilePathWithMd5& operator=(const TFilePathWithMd5& other) = default;
};

class IUdfResolver : public TThrRefBase {
public:
    using TPtr = TIntrusiveConstPtr<IUdfResolver>;

    virtual ~IUdfResolver() = default;

    struct TFunction {
        // input
        TPosition Pos;
        TString Name;
        TString TypeConfig;
        const TTypeAnnotationNode* UserType = nullptr;
        THashMap<TString, TString> SecureParams;

        // output
        TString NormalizedName;
        const TTypeAnnotationNode* NormalizedUserType = nullptr;
        const TTypeAnnotationNode* RunConfigType = nullptr;
        const TTypeAnnotationNode* CallableType = nullptr;
        bool SupportsBlocks = false;
        bool IsStrict = false;
    };

    struct TImport {
        // input
        TPosition Pos;
        TString FileAlias;
        const TUserDataBlock* Block = nullptr;

        // output
        TMaybe<TVector<TString>> Modules;
    };

    /*
    Returns nothing if module is not a system one
    Always returns frozen path
    */
    virtual TMaybe<TFilePathWithMd5> GetSystemModulePath(const TStringBuf& moduleName) const = 0;
    virtual bool LoadMetadata(const TVector<TImport*>& imports,
        const TVector<TFunction*>& functions, TExprContext& ctx) const = 0;

    virtual TResolveResult LoadRichMetadata(const TVector<TImport>& imports) const = 0;
    virtual bool ContainsModule(const TStringBuf& moduleName) const = 0;
};

TResolveResult LoadRichMetadata(const IUdfResolver& resolver, const TVector<TUserDataBlock>& blocks);
TResolveResult LoadRichMetadata(const IUdfResolver& resolver, const TVector<TString>& paths);

}