anchor.diff:          compile(DDL, Q, 100)
       ).
   
  +quantum_field_name_test() ->
  +    DDL = get_ddl(
  +        "CREATE TABLE tab1("
  +        "a SINT64 NOT NULL, "
  +        "b TIMESTAMP NOT NULL, "
  +        "PRIMARY KEY  ((a,quantum(b, 15, 's')), a,b))"),
  +    ?assertEqual(
  +        <<"b">>,
  +        quantum_field_name(DDL)
  +    ).
  +
  +quantum_field_name_no_quanta_test() ->
  +    DDL = get_ddl(
  +        "CREATE TABLE tab1("
  +        "a SINT64 NOT NULL, "
  +        "b TIMESTAMP NOT NULL, "
  +        "PRIMARY KEY  ((a,b), a,b))"),
  +    ?assertEqual(
  +        no_quanta,
  +        quantum_field_name(DDL)
  +    ).
  +
  +% short key, partition and local keys are the same
  +no_quantum_in_query_1_test() ->
  +    DDL = get_ddl(
  +        "CREATE TABLE tabab("
  +        "a TIMESTAMP NOT NULL, "
  +        "b VARCHAR NOT NULL, "
  +        "PRIMARY KEY  ((a,b), a,b))"),
  +    {ok, Q} = get_query(
  +          "SELECT * FROM tab1 WHERE a = 1 AND b = 1"),
  +    ?assertMatch(
  +        {ok, [#riak_select_v1{ 
  +            'WHERE' = 
  +                [{startkey,[{<<"a">>,timestamp,1},{<<"b">>,varchar,1}]},
  +                 {endkey,  [{<<"a">>,timestamp,1},{<<"b">>,varchar,1}]},
  +                 {filter,[]},
  +                 {end_inclusive,true}] }]},
  +        compile(DDL, Q, 100)
  +    ).
  +
  +no_quantum_in_query_2_test() ->
  +    DDL = get_ddl(
  +        "CREATE TABLE tabab("
  +        "a SINT64 NOT NULL, "
  +        "b VARCHAR NOT NULL, "
  +        "c DOUBLE NOT NULL, "
  +        "d BOOLEAN NOT NULL, "
  +        "PRIMARY KEY  ((c,a,b), c,a,b,d))"),
  +    {ok, Q} = get_query(
  +          "SELECT * FROM tab1 WHERE a = 1000 AND b = 'bval' AND c = 3.5"),
  +    {ok, [Select]} = compile(DDL, Q, 100),
  +    Key = 
  +        [{<<"c">>,double,3.5}, {<<"a">>,sint64,1000},{<<"b">>,varchar,<<"bval">>}],
  +    ?assertEqual(
  +        [{startkey, Key},
  +         {endkey, Key},
  +         {filter,[]},
  +         {end_inclusive,true}],
  +        Select#riak_select_v1.'WHERE'
  +    ).
  +
   -endif.
  
positive.code:           "SELECT SUM(location) FROM GeoCheckin "
            "WHERE time > 5000 AND time < 10000"
            "AND user = 'user_1' AND location = 'derby'"),
      io:format(user, "~p", [compile(get_standard_ddl(), Q, 100)]),
      ?assertEqual(
          {error,{invalid_query,<<"\nFunction 'SUM' called with arguments of the wrong type [varchar].">>}},
          compile(get_standard_ddl(), Q, 100)
  
negative.code:     end.
  
  %% find the upper and lower bound for the time
  find_timestamp_bounds(QuantumField, LocalFields) ->
      find_timestamp_bounds2(QuantumField, LocalFields, [], {undefined, undefined}).
  
  %%
  