Repository: incubator-hawq Updated Branches: refs/heads/master f5b0cadb9 -> ab5fc167e
HAWQ-801 Refactor create_aggregate 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/ab5fc167 Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/ab5fc167 Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/ab5fc167 Branch: refs/heads/master Commit: ab5fc167ef88156e85ace9df42cc3b58dcd3031c Parents: f5b0cad Author: hzhang2 <[email protected]> Authored: Wed Jun 15 10:02:37 2016 +0800 Committer: hzhang2 <[email protected]> Committed: Wed Jun 15 10:04:37 2016 +0800 ---------------------------------------------------------------------- src/test/feature/query/test_aggregate.cpp | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ab5fc167/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 new file mode 100644 index 0000000..f8f93e9 --- /dev/null +++ b/src/test/feature/query/test_aggregate.cpp @@ -0,0 +1,52 @@ +#include <pwd.h> +#include <sys/types.h> +#include <unistd.h> +#include <vector> +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <iostream> + +#include "lib/command.h" +#include "lib/data_gen.h" +#include "lib/hawq_config.h" +#include "lib/sql_util.h" + +#include "gtest/gtest.h" + +class TestAggregate : public ::testing::Test { + public: + TestAggregate() {} + ~TestAggregate() {} +}; + +TEST_F(TestAggregate, TestCreateAggregate) { + hawq::test::SQLUtility util; + + // create a basic aggregate + util.execute("CREATE AGGREGATE newavg (sfunc = int8_avg_accum," + " basetype = int8, stype = bytea, finalfunc = int8_avg," + " initcond1 = '{0}');", true); + + // create a full featured aggregate including schema. + util.execute("create schema testaggregateschema;"); + util.execute("CREATE AGGREGATE testaggregateschema.newavg (" + "sfunc = int8_avg_accum, basetype = int8, stype = bytea," + " finalfunc = int8_avg, initcond1 = '{0}');", true); + util.execute("drop schema testaggregateschema cascade;"); + + // multi argument aggregate + util.execute("create function sum3(int8,int8,int8) returns int8 as " + "'select \\$1 + \\$2 + \\$3' language sql strict immutable;",true); + util.execute("create ordered aggregate sum2(int8,int8) ( sfunc = sum3, " + "stype = int8, initcond = '0');", true); + + // test basic aggregate + util.execute("drop table if exists t"); + hawq::test::DataGenerator dGen(&util); + dGen.genSimpleTable("t"); + util.query("select avg(b) from t group by a","3|\n62|\n15|\n"); + util.query("select newavg(b) from t group by a","3|\n15|\n62|\n"); +} + +
