Adjust expected results and add in describe table

This commit is contained in:
Brett Hazen 2015-12-17 20:44:58 -07:00
parent bebf57dcea
commit 7e2938878d
4 changed files with 59 additions and 19 deletions

View File

@ -36,21 +36,21 @@ confirm() ->
Qry = "SELECT SUM(mybool) FROM " ++ Bucket,
ClusterConn = {_Cluster, Conn} = ts_util:cluster_and_connect(single),
Got = ts_util:ts_query(ClusterConn, TestType, DDL, Data, Qry, Bucket),
?assertEqual(Got, some_error_value),
?assertEqual(some_error_value, Got),
Qry2 = "SELECT AVG(myfamily) FROM " ++ Bucket,
Got2 = ts_util:single_query(Conn, Qry2),
?assertEqual(Got2, some_error_value),
?assertEqual(some_error_value, Got2),
Qry3 = "SELECT MIN(myseries) FROM " ++ Bucket,
Got3 = ts_util:single_query(Conn, Qry3),
?assertEqual(Got3, some_error_value),
?assertEqual(some_error_value, Got3),
Qry4 = "SELECT MAX(mytimestamp) FROM " ++ Bucket,
Got4 = ts_util:single_query(Conn, Qry4),
?assertEqual(Got4, some_error_value),
?assertEqual(some_error_value, Got4),
Qry5 = "SELECT STDDEV(mybool) FROM " ++ Bucket,
Got5 = ts_util:single_query(Conn, Qry5),
?assertEqual(Got5, some_error_value),
?assertEqual(some_error_value, Got5),
pass.

View File

@ -41,23 +41,23 @@ confirm() ->
FilteredTemp = lists:filter(fun(X) -> case X>10 of true -> true; _ -> false end end, Column4),
FilteredSum4 = lists:sum(FilteredTemp),
{_, Got} = ts_util:ts_query(ClusterConn, TestType, DDL, Data, Qry, Bucket),
?assertEqual(Got, (FilteredSum4/length(FilteredTemp)) * (9/5) + 32),
?assertEqual((FilteredSum4/length(FilteredTemp)) * (9/5) + 32, Got),
Qry2 = "SELECT SUM(pressure/precipitation) FROM " ++ Bucket,
{_, Got2} = ts_util:single_query(Conn, Qry2),
SumDiv = lists:sum([Press/Precip || {Press, Precip} <- lists:zip(Column5, Column6)]),
?assertEqual(Got2, SumDiv),
?assertEqual(SumDiv, Got2),
Qry3 = "SELECT 3+5, 2.0+8, 9/2, 9.0/2 FROM " ++ Bucket,
{_, Got3} = ts_util:single_query(Conn, Qry3),
Math = [[8, 10.0, 4, 4.5] || _ <- lists:seq(1, Count)],
?assertEqual(Got3, Math),
?assertEqual(Math, Got3),
Qry4 = "SELECT SUM(temperature+10), AVG(pressure)/10 FROM " ++ Bucket,
{_, Got4} = ts_util:single_query(Conn, Qry4),
SumPlus = lists:sum([X+10 || X<-Column4]),
AvgDiv = lists:sum(Column5)/Count/10,
?assertEqual(Got4, [SumPlus, AvgDiv]),
?assertEqual([SumPlus, AvgDiv], Got4),
pass.

View File

@ -51,44 +51,44 @@ verify_aggregation(ClusterType) ->
Qry = "SELECT COUNT(myseries) FROM " ++ Bucket,
ClusterConn = {_Cluster, Conn} = ts_util:cluster_and_connect(ClusterType),
{_, Got} = ts_util:ts_query(ClusterConn, TestType, DDL, Data, Qry, Bucket),
?assertEqual(Got, Count),
?assertEqual(Count, Got),
Qry2 = "SELECT COUNT(timestamp) FROM " ++ Bucket,
{_, Got2} = ts_util:single_query(Conn, Qry2),
?assertEqual(Got2, Count),
?assertEqual(Count, Got2),
Qry3 = "SELECT COUNT(pressure), COUNT(temperature), COUNT(precipitation) FROM " ++ Bucket,
{_, Got3} = ts_util:single_query(Conn, Qry3),
?assertEqual(Got3, [Count, Count, Count]),
?assertEqual([Count, Count, Count], Got3),
Qry4 = "SELECT SUM(temperature) FROM " ++ Bucket,
{_, Got4} = ts_util:single_query(Conn, Qry4),
Sum4 = lists:sum(Column4),
?assertEqual(Got4, Sum4),
?assertEqual(Sum4, Got4),
Qry5 = "SELECT SUM(temperature), SUM(pressure), SUM(\precipitation) FROM " ++ Bucket,
{_, Got5} = ts_util:single_query(Conn, Qry5),
Sum5 = lists:sum(Column5),
Sum6 = lists:sum(Column6),
?assertEqual(Got5, [Sum4, Sum5, Sum6]),
?assertEqual([Sum4, Sum5, Sum6], Got5),
Qry6 = "SELECT MIN(temperature), MIN(pressure) FROM " ++ Bucket,
{_, Got6} = ts_util:single_query(Conn, Qry6),
Min4 = lists:min(Column4),
Min5 = lists:min(Column5),
?assertEqual(Got6, [Min4, Min5]),
?assertEqual([Min4, Min5], Got6),
Qry7 = "SELECT MAX(temperature), MAX(pressure) FROM " ++ Bucket,
{_, Got7} = ts_util:single_query(Conn, Qry7),
Max4 = lists:max(Column4),
Max5 = lists:max(Column5),
?assertEqual(Got7, [Max4, Max5]),
?assertEqual([Max4, Max5], Got7),
Avg4 = Sum4 / Count,
Avg5 = Sum5 / Count,
Qry8 = "SELECT AVG(temperature), MEAN(pressure) FROM " ++ Bucket,
{_, Got8} = ts_util:single_query(Conn, Qry8),
?assertEqual(Got8, [Avg4, Avg5]),
?assertEqual([Avg4, Avg5], Got8),
StdDevFun4 = stddev_fun_builder(Avg4),
StdDevFun5 = stddev_fun_builder(Avg5),
@ -96,11 +96,11 @@ verify_aggregation(ClusterType) ->
StdDev5 = math:sqrt(lists:foldl(StdDevFun5, 0, Column5) / (Count-1)),
Qry9 = "SELECT STDDEV(temperature), STDDEV(pressure) FROM " ++ Bucket,
{_, Got9} = ts_util:single_query(Conn, Qry9),
?assertEqual(Got9, [StdDev4, StdDev5]),
?assertEqual([StdDev4, StdDev5], Got9),
Qry10 = "SELECT SUM(temperature), MIN(pressure), AVG(pressure) FROM " ++ Bucket,
{_, Got10} = ts_util:single_query(Conn, Qry10),
?assertEqual(Got10, [Sum4, Min5, Avg5]).
?assertEqual([Sum4, Min5, Avg5], Got10).

View File

@ -0,0 +1,40 @@
%% -------------------------------------------------------------------
%%
%% Copyright (c) 2015 Basho Technologies, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%
%% -------------------------------------------------------------------
-module(ts_describe_table).
-behavior(riak_test).
-export([confirm/0]).
-include_lib("eunit/include/eunit.hrl").
%% Test basic aggregation functions
confirm() ->
TestType = normal,
DDL = ts_util:get_ddl(),
Data = ts_util:get_valid_select_data(),
Qry = "DESCRIBE GeoCheckin",
Got = ts_util:ts_query(
ts_util:cluster_and_connect(single), TestType, DDL, Data, Qry),
Expected = some_table_description,
?assertEqual(Expected, Got),
pass.