mirror of
https://github.com/valitydev/riak_test.git
synced 2024-11-06 16:45:29 +00:00
74 lines
2.8 KiB
Erlang
74 lines
2.8 KiB
Erlang
%% -------------------------------------------------------------------
|
|
%%
|
|
%% Copyright (c) 2016 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_simple_explain_query).
|
|
|
|
-behavior(riak_test).
|
|
|
|
-export([confirm/0]).
|
|
|
|
-include_lib("eunit/include/eunit.hrl").
|
|
|
|
%% Test basic table description
|
|
|
|
confirm() ->
|
|
DDL = ts_util:get_ddl(big, "MyTable"),
|
|
ClusterConn = {_Cluster, Conn} = ts_util:cluster_and_connect(single),
|
|
ts_util:create_and_activate_bucket_type(ClusterConn, DDL, "MyTable"),
|
|
Qry = "EXPLAIN SELECT myint, myfloat, myoptional FROM MyTable WHERE "
|
|
"myfamily='wingo' AND myseries='dingo' AND time > 0 AND time < 2000000 "
|
|
"AND ((mybool=true AND myvarchar='banana') OR (myoptional=7))",
|
|
|
|
Got = ts_util:single_query(Conn, Qry),
|
|
Expected =
|
|
{ok,{[<<"Subquery">>,
|
|
<<"Coverage Plan">>,
|
|
<<"Range Scan Start Key">>,
|
|
<<"Is Start Inclusive?">>,
|
|
<<"Range Scan End Key">>,
|
|
<<"Is End Inclusive?">>,<<"Filter">>],
|
|
[{1,
|
|
<<"dev1@127.0.0.1/49">>,
|
|
<<"myfamily = 'wingo', myseries = 'dingo', time = 1">>,
|
|
false,
|
|
<<"myfamily = 'wingo', myseries = 'dingo', time = 900000">>,
|
|
false,
|
|
<<"((myoptional = 7) OR ((mybool = true) AND (myvarchar = 'banana')))">>},
|
|
{2,
|
|
<<"dev1@127.0.0.1/11">>,
|
|
<<"myfamily = 'wingo', myseries = 'dingo', time = 900000">>,
|
|
false,
|
|
<<"myfamily = 'wingo', myseries = 'dingo', time = 1800000">>,
|
|
false,
|
|
<<"((myoptional = 7) OR ((mybool = true) AND (myvarchar = 'banana')))">>},
|
|
{3,
|
|
<<"dev1@127.0.0.1/59">>,
|
|
<<"myfamily = 'wingo', myseries = 'dingo', time = 1800000">>,
|
|
false,
|
|
<<"myfamily = 'wingo', myseries = 'dingo', time = 2000000">>,
|
|
false,
|
|
<<"((myoptional = 7) OR ((mybool = true) AND (myvarchar = 'banana')))">>}]}},
|
|
?assertEqual(Expected, Got),
|
|
|
|
%% Now try NOT using TTB
|
|
Got2 = riakc_ts:query(Conn, Qry, [], undefined, [{use_ttb, false}]),
|
|
?assertEqual(Expected, Got2),
|
|
pass.
|