aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/providers/pg/provider/yql_pg_dq_integration.cpp
blob: 263e0fe3105c7d6946c81acde4a1c5856ba1cecc (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
#include "yql_pg_provider_impl.h"
#include <yql/essentials/providers/common/dq/yql_dq_integration_impl.h>
#include <yql/essentials/providers/pg/expr_nodes/yql_pg_expr_nodes.h>

namespace NYql {

using namespace NNodes;

namespace {

class TPgDqIntegration: public TDqIntegrationBase {
public:
    TPgDqIntegration(TPgState::TPtr state)
        : State_(state)
    {}

    bool CanRead(const TExprNode& read, TExprContext&, bool) override {
        return TPgReadTable::Match(&read);
    }

    TMaybe<ui64> EstimateReadSize(ui64 /*dataSizePerJob*/, ui32 /*maxTasksPerStage*/, const TVector<const TExprNode*>& read, TExprContext&) override {
        if (AllOf(read, [](const auto val) { return TPgReadTable::Match(val); })) {
            return 0ul;
        }
        return Nothing();
    }

    ui64 Partition(const TExprNode&, TVector<TString>& partitions, TString*, TExprContext&, const TPartitionSettings&) override {
        partitions.clear();
        partitions.emplace_back();
        return 0ULL;
    }

private:
    const TPgState::TPtr State_;
};

}

THolder<IDqIntegration> CreatePgDqIntegration(TPgState::TPtr state) {
    return MakeHolder<TPgDqIntegration>(state);
}

}