summaryrefslogtreecommitdiffstats
path: root/yql/essentials/public/purecalc/ut/test_compile_settings.cpp
blob: 437f364e2d6fead50c1f318425ef467f3f0b7a84 (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
#include <yql/essentials/public/purecalc/purecalc.h>
#include <yql/essentials/public/purecalc/io_specs/protobuf/spec.h>
#include <yql/essentials/public/purecalc/ut/protos/test_structs.pb.h>
#include <yql/essentials/public/purecalc/ut/empty_stream.h>

#include <library/cpp/testing/unittest/registar.h>

#include "fake_spec.h"

Y_UNIT_TEST_SUITE(TestCompileSettings) {

TString MakeBigSql() {
    TStringBuilder b;
    b << "SELECT * FROM Input WHERE ListLength([";
    for (ui32 i = 0; i < 1000; ++i) {
        b << i << ",";
    }

    b << "]) > 0";
    return b;
}

Y_UNIT_TEST(NodesAllocationLimit) {
    using namespace NYql::NPureCalc;

    auto options = TProgramFactoryOptions();
    options.InternalSettings.NodesAllocationLimit = 10;
    auto factory = MakeProgramFactory(options);

    try {
        factory->MakePullStreamProgram(FakeIS(), FakeOS(), MakeBigSql(), ETranslationMode::SQL);
        UNIT_FAIL("Exception is expected");
    } catch (const TCompileError& e) {
        UNIT_ASSERT_C(e.GetIssues().Contains("Too many allocated nodes"), e.GetIssues());
    }
}

Y_UNIT_TEST(StringsAllocationLimit) {
    using namespace NYql::NPureCalc;

    auto options = TProgramFactoryOptions();
    options.InternalSettings.StringsAllocationLimit = 10;
    auto factory = MakeProgramFactory(options);

    try {
        factory->MakePullStreamProgram(FakeIS(), FakeOS(), MakeBigSql(), ETranslationMode::SQL);
        UNIT_FAIL("Exception is expected");
    } catch (const TCompileError& e) {
        UNIT_ASSERT_C(e.GetIssues().Contains("Too large string pool"), e.GetIssues());
    }
}

Y_UNIT_TEST(RepeatTransformLimit) {
    using namespace NYql::NPureCalc;

    auto options = TProgramFactoryOptions();
    options.InternalSettings.RepeatTransformLimit = 10;
    auto factory = MakeProgramFactory(options);

    try {
        factory->MakePullStreamProgram(FakeIS(), FakeOS(), MakeBigSql(), ETranslationMode::SQL);
        UNIT_FAIL("Exception is expected");
    } catch (const TCompileError& e) {
        UNIT_ASSERT_C(e.GetIssues().Contains("SyncTransform takes too much iterations"), e.GetIssues());
    }
}

} // Y_UNIT_TEST_SUITE(TestCompileSettings)