anchor.diff:              '/' -> riak_ql_window_agg_fns:divide(A,B)
           end,
       {calculated, Value};
  -resolve_expressions_folder(Mod, {ExpOp,FieldName,{calculated,V1}}) when is_binary(FieldName) ->
  +resolve_expressions_folder(_, Options, {{sql_select_fn,'NOW'}, Args}) ->
  +    ok = validate_where_fn_arity('NOW', Args),
  +    {_, Now} = lists:keyfind(now_milliseconds, 1, Options),
  +    {timestamp, Now};
  +resolve_expressions_folder(Mod, _, {ExpOp,FieldName,{calculated,V1}}) when is_binary(FieldName) ->
       V2 = cast_value_to_ast(Mod:get_field_type([FieldName]),V1),
       {ExpOp,FieldName,V2};
  -resolve_expressions_folder(_, AST) ->
  +resolve_expressions_folder(_, _, AST) ->
       AST.
  +
  +validate_where_fn_arity(FnName, Args) ->
  +    ExpectedArity = riak_ql_ddl:sql_function_arity(FnName),
  +    ActualArity = length(Args),
  +    case ExpectedArity == length(Args) of
  +        true ->
  +            ok;
  +        false ->
  +            Msg = format_binary(
  +                "Function ~p has arity of ~p but was called with ~p arguments.",
  +                [FnName, ExpectedArity, ActualArity]),
  +            throw({error,{invalid_query,  Msg}})
  +    end.
  +
  +format_binary(Fmt, Args) ->
  +    iolist_to_binary(io_lib:format(Fmt, Args)).
   
   cast_value_to_ast(T, V) when (T == integer orelse T == timestamp), is_integer(V) -> {T, V};
   cast_value_to_ast(T, V) when (T == integer orelse T == timestamp), is_float(V)   -> {T, erlang:round(V)};
  
positive.code: 
  boolean_true_literal_test() ->
      {ok, Rec} = get_query("SELECT true from mytab"),
      {ok, Sel} = compile_select_clause(get_sel_ddl(), Rec),
      ?assertMatch(
         #riak_sel_clause_v1{
            calc_type        = rows,
  
negative.code: count_plus_seven_sum__test() ->
      {ok, Rec} = get_query(
          "SELECT COUNT(mydouble) + 7, SUM(mydouble) FROM mytab"),
      {ok, Select} = compile_select_clause(get_sel_ddl(), options(), Rec),
      ?assertMatch(
          #riak_sel_clause_v1{
              initial_state = [0,[]],
  