summaryrefslogtreecommitdiffstats
path: root/yt/yql/providers/ytflow/integration/interface/yql_ytflow_optimization.h
blob: 1fd06e9129aa80cc6b0151ade0afa1b3d1615e47 (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
#pragma once

#include <yql/essentials/ast/yql_expr.h>


namespace NYql {

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

    /**
        Apply new members subset for YtflowReadWrap's underlying provider specific read callable
        Args:
            * read - provider specific read callable
            * members - expr list of atoms with new members
            * ctx - expr context
        Returns one of:
            * empty TPtr on error
            * original `read`, if no changes
            * new read with applied new members
    */
    virtual TExprNode::TPtr ApplyExtractMembers(
        const TExprNode::TPtr& read,
        const TExprNode::TPtr& members,
        TExprContext& ctx) = 0;

    /**
        Apply `unordered` setting for YtflowReadWrap's underlying provider specific read callable
        Args:
            * read - provider specific read callable
            * ctx - expr context
        Returns one of:
            * empty TPtr on error
            * original `read`, if no changes
            * new read with applied setting
    */
    virtual TExprNode::TPtr ApplyUnordered(
        const TExprNode::TPtr& read,
        TExprContext& ctx) = 0;

    /**
        Rewrite YtflowWriteWrap's underlying provider specific write callable
        Args:
            * write - provider specific write callable
            * ctx - expr context
        Returns one of:
            * empty TPtr on error
            * original `write`, if no changes
            * new write with trimmed content
    */
    virtual TExprNode::TPtr TrimWriteContent(
        const TExprNode::TPtr& write,
        TExprContext& ctx) = 0;
};

// Non-operational base which enables descendants to provide only partial functionality
class TEmptyYtflowOptimization
    : public IYtflowOptimization
{
public:
    TExprNode::TPtr ApplyExtractMembers(
        const TExprNode::TPtr& read,
        const TExprNode::TPtr& members,
        TExprContext& ctx) override;

    TExprNode::TPtr ApplyUnordered(
        const TExprNode::TPtr& read,
        TExprContext& ctx) override;

    TExprNode::TPtr TrimWriteContent(
        const TExprNode::TPtr& write,
        TExprContext& ctx) override;
};

} // namespace NYql