diff options
author | Iuliia Sidorina <yulia@ydb.tech> | 2024-02-19 11:26:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-19 11:26:32 +0100 |
commit | eabc943aef2dff79017222b67911bc4ca7208980 (patch) | |
tree | e429838806cddfebcf90e2436ad6d2133a0c1471 | |
parent | 1e1d8e3d8727403c243169420ec242c636731cbf (diff) | |
download | ydb-eabc943aef2dff79017222b67911bc4ca7208980.tar.gz |
increase default value for GroupByLimit (#1986)
-rw-r--r-- | ydb/core/kqp/ut/opt/kqp_agg_ut.cpp | 78 | ||||
-rw-r--r-- | ydb/library/yql/sql/v0/context.h | 2 | ||||
-rw-r--r-- | ydb/library/yql/sql/v0/sql_ut.cpp | 2 | ||||
-rw-r--r-- | ydb/library/yql/sql/v1/context.h | 2 | ||||
-rw-r--r-- | ydb/library/yql/sql/v1/sql_ut.cpp | 2 |
5 files changed, 82 insertions, 4 deletions
diff --git a/ydb/core/kqp/ut/opt/kqp_agg_ut.cpp b/ydb/core/kqp/ut/opt/kqp_agg_ut.cpp index 2000c73ad02..516192e1e19 100644 --- a/ydb/core/kqp/ut/opt/kqp_agg_ut.cpp +++ b/ydb/core/kqp/ut/opt/kqp_agg_ut.cpp @@ -89,6 +89,84 @@ Y_UNIT_TEST_SUITE(KqpAgg) { [["Value3"];[1]] ])", FormatResultSetYson(result.GetResultSet(0))); } + + Y_UNIT_TEST(GroupByLimit) { + TKikimrRunner kikimr; + auto db = kikimr.GetTableClient(); + auto session = db.CreateSession().GetValueSync().GetSession(); + + AssertSuccessResult(session.ExecuteSchemeQuery(R"( + --!syntax_v1 + + CREATE TABLE `TestTable` ( + a Uint64, + b Uint64, + c Uint64, + d Uint64, + e Uint64, + PRIMARY KEY (a, b, c) + ); + )").GetValueSync()); + + AssertSuccessResult(session.ExecuteDataQuery(R"( + REPLACE INTO `TestTable` (a, b, c, d, e) VALUES + (1, 11, 21, 31, 41), + (2, 12, 22, 32, 42), + (3, 13, 23, 33, 43); + )", TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()).GetValueSync()); + + + { // query with 36 groups and limit 32 + auto result = session.ExecuteDataQuery(R"( + --!syntax_v1 + + PRAGMA GroupByLimit = '32'; + + SELECT a, b, c, d, SUM(e) Data FROM TestTable + GROUP BY ROLLUP(a, b, c, d, a * b AS ab, b * c AS bc, c * d AS cd, a + b AS sum) + ORDER BY a, b, c, d; + )", TTxControl::BeginTx().CommitTx()).ExtractValueSync(); + UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::GENERIC_ERROR); + } + + { // query with 36 groups (without explicit limit) + auto result = session.ExecuteDataQuery(R"( + --!syntax_v1 + + SELECT a, b, c, d, SUM(e) Data FROM TestTable + GROUP BY ROLLUP(a, b, c, d, a * b AS ab, b * c AS bc, c * d AS cd, a + b AS sum) + ORDER BY a, b, c, d; + )", TTxControl::BeginTx().CommitTx()).ExtractValueSync(); + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); + CompareYson(R"([ + [#;#;#;#;[126u]]; + [[1u];#;#;#;[41u]]; + [[1u];[11u];#;#;[41u]]; + [[1u];[11u];[21u];#;[41u]]; + [[1u];[11u];[21u];[31u];[41u]]; + [[1u];[11u];[21u];[31u];[41u]]; + [[1u];[11u];[21u];[31u];[41u]]; + [[1u];[11u];[21u];[31u];[41u]]; + [[1u];[11u];[21u];[31u];[41u]]; + [[2u];#;#;#;[42u]]; + [[2u];[12u];#;#;[42u]]; + [[2u];[12u];[22u];#;[42u]]; + [[2u];[12u];[22u];[32u];[42u]]; + [[2u];[12u];[22u];[32u];[42u]]; + [[2u];[12u];[22u];[32u];[42u]]; + [[2u];[12u];[22u];[32u];[42u]]; + [[2u];[12u];[22u];[32u];[42u]]; + [[3u];#;#;#;[43u]]; + [[3u];[13u];#;#;[43u]]; + [[3u];[13u];[23u];#;[43u]]; + [[3u];[13u];[23u];[33u];[43u]]; + [[3u];[13u];[23u];[33u];[43u]]; + [[3u];[13u];[23u];[33u];[43u]]; + [[3u];[13u];[23u];[33u];[43u]]; + [[3u];[13u];[23u];[33u];[43u]] + ])", FormatResultSetYson(result.GetResultSet(0))); + } + } } } // namespace NKikimr::NKqp diff --git a/ydb/library/yql/sql/v0/context.h b/ydb/library/yql/sql/v0/context.h index 45f40fae61c..b8d8e4bd11d 100644 --- a/ydb/library/yql/sql/v0/context.h +++ b/ydb/library/yql/sql/v0/context.h @@ -152,7 +152,7 @@ namespace NSQLTranslationV0 { bool EnableSystemColumns = true; ui32 ResultRowsLimit = 0; ui64 ResultSizeLimit = 0; - ui32 PragmaGroupByLimit = 1 << 5; + ui32 PragmaGroupByLimit = 1 << 6; ui32 PragmaGroupByCubeLimit = 5; THashSet<TString> Libraries; NYql::TWarningPolicy WarningPolicy; diff --git a/ydb/library/yql/sql/v0/sql_ut.cpp b/ydb/library/yql/sql/v0/sql_ut.cpp index 3a70aef93cc..6ef5cfa5c9a 100644 --- a/ydb/library/yql/sql/v0/sql_ut.cpp +++ b/ydb/library/yql/sql/v0/sql_ut.cpp @@ -1563,7 +1563,7 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { Y_UNIT_TEST(GroupByFewBigCubes) { 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);"); UNIT_ASSERT(!res.Root); - UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Unable to GROUP BY more than 32 groups, you try use 80 groups\n"); + UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Unable to GROUP BY more than 64 groups, you try use 80 groups\n"); } Y_UNIT_TEST(GroupByFewBigCubesWithPragmaLimit) { diff --git a/ydb/library/yql/sql/v1/context.h b/ydb/library/yql/sql/v1/context.h index 26a09ed5dbf..3afa2f1bebf 100644 --- a/ydb/library/yql/sql/v1/context.h +++ b/ydb/library/yql/sql/v1/context.h @@ -281,7 +281,7 @@ namespace NSQLTranslationV1 { bool WarnOnAnsiAliasShadowing = true; ui32 ResultRowsLimit = 0; ui64 ResultSizeLimit = 0; - ui32 PragmaGroupByLimit = 1 << 5; + ui32 PragmaGroupByLimit = 1 << 6; ui32 PragmaGroupByCubeLimit = 5; // if FlexibleTypes=true, emit TypeOrMember callable and resolve Type/Column uncertainty on type annotation stage, otherwise always emit Type bool FlexibleTypes = false; diff --git a/ydb/library/yql/sql/v1/sql_ut.cpp b/ydb/library/yql/sql/v1/sql_ut.cpp index 78a05a85c1d..87f4cc8fa8e 100644 --- a/ydb/library/yql/sql/v1/sql_ut.cpp +++ b/ydb/library/yql/sql/v1/sql_ut.cpp @@ -3428,7 +3428,7 @@ Y_UNIT_TEST_SUITE(SqlToYQLErrors) { Y_UNIT_TEST(GroupByFewBigCubes) { 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);"); UNIT_ASSERT(!res.Root); - UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Unable to GROUP BY more than 32 groups, you try use 80 groups\n"); + UNIT_ASSERT_NO_DIFF(Err2Str(res), "<main>:1:1: Error: Unable to GROUP BY more than 64 groups, you try use 80 groups\n"); } Y_UNIT_TEST(GroupByFewBigCubesWithPragmaLimit) { |