anchor.diff:                                                         ]
                                               },
                                               {filter, []},
  -                        {start_inclusive,   false}
  +                                            {start_inclusive,   false}
                                              ],
                              helper_mod    = riak_ql_ddl:make_module_name(<<"GeoCheckin">>),
                              partition_key = get_standard_pk(),
  
positive.code: -module(sql_compilation_end_to_end).
  
  -include_lib("eunit/include/eunit.hrl").
  -include_lib("riak_ql/include/riak_ql_ddl.hrl").
  
  %% this is a basic test of timeseries that writes a single element to the back end
  %% and checks it is correct
  
  -define(VALID,   true).
  -define(INVALID, false).
  
negative.code:              ]).
  
  ?assert_test(badarith_regression_test,
               "CREATE TABLE GeoCheckin ("
               " geohash varchar not null,"
               " user varchar not null,"
               " time timestamp not null,"
               " weather varchar not null,"
               " temperature varchar,"
               " PRIMARY KEY ((user, geohash, quantum(time, 15, s)), user, geohash, time))",
               "select weather from GeoCheckin where time > 3000 and time < 5000",
               {error, {missing_param, <<"Missing parameter user in where clause.">>}}).
  
  ?assert_test(spanning_qry_test,
               "CREATE TABLE GeoCheckin ("
               " geohash varchar not null, "
               " location varchar not null, "
               " user varchar not null, "
               " time timestamp not null, "
               " weather varchar not null, "
               " temperature varchar, "
               "PRIMARY KEY ((location, user, quantum(time, 15, 's')),"
               " location, user, time))",
               "select weather from GeoCheckin where time > 3000 and "
               " time < 18000 and user = 'gordon' and location = 'Lithgae'",
  
            [
             #riak_sql_v1{'SELECT'      = [[<<"weather">>]],
                          'FROM'        = <<"GeoCheckin">>,
                          'WHERE'       = [
                                           {startkey, [
                                                       {<<"location">>, varchar, <<"Lithgae">>},
                                                       {<<"user">>, varchar, <<"gordon">>},
                                                       {<<"time">>, timestamp, 3000}
                                                      ]
                                           },
                                           {endkey,   [
                                                       {<<"location">>, varchar, <<"Lithgae">>},
                                                       {<<"user">>, varchar, <<"gordon">>},
                                                       {<<"time">>, timestamp, 15000}
                                                      ]
                                           },
                                           {filter, []},
                                           {start_inclusive,   false}
                                          ],
                          helper_mod    = riak_ql_ddl:make_module_name(<<"GeoCheckin">>),
                          partition_key = get_standard_pk(),
                          is_executable = true,
                          type          = timeseries,
                          local_key     = get_standard_lk()},
  
             #riak_sql_v1{'SELECT'      = [[<<"weather">>]],
                          'FROM'        = <<"GeoCheckin">>,
                          'WHERE'       = [
                                           {startkey, [
                                                       {<<"location">>, varchar, <<"Lithgae">>},
                                                       {<<"user">>, varchar, <<"gordon">>},
                                                       {<<"time">>, timestamp, 15000}
                                                      ]
                                           },
                                           {endkey,   [
                                                       {<<"location">>, varchar, <<"Lithgae">>},
                                                       {<<"user">>, varchar, <<"gordon">>},
                                                       {<<"time">>, timestamp, 18000}
                                                      ]
                                           },
                                           {filter, []}
                                          ],
                          helper_mod    = riak_ql_ddl:make_module_name(<<"GeoCheckin">>),
                          partition_key = get_standard_pk(),
                          is_executable = true,
                          type          = timeseries,
                          local_key     = get_standard_lk()}
            ]).
  