anchor.diff:  count_multiplied_by_count_finalise_test() ->
       {ok, Rec} = get_query(
           "SELECT COUNT(mydouble) * COUNT(mydouble) FROM mytab"),
  -    {ok, Select} = compile_select_clause(get_sel_ddl(), Rec),
  +    {ok, Select} = compile_select_clause(get_sel_ddl(), options(), Rec),
       ?assertMatch(
           [9],
           finalise_aggregate(Select, [3,3])
  
positive.code: my_mapfoldl(F, Accu, []) when is_function(F, 2) -> {[],Accu}.
  
  %%
  compile_select_clause(DDL, ?SQL_SELECT{'SELECT' = #riak_sel_clause_v1{clause = Sel}} = Q) ->
      %% compile each select column and put all the calc types into a set, if
      %% any of the results are aggregate then aggregate is the calc type for the
      %% whole query
      CompileColFn =
          fun(ColX, AccX) ->
              select_column_clause_folder(DDL, ColX, AccX)
          end,
      Acc = {sets:new(), #riak_sel_clause_v1{ }},
      %% iterate from the right so we can append to the head of lists
  
negative.code: 
  %% Compile a single selection column into a fun that can extract the cell
  %% from the row.
  -spec compile_select_col(DDL::?DDL{}, options(), ColumnSpec::any()) ->
                                  #single_sel_column{}.
  compile_select_col(DDL, Options, {{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, Options, FnArg1),
              #single_sel_column{ calc_type        = rows,
                                  initial_state    = undefined,
                                  clause           = Fn };
          Initial_state ->
              Compiled_arg1 = compile_select_col_stateless(DDL, Options, FnArg1),
              % all the windows agg fns so far are arity of 1
              % which we have forced in this clause by matching on a single argument in the
              % function head
  