anchor.diff:  
   %% Returns a one arity fun which is stateless for example pulling a field from a
   %% row.
  -% -spec compile_select_col_stateless(#ddl_v1{}, selection()) ->
  -%         {ColTypes::[primitive_field_type()], IsValid::true|any(), function()}.
  +-spec compile_select_col_stateless(#ddl_v1{}, selection()) ->
  +       {ColTypes::[primitive_field_type()], IsValid::true|any(), function()}.
   compile_select_col_stateless(DDL, {identifier, [<<"*">>]}) ->
       ColTypes = [X#riak_field_v1.type || X <- DDL#ddl_v1.fields],
       {ColTypes, true, fun(Row) -> Row end};
  
positive.code: }).
  
  %%
  % -spec select_column_clause_folder(#ddl_v1{}, )
  select_column_clause_folder(DDL, ColX, {TypeSet1, SelClause1}) ->
      #riak_sel_clause_v1{
          initial_state = InitX,
  
negative.code: %%
  compile_select_clause(DDL, #riak_sql_v1{'SELECT' = #riak_sel_clause_v1{ clause = Sel } } = Q) ->
      CompileColFn = 
          fun(ColX, AccX) ->
              select_column_clause_folder(DDL, ColX, AccX)
          end,
      % 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
      Acc = {sets:new(), #riak_sel_clause_v1{ }},
      % iterate from the right so we can append to the head of lists
      {ColTypeSet, Q2} = lists:foldr(CompileColFn, Acc, Sel),
      case sets:is_element(aggregate, ColTypeSet) of
          true  -> CalcType = aggregate;
          false -> CalcType = rows
      end,
      {ok, Q2#riak_sel_clause_v1{ calc_type = CalcType,
                                  col_names = get_col_names(DDL, Q) }}.
  
  %%
  -record(single_sel_column, {
      calc_type       :: select_result_type(),
      initial_state   :: any(),
  