Skip to content

Commit eabc943

Browse files
increase default value for GroupByLimit (#1986)
1 parent 1e1d8e3 commit eabc943

File tree

5 files changed

+82
-4
lines changed

5 files changed

+82
-4
lines changed

ydb/core/kqp/ut/opt/kqp_agg_ut.cpp

+78
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,84 @@ Y_UNIT_TEST_SUITE(KqpAgg) {
8989
[["Value3"];[1]]
9090
])", FormatResultSetYson(result.GetResultSet(0)));
9191
}
92+
93+
Y_UNIT_TEST(GroupByLimit) {
94+
TKikimrRunner kikimr;
95+
auto db = kikimr.GetTableClient();
96+
auto session = db.CreateSession().GetValueSync().GetSession();
97+
98+
AssertSuccessResult(session.ExecuteSchemeQuery(R"(
99+
--!syntax_v1
100+
101+
CREATE TABLE `TestTable` (
102+
a Uint64,
103+
b Uint64,
104+
c Uint64,
105+
d Uint64,
106+
e Uint64,
107+
PRIMARY KEY (a, b, c)
108+
);
109+
)").GetValueSync());
110+
111+
AssertSuccessResult(session.ExecuteDataQuery(R"(
112+
REPLACE INTO `TestTable` (a, b, c, d, e) VALUES
113+
(1, 11, 21, 31, 41),
114+
(2, 12, 22, 32, 42),
115+
(3, 13, 23, 33, 43);
116+
)", TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()).GetValueSync());
117+
118+
119+
{ // query with 36 groups and limit 32
120+
auto result = session.ExecuteDataQuery(R"(
121+
--!syntax_v1
122+
123+
PRAGMA GroupByLimit = '32';
124+
125+
SELECT a, b, c, d, SUM(e) Data FROM TestTable
126+
GROUP BY ROLLUP(a, b, c, d, a * b AS ab, b * c AS bc, c * d AS cd, a + b AS sum)
127+
ORDER BY a, b, c, d;
128+
)", TTxControl::BeginTx().CommitTx()).ExtractValueSync();
129+
UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::GENERIC_ERROR);
130+
}
131+
132+
{ // query with 36 groups (without explicit limit)
133+
auto result = session.ExecuteDataQuery(R"(
134+
--!syntax_v1
135+
136+
SELECT a, b, c, d, SUM(e) Data FROM TestTable
137+
GROUP BY ROLLUP(a, b, c, d, a * b AS ab, b * c AS bc, c * d AS cd, a + b AS sum)
138+
ORDER BY a, b, c, d;
139+
)", TTxControl::BeginTx().CommitTx()).ExtractValueSync();
140+
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
141+
CompareYson(R"([
142+
[#;#;#;#;[126u]];
143+
[[1u];#;#;#;[41u]];
144+
[[1u];[11u];#;#;[41u]];
145+
[[1u];[11u];[21u];#;[41u]];
146+
[[1u];[11u];[21u];[31u];[41u]];
147+
[[1u];[11u];[21u];[31u];[41u]];
148+
[[1u];[11u];[21u];[31u];[41u]];
149+
[[1u];[11u];[21u];[31u];[41u]];
150+
[[1u];[11u];[21u];[31u];[41u]];
151+
[[2u];#;#;#;[42u]];
152+
[[2u];[12u];#;#;[42u]];
153+
[[2u];[12u];[22u];#;[42u]];
154+
[[2u];[12u];[22u];[32u];[42u]];
155+
[[2u];[12u];[22u];[32u];[42u]];
156+
[[2u];[12u];[22u];[32u];[42u]];
157+
[[2u];[12u];[22u];[32u];[42u]];
158+
[[2u];[12u];[22u];[32u];[42u]];
159+
[[3u];#;#;#;[43u]];
160+
[[3u];[13u];#;#;[43u]];
161+
[[3u];[13u];[23u];#;[43u]];
162+
[[3u];[13u];[23u];[33u];[43u]];
163+
[[3u];[13u];[23u];[33u];[43u]];
164+
[[3u];[13u];[23u];[33u];[43u]];
165+
[[3u];[13u];[23u];[33u];[43u]];
166+
[[3u];[13u];[23u];[33u];[43u]]
167+
])", FormatResultSetYson(result.GetResultSet(0)));
168+
}
169+
}
92170
}
93171

94172
} // namespace NKikimr::NKqp

ydb/library/yql/sql/v0/context.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ namespace NSQLTranslationV0 {
152152
bool EnableSystemColumns = true;
153153
ui32 ResultRowsLimit = 0;
154154
ui64 ResultSizeLimit = 0;
155-
ui32 PragmaGroupByLimit = 1 << 5;
155+
ui32 PragmaGroupByLimit = 1 << 6;
156156
ui32 PragmaGroupByCubeLimit = 5;
157157
THashSet<TString> Libraries;
158158
NYql::TWarningPolicy WarningPolicy;

ydb/library/yql/sql/v0/sql_ut.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) {
15631563
Y_UNIT_TEST(GroupByFewBigCubes) {
15641564
NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input GROUP BY CUBE(key, subkey, key + subkey as sum), CUBE(value, value + key + subkey as total);");
15651565
UNIT_ASSERT(!res.Root);
1566-
UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Unable to GROUP BY more than 32 groups, you try use 80 groups\n");
1566+
UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Unable to GROUP BY more than 64 groups, you try use 80 groups\n");
15671567
}
15681568

15691569
Y_UNIT_TEST(GroupByFewBigCubesWithPragmaLimit) {

ydb/library/yql/sql/v1/context.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ namespace NSQLTranslationV1 {
281281
bool WarnOnAnsiAliasShadowing = true;
282282
ui32 ResultRowsLimit = 0;
283283
ui64 ResultSizeLimit = 0;
284-
ui32 PragmaGroupByLimit = 1 << 5;
284+
ui32 PragmaGroupByLimit = 1 << 6;
285285
ui32 PragmaGroupByCubeLimit = 5;
286286
// if FlexibleTypes=true, emit TypeOrMember callable and resolve Type/Column uncertainty on type annotation stage, otherwise always emit Type
287287
bool FlexibleTypes = false;

ydb/library/yql/sql/v1/sql_ut.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3428,7 +3428,7 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) {
34283428
Y_UNIT_TEST(GroupByFewBigCubes) {
34293429
NYql::TAstParseResult res = SqlToYql("SELECT key FROM plato.Input GROUP BY CUBE(key, subkey, key + subkey as sum), CUBE(value, value + key + subkey as total);");
34303430
UNIT_ASSERT(!res.Root);
3431-
UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Unable to GROUP BY more than 32 groups, you try use 80 groups\n");
3431+
UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Unable to GROUP BY more than 64 groups, you try use 80 groups\n");
34323432
}
34333433

34343434
Y_UNIT_TEST(GroupByFewBigCubesWithPragmaLimit) {

0 commit comments

Comments
 (0)