summaryrefslogtreecommitdiffstats
path: root/yql/essentials/core/poly_args/yql_poly_args.h
blob: fdab43143d90c6c9ae98df6e280ab039fd801977 (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
#pragma once
#include <library/cpp/yson/node/node.h>
#include <yql/essentials/public/langver/yql_langver.h>

namespace NYql {

class TConfigException: public yexception {};

class IPolyArgs {
public:
    virtual ~IPolyArgs() = default;

    using TArgs = THashMap<TString, NYT::TNode>;

    struct TUnresolvedInput {
        TMaybe<TVector<NYT::TNode>> UserTypeArgs;
        TLangVersion LangVer = MinLangVersion;
    };

    virtual ui32 GetPredicatesCount() const = 0;
    virtual TMaybe<TUnresolvedInput> GetUnresolvedInput(ui32 index) const = 0;

    struct TMatchResult {
        ui32 Index = Max<ui32>();
        TMaybe<NYT::TNode> CallableType;
        TMaybe<NYT::TNode> RunConfigType;
        TMaybe<TString> Error;
    };

    // may fill callable type if specified, otherwise resolved callable type should be used
    // returns index of first matched predicate
    virtual TMatchResult Match(const TArgs& args, TLangVersion version) const = 0;
};

std::unique_ptr<IPolyArgs> ParsePolyArgs(const NYT::TNode& config);

} // namespace NYql