File tree Expand file tree Collapse file tree 4 files changed +41
-1
lines changed
Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -96,14 +96,15 @@ void TTpcBaseWorkloadGenerator::PatchQuery(TString& query) const {
9696}
9797
9898void TTpcBaseWorkloadGenerator::FilterHeader (IOutputStream& result, TStringBuf header, const TString& query) const {
99+ const TString scaleFactor = " $scale_factor = " + ToString (Params.GetScale ()) + " ;" ;
99100 for (TStringBuf line; header.ReadLine (line);) {
100101 const auto pos = line.find (' =' );
101102 if (pos == line.npos ) {
102103 continue ;
103104 }
104105 const auto name = StripString (line.SubString (0 , pos));
105106 if (name == " $scale_factor" ) {
106- line = " $scale_factor = " + ToString (Params. GetScale ()) + " ; " ;
107+ line = scaleFactor ;
107108 }
108109 for (auto posInQ = query.find (name); posInQ != query.npos ; posInQ = query.find (name, posInQ)) {
109110 posInQ += name.length ();
Original file line number Diff line number Diff line change 1+ #include < ydb/library/workload/tpch/tpch.h>
2+ #include < library/cpp/testing/unittest/registar.h>
3+ #include < library/cpp/regex/pcre/regexp.h>
4+
5+ using namespace NYdbWorkload ;
6+
7+ Y_UNIT_TEST_SUITE (TpchQueries) {
8+ Y_UNIT_TEST (ScaleFactor) {
9+ TTpchWorkloadParams params;
10+ NLastGetopt::TOpts opts;
11+ params.ConfigureOpts (opts, TWorkloadParams::ECommandType::Run, 0 );
12+ const char * args[] = {" ut" , " --scale" , " 10" };
13+ for (auto parser = NLastGetopt::TOptsParser (&opts, sizeof (args)/sizeof (*args), args); parser.Next ();) {
14+ }
15+ auto generator = params.CreateGenerator ();
16+ ui32 query_num = 0 ;
17+ for (const auto & query: generator->GetWorkload (0 )) {
18+ if (query_num == 11 ) {
19+ UNIT_ASSERT_C (TRegExMatch (" \\ $scale_factor\\ s*=\\ s*10\\ s*;" ).Match (query.Query .c_str ()),
20+ " Scale factor is wrong for q11:" << Endl << query.Query );
21+ break ;
22+ }
23+ ++query_num;
24+ }
25+ }
26+ };
Original file line number Diff line number Diff line change 1+ UNITTEST_FOR(ydb/library/workload/tpch)
2+
3+ SIZE(SMALL)
4+
5+ SRCS(queries_ut.cpp)
6+
7+ PEERDIR(
8+ library/cpp/regex/pcre
9+ )
10+
11+ END()
Original file line number Diff line number Diff line change @@ -100,3 +100,5 @@ PEERDIR(
100100)
101101
102102END()
103+
104+ RECURSE_FOR_TESTS(ut)
You can’t perform that action at this time.
0 commit comments