From eeb98a9aa6a4c0fd4b9832061223994284b4b0e9 Mon Sep 17 00:00:00 2001 From: Arseniy Volynets <vol0ncar@yandex.ru> Date: Tue, 30 Jul 2024 12:50:08 +0300 Subject: [PATCH] chore: remove duplicate tests from test_groupby.lua --- .../test/integration/groupby_test.lua | 323 ------------------ 1 file changed, 323 deletions(-) diff --git a/sbroad-cartridge/test_app/test/integration/groupby_test.lua b/sbroad-cartridge/test_app/test/integration/groupby_test.lua index b566436092..437c906180 100644 --- a/sbroad-cartridge/test_app/test/integration/groupby_test.lua +++ b/sbroad-cartridge/test_app/test/integration/groupby_test.lua @@ -1843,83 +1843,6 @@ groupby_queries.test_total_with_groupby = function() }) end -groupby_queries.test_having1 = function() - local api = cluster:server("api-1").net_box - - -- with having - local r, err = api:call("sbroad.execute", { - [[ - SELECT "a", sum("b") as "sum" from "arithmetic_space" - group by "a" - having sum("b") > 5 - ]], {} - }) - t.assert_equals(err, nil) - t.assert_equals(r.metadata, { - { name = "a", type = "integer" }, - { name = "sum", type = "decimal" } - }) - t.assert_items_equals(r.rows, { - {2, 6} - }) - -- without having - r, err = api:call("sbroad.execute", { - [[ - SELECT "a", sum("b") as "sum" from "arithmetic_space" - group by "a" - ]], {} - }) - t.assert_equals(err, nil) - t.assert_equals(r.metadata, { - { name = "a", type = "integer" }, - { name = "sum", type = "decimal" } - }) - t.assert_items_equals(r.rows, { - {2, 6}, - {1, 3} - }) -end - -groupby_queries.test_having2 = function() - local api = cluster:server("api-1").net_box - - local r, err = api:call("sbroad.execute", { - [[ - SELECT "a", sum("b") as "sum" from "arithmetic_space" - group by "a" - having "a" = 1 - ]], {} - }) - t.assert_equals(err, nil) - t.assert_equals(r.metadata, { - { name = "a", type = "integer" }, - { name = "sum", type = "decimal" } - }) - t.assert_items_equals(r.rows, { - {1, 3} - }) -end - -groupby_queries.test_having3 = function() - local api = cluster:server("api-1").net_box - - local r, err = api:call("sbroad.execute", { - [[ - SELECT "boolean_col", sum(distinct "f") as "sum" from "arithmetic_space" - group by "boolean_col" - having "boolean_col" = true - ]], {} - }) - t.assert_equals(err, nil) - t.assert_equals(r.metadata, { - { name = "boolean_col", type = "boolean" }, - { name = "sum", type = "decimal" } - }) - t.assert_items_equals(r.rows, { - {true, 2} - }) -end - groupby_queries.test_having_with_sq = function() local api = cluster:server("api-1").net_box local query_str = [[ @@ -1957,252 +1880,6 @@ groupby_queries.test_having_with_sq = function() }) end -groupby_queries.test_having_no_groupby = function() - local api = cluster:server("api-1").net_box - - -- having condition is true - local r, err = api:call("sbroad.execute", { - [[ - SELECT sum("a"), sum(distinct "a"), count("a"), count(distinct "a") from "arithmetic_space" - having count(distinct "a") > 1 - ]], {} - }) - t.assert_equals(err, nil) - -- todo: if executed on single tarantool instance, types are: (integer, integer, integer, integer) - t.assert_equals(r.metadata, { - { name = "COL_1", type = "decimal" }, - { name = "COL_2", type = "decimal" }, - { name = "COL_3", type = "decimal" }, - { name = "COL_4", type = "integer" }, - }) - t.assert_items_equals(r.rows, { - {6, 3, 4, 2} - }) - -- having condition is false - r, err = api:call("sbroad.execute", { - [[ - SELECT sum("a"), sum(distinct "a"), count("a"), count(distinct "a") from "arithmetic_space" - having count(distinct "a") > 100 - ]], {} - }) - t.assert_equals(err, nil) - t.assert_equals(r.metadata, { - { name = "COL_1", type = "decimal" }, - { name = "COL_2", type = "decimal" }, - { name = "COL_3", type = "decimal" }, - { name = "COL_4", type = "integer" }, - }) - t.assert_items_equals(r.rows, {}) -end - -groupby_queries.test_having_selection = function() - local api = cluster:server("api-1").net_box - - -- with having - local r, err = api:call("sbroad.execute", { - [[ - SELECT "string_col", count(distinct "string_col"), count("string_col") - from "arithmetic_space" - where "id" > 2 or "string_col" = 'a' - group by "string_col" - having sum(distinct "a") > 1 - ]], {} - }) - t.assert_equals(err, nil) - t.assert_equals(r.metadata, { - { name = "string_col", type = "string" }, - { name = "COL_1", type = "integer" }, - { name = "COL_2", type = "decimal" } - }) - t.assert_items_equals(r.rows, { - { 'c', 1, 2 } - }) - -- without having - r, err = api:call("sbroad.execute", { - [[ - SELECT "string_col", count(distinct "string_col"), count("string_col") - from "arithmetic_space" - where "id" > 2 or "string_col" = 'a' - group by "string_col" - ]], {} - }) - t.assert_equals(err, nil) - t.assert_equals(r.metadata, { - { name = "string_col", type = "string" }, - { name = "COL_1", type = "integer" }, - { name = "COL_2", type = "decimal" } - }) - t.assert_items_equals(r.rows, { - { 'a', 1, 2 }, - { 'c', 1, 2 } - }) -end - -groupby_queries.test_having_join = function() - local api = cluster:server("api-1").net_box - - local r, err = api:call("sbroad.execute", { - [[ - SELECT sum(distinct "a"), "b", s - from "arithmetic_space" as t1 inner join - ( - select cast(sum("a") / 6 as integer) as s - from "arithmetic_space2" - having count(distinct "a") > 1 - ) as t2 - on t1."c" = t2.s - group by s, t1."b" - having sum(distinct "a") in (2, 3) and count(distinct t2.s) = 1 - ]], {} - }) - t.assert_equals(err, nil) - t.assert_equals(r.metadata, { - { name = "COL_1", type = "decimal" }, - { name = "b", type = "integer" }, - { name = "S", type = "integer" } - }) - t.assert_items_equals(r.rows, { - { 2, 3, 1 } - }) -end - -groupby_queries.test_having_full_query = function() - local api = cluster:server("api-1").net_box - - -- data after join + where - local r, err = api:call("sbroad.execute", { - [[ - SELECT t1."a", t2.b, t2.s, t1."d" - from "arithmetic_space" as t1 inner join - (select "b" as b, "string_col" as s from "arithmetic_space2") as t2 - on t1."a" = t2.b - where t1."d" + t1."a" > 2 - ]], {} - }) - t.assert_equals(err, nil) - t.assert_equals(r.metadata, { - { name = "T1.a", type = "integer" }, - { name = "T2.B", type = "integer" }, - { name = "T2.S", type = "string" }, - { name = "T1.d", type = "integer" }, - }) - t.assert_items_equals(r.rows, { - {1, 1, "a", 2}, - {1, 1, "b", 2}, - {1, 1, "b", 2}, - {2, 2, "a", 2}, - {2, 2, "a", 1}, - }) - r, err = api:call("sbroad.execute", { - [[ - SELECT t1."a", count(distinct s) - from "arithmetic_space" as t1 inner join - (select "b" as b, "string_col" as s from "arithmetic_space2") as t2 - on t1."a" = t2.b - where t1."d" + t1."a" > 2 - group by "a" - having count(distinct s) > 1 - ]], {} - }) - t.assert_equals(err, nil) - t.assert_equals(r.metadata, { - { name = "a", type = "integer" }, - { name = "COL_1", type = "integer" }, - }) - t.assert_items_equals(r.rows, { - { 1, 2 } - }) -end - -groupby_queries.test_having_inside_union = function() - local api = cluster:server("api-1").net_box - - local r, err = api:call("sbroad.execute", { - [[ - select sum(distinct "e") from "arithmetic_space" - having count(distinct "d") > 1 - union all - select "b" from "arithmetic_space" - group by "b" - having count(distinct "d") > 1 - ]], {} - }) - t.assert_equals(err, nil) - t.assert_equals(r.metadata, { - { name = "COL_1", type = "decimal" }, - }) - t.assert_items_equals(r.rows, { - {2}, - {3} - }) -end - -groupby_queries.test_having_inside_union1 = function() - local api = cluster:server("api-1").net_box - - local r, err = api:call("sbroad.execute", { - [[ - select "e" from "arithmetic_space" - union all - select "b" from "arithmetic_space" - group by "b" - having count(distinct "d") > 1 - ]], {} - }) - t.assert_equals(err, nil) - t.assert_equals(r.metadata, { - { name = "e", type = "integer" }, - }) - t.assert_items_equals(r.rows, { - {2}, - {2}, - {2}, - {2}, - {3} - }) -end - -groupby_queries.test_having_inside_except = function() - local api = cluster:server("api-1").net_box - - local r, err = api:call("sbroad.execute", { - [[ - select count("e") - 1 from "arithmetic_space" - having count("e") = 4 - except - select "b" from "arithmetic_space" - group by "b" - having count(distinct "d") > 1 - ]], {} - }) - t.assert_equals(err, nil) - t.assert_equals(r.metadata, { - { name = "COL_1", type = "decimal" }, - }) - t.assert_items_equals(r.rows, {}) -end - -groupby_queries.test_having_inside_except1 = function() - local api = cluster:server("api-1").net_box - - local r, err = api:call("sbroad.execute", { - [[ - select "d" from "arithmetic_space" - group by "d" - except - select sum(distinct "c") from "arithmetic_space" - having count(distinct "c") = 1 - ]], {} - }) - t.assert_equals(err, nil) - t.assert_equals(r.metadata, { - { name = "d", type = "integer" }, - }) - t.assert_items_equals(r.rows, { - {2}, - }) -end - groupby_queries.test_having1 = function() local api = cluster:server("api-1").net_box -- GitLab