anchor.diff:          infer_col_type(get_sel_ddl(), {{window_agg_fn, 'SUM'}, [{integer, 4}]}, [])
       ).
   
  +compile_query_with_function_type_error_1_test() ->
  +    {ok, Q} = get_query(
  +          "SELECT SUM(location) FROM GeoCheckin "
  +          "WHERE time > 5000 AND time < 10000"
  +          "AND user = 'user_1' AND location = 'derby'"),
  +    ?assertEqual(
  +        {error, [{invalid_function_call,'SUM',[varchar]}]},
  +        compile(get_standard_ddl(), Q, 100)
  +    ).
  +
  +compile_query_with_function_type_error_2_test() ->
  +    {ok, Q} = get_query(
  +          "SELECT SUM(location), AVG(location) FROM GeoCheckin "
  +          "WHERE time > 5000 AND time < 10000"
  +          "AND user = 'user_1' AND location = 'derby'"),
  +    ?assertEqual(
  +        {error, [
  +            {invalid_function_call,'SUM',[varchar]},
  +            {invalid_function_call,'AVG',[varchar]}]},
  +        compile(get_standard_ddl(), Q, 100)
  +    ).
  +
  +compile_query_with_function_type_error_3_test() ->
  +    {ok, Q} = get_query(
  +          "SELECT AVG(location + 1) FROM GeoCheckin "
  +          "WHERE time > 5000 AND time < 10000"
  +          "AND user = 'user_1' AND location = 'derby'"),
  +    ?assertEqual(
  +        {error, [{invalid_type,'+',varchar,sint64}]},
  +        compile(get_standard_ddl(), Q, 100)
  +    ).
  +
  +compile_query_with_arithmetic_type_error_1_test() ->
  +    {ok, Q} = get_query(
  +          "SELECT location + 1 FROM GeoCheckin "
  +          "WHERE time > 5000 AND time < 10000"
  +          "AND user = 'user_1' AND location = 'derby'"),
  +    ?assertEqual(
  +        {error, [{invalid_type,'+',varchar,sint64}]},
  +        compile(get_standard_ddl(), Q, 100)
  +    ).
  +
  +compile_query_with_arithmetic_type_error_2_test() ->
  +    {ok, Q} = get_query(
  +          "SELECT 2*(location + 1) FROM GeoCheckin "
  +          "WHERE time > 5000 AND time < 10000"
  +          "AND user = 'user_1' AND location = 'derby'"),
  +    ?assertEqual(
  +        {error, [{invalid_type,'+',varchar,sint64}]},
  +        compile(get_standard_ddl(), Q, 100)
  +    ).
  +
   -endif.
  
positive.code:         finalise_aggregate(Select, [3, 11.0])
        ).
  
  count_plus_seven_sum_fsinalise_test() ->
      {ok, Rec} = get_query(
          "SELECT COUNT(user+1) + 1 FROM mytab"),
      {ok, Select} = compile_select_clause(get_sel_ddl(), Rec),
      ?assertEqual(
          [2],
  
negative.code: compile_select_col(DDL, {{window_agg_fn, FnName}, [FnArg1]}) when is_atom(FnName) ->
      case riak_ql_window_agg_fns:start_state(FnName) of
          stateless ->
              %% TODO this does not run the function! nothing is stateless so far though
              Fn = compile_select_col_stateless(DDL, FnArg1),
              #single_sel_column{ calc_type        = rows,
                                  initial_state    = undefined,
  