Merge pull request #1266 from basho/at-group-by-time

Group by time in the GROUP BY clause RTS-1689
This commit is contained in:
Brett Hazen 2017-02-22 20:46:20 -07:00 committed by GitHub
commit d80cc7c5e6

View File

@ -116,8 +116,25 @@ group_by_2_test(Ctx) ->
{ok,{Cols, lists:sort(Rows)}}
).
group_by_time_test(Ctx) ->
?assertMatch(
{ok, _},
riakc_ts:query(client_pid(Ctx),
"CREATE TABLE grouptab3 ("
"a TIMESTAMP NOT NULL, "
"PRIMARY KEY ((quantum(a,1,s)), a))"
)),
ok = riakc_ts:put(client_pid(Ctx), <<"grouptab3">>,
[{A} || A <- lists:seq(1,10000,2)]),
Query =
"SELECT time(a,1s), COUNT(*) FROM grouptab3 "
"WHERE a >= 1 AND a <= 10000"
"GROUP BY time(a,1s)",
{ok, {Cols, Rows}} = run_query(Ctx, Query),
ts_data:assert_row_sets(
{rt_ignore_columns, [{N*1000,500} || N <- lists:seq(0,9)]},
{ok,{Cols, lists:sort(Rows)}}
).