anchor.diff:                                                            ]},
                                                  {filter,   []}
                                                 ],
  -                              partition_key = #key_v1{ast = [
  -                                                             #hash_fn_v1{mod = riak_ql_quanta,
  -                                                                         fn = quantum,
  -                                                                         args = [
  -                                                                                 #param_v1{name = [<<"time">>]},
  -                                                                                 15,
  -                                                                                 m
  -                                                                                ],
  -                                                                         type = timestamp}
  -                                                            ]
  -                                                     },
  -                              local_key = #key_v1{ast = [
  -                                                         #param_v1{name = [<<"time">>]},
  -                                                         #param_v1{name = [<<"user">>]}
  -                                                        ]}
  +                              partition_key = get_standard_pk(),
  +                              local_key     = get_standard_lk()
                        }],
  -    gg:format("in simplest~nExpected:~n- ~p~nGot:~n- ~p~n", [Expected, Got]),
  +    %% simplify the test we overwrite a couple of fields
       ?assertEqual(Expected, Got).
   
  +%% got for 3 queries to get partition ordering problems flushed out
   simple_spanning_boundary_test() ->
       DDL = get_standard_ddl(),
  -    Query = "select weather from GeoCheckin where time > 3000 and time < 16000 and user = \"user_1\"",
  +    Query = "select weather from GeoCheckin where time > 3000 and time < 31000 and user = \"user_1\"",
       {ok, Q} = get_query(Query),
       true = is_query_valid(DDL, Q),
       %% get basic query
  -    %% make new Where clause
  -    NewW = [
  -	    {and_, 
  -	     {and_,
  -	      {'>', ?NAME, {int,  1 * ?MIN}},
  -	      {'<', ?NAME, {int, 16 * ?MIN}}
  -	     },
  -	     {'=', "user", {word, "user_1"}}
  -	    }
  -	   ],
  -    Q2 = Q#riak_sql_v1{'WHERE' = NewW},
  -    Got = compile(DDL, Q2),
  -    %% now make the result - expecting 2 queries
  +    Got = compile(DDL, Q),
  +    %% now make the result - expecting 3 queries
       W1 = [
  -	  {startkey, "user_112323213"},
  -	  {endkey,   "user_14345345"}
  +	  {startkey, [{<<"time">>, 3000},  {<<"user">>, <<"user_1">>}]},
  +	  {endkey,   [{<<"time">>, 15000}, {<<"user">>, <<"user_1">>}]},
  +	  {filter, []}
   	 ],
       W2 = [
  -	  {startkey, "user_1dlfkljfkldsjdsa"},
  -	  {endkey,   "user_1wjweqoewoiei"}
  +	  {startkey, [{<<"time">>, 15000}, {<<"user">>, <<"user_1">>}]},
  +	  {endkey,   [{<<"time">>, 30000}, {<<"user">>, <<"user_1">>}]},
  +	  {filter, []}
  +	 ],
  +    W3 = [
  +	  {startkey, [{<<"time">>, 30000}, {<<"user">>, <<"user_1">>}]},
  +	  {endkey,   [{<<"time">>, 31000}, {<<"user">>, <<"user_1">>}]},
  +	  {filter, []}
   	 ],
       Expected = [
   		Q#riak_sql_v1{is_executable = true,
   			      type          = timeseries,
  -			      'WHERE'       = W1},
  +			      'WHERE'       = W1,
  +                              partition_key = get_standard_pk(),
  +                              local_key     = get_standard_lk()},
   		Q#riak_sql_v1{is_executable = true,
   			      type          = timeseries,
  -			      'WHERE'       = W2}
  +			      'WHERE'       = W2,
  +                              partition_key = get_standard_pk(),
  +                              local_key     = get_standard_lk()},
  +		Q#riak_sql_v1{is_executable = true,
  +			      type          = timeseries,
  +			      'WHERE'       = W3,
  +                              partition_key = get_standard_pk(),
  +                              local_key     = get_standard_lk()}
   	       ],
  -    gg:format("in simple spanning~nExpected:~n- ~p~nGot:~n- ~p~n", [Expected, Got]),
       ?assertEqual(Expected, Got).
   
   %%
  
positive.code: -include_lib("eunit/include/eunit.hrl").
  
  %%
  %% Helper Fn for unit tests
  %%
  
  make_ddl(Bucket, Fields) when is_binary(Bucket) ->
  
negative.code:         "time timestamp not null, " ++
          "weather varchar not null, " ++
          "temperature varchar, " ++
          "PRIMARY KEY((quantum(time, 15, s)), time, user))",
      Lexed = riak_ql_lexer:get_tokens(SQL),
      {ok, DDL} = riak_ql_parser:parse(Lexed),
      {module, _Module} = riak_ql_ddl_compiler:make_helper_mod(DDL),
      DDL.
  
  get_standard_pk() ->
      #key_v1{ast = [
  		   #hash_fn_v1{mod = riak_ql_quanta,
  			       fn = quantum,
  			       args = [
  				       #param_v1{name = [<<"time">>]},
  				       15,
  				       s
  				      ],
  			       type = timestamp}
  		  ]
  	   }.
  
  get_standard_lk() ->
      #key_v1{ast = [
  		   #param_v1{name = [<<"time">>]},
  		   #param_v1{name = [<<"user">>]}
  		  ]}.
  
  %%
  %% Unit tests
  