Repository: incubator-hawq Updated Branches: refs/heads/master 54d90913a -> f2066eb4c
HAWQ-827. Refactor aggregate_with_groupingsets checkinstall cases using new test framework. Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/f2066eb4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/f2066eb4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/f2066eb4 Branch: refs/heads/master Commit: f2066eb4ceed998442fad91673cc9f792ca9d466 Parents: 54d9091 Author: hzhang2 <[email protected]> Authored: Fri Jun 17 10:30:28 2016 +0800 Committer: hzhang2 <[email protected]> Committed: Fri Jun 17 10:30:41 2016 +0800 ---------------------------------------------------------------------- src/test/feature/lib/data_gen.cpp | 16 ++++++++++++++++ src/test/feature/lib/data_gen.h | 6 ++++++ src/test/feature/query/test_aggregate.cpp | 11 +++++++++++ 3 files changed, 33 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f2066eb4/src/test/feature/lib/data_gen.cpp ---------------------------------------------------------------------- diff --git a/src/test/feature/lib/data_gen.cpp b/src/test/feature/lib/data_gen.cpp index df19c09..b8fc444 100644 --- a/src/test/feature/lib/data_gen.cpp +++ b/src/test/feature/lib/data_gen.cpp @@ -20,6 +20,22 @@ void DataGenerator::genSimpleTable(string tableName, bool appendonly, sqlUtil->execute(insertSql); } +void DataGenerator::genAggregateTable(string tableName, bool appendonly, + string orientation, + string compresstype, + int compresslevel) { + string desc = + genTableDesc(appendonly, orientation, compresstype, compresslevel); + string createSql = + "create table " + tableName + "(a int, b VARCHAR, c int) " + desc; + sqlUtil->execute(createSql); + + string insertSql = + "insert into " + tableName + " values(1, 'aa', 10), (1, 'bb', 20), " + "(2, 'cc', 20), (3, 'cc', 20);"; + sqlUtil->execute(insertSql); +} + void DataGenerator::genTableWithSeries(string tableName, bool appendonly, string orientation, string compresstype, http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f2066eb4/src/test/feature/lib/data_gen.h ---------------------------------------------------------------------- diff --git a/src/test/feature/lib/data_gen.h b/src/test/feature/lib/data_gen.h index 5c2adae..8a0a352 100644 --- a/src/test/feature/lib/data_gen.h +++ b/src/test/feature/lib/data_gen.h @@ -28,6 +28,12 @@ class DataGenerator { std::string compresstype = "none", int compresslevel = -1); + void genAggregateTable(std::string tableName, + bool appendonly = true, + std::string orientation = "row", + std::string compresstype = "none", + int compresslevel = -1); + void genTableWithFullTypes(std::string tableName, bool appendonly = true, std::string orientation = "row", http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f2066eb4/src/test/feature/query/test_aggregate.cpp ---------------------------------------------------------------------- diff --git a/src/test/feature/query/test_aggregate.cpp b/src/test/feature/query/test_aggregate.cpp index 337ef3c..76f2ede 100644 --- a/src/test/feature/query/test_aggregate.cpp +++ b/src/test/feature/query/test_aggregate.cpp @@ -49,4 +49,15 @@ TEST_F(TestAggregate, TestCreateAggregate) { util.query("select newavg(b) as bavg from t group by a order by bavg","3|\n15|\n62|\n"); } +TEST_F(TestAggregate, TestAggregateWithGroupingsets) { + hawq::test::SQLUtility util; + util.execute("drop table if exists t"); + hawq::test::DataGenerator dGen(&util); + dGen.genAggregateTable("t"); + + util.query("SELECT a, b, sum(c) sum_c FROM (SELECT a, b, c FROM t F1 " + "LIMIT 3) F2 GROUP BY GROUPING SETS((a, b), (b)) ORDER BY a," + " sum_c;", "1|aa|10|\n1|bb|20|\n2|cc|20|\n|aa|10|\n|bb|20|\n|cc|20|\n"); +} +
