anchor.diff:  
   -ifdef(TEST).
   -include_lib("eunit/include/eunit.hrl").
  -
  -describe_table_columns_test() ->
  -    {ddl, DDL, []} =
  -        riak_ql_parser:ql_parse(
  -          riak_ql_lexer:get_tokens(
  -            "CREATE TABLE fafa ("
  -            " f varchar   not null,"
  -            " s varchar   not null,"
  -            " t timestamp not null,"
  -            " w sint64    not null,"
  -            " p double,"
  -            " PRIMARY KEY ((f, s, quantum(t, 15, m)), f, s, t))")),
  -    Res = do_describe(DDL),
  -    ?assertMatch(
  -       {ok, {_, _,
  -             [[<<"f">>, <<"varchar">>,   false, 1,  1, [], [], []],
  -              [<<"s">>, <<"varchar">>,   false, 2,  2, [], [], []],
  -              [<<"t">>, <<"timestamp">>, false, 3,  3, 15, <<"m">>, []],
  -              [<<"w">>, <<"sint64">>, false, [], [], [], [], []],
  -              [<<"p">>, <<"double">>, true,  [], [], [], [], []]]}},
  -       Res).
  -
  -describe_table_columns_no_quantum_test() ->
  -    {ddl, DDL, []} =
  -        riak_ql_parser:ql_parse(
  -            riak_ql_lexer:get_tokens(
  -                "CREATE TABLE fafa ("
  -                " f varchar   not null,"
  -                " s varchar   not null,"
  -                " t timestamp not null,"
  -                " w sint64    not null,"
  -                " p double,"
  -                " PRIMARY KEY ((f, s, t), f, s, t))")),
  -    Res = do_describe(DDL),
  -    ?assertMatch(
  -        {ok, {_, _,
  -            [[<<"f">>, <<"varchar">>,   false, 1,  1, [],  [], []],
  -             [<<"s">>, <<"varchar">>,   false, 2,  2, [],  [], []],
  -             [<<"t">>, <<"timestamp">>, false, 3,  3, [],  [], []],
  -             [<<"w">>, <<"sint64">>,    false, [], [], [], [], []],
  -             [<<"p">>, <<"double">>,    true,  [], [], [], [], []]]}},
  -        Res).
   
   show_tables_test() ->
       Res = build_show_tables_result([<<"fafa">>,<<"lala">>]),
  
positive.code:     Val.
  
  
  %% DESCRIBE
  
  -spec do_describe(?DDL{}) ->
                           {ok, query_tabular_result()} | {error, term()}.
  do_describe(?DDL{fields = FieldSpecs,
                   partition_key = #key_v1{ast = PKSpec},
                   local_key     = #key_v1{ast = LKSpec}}) ->
      ColumnNames = [<<"Column">>, <<"Type">>, <<"Is Null">>, <<"Partition Key">>, <<"Local Key">>, <<"Interval">>, <<"Unit">>, <<"Sort Order">>],
      ColumnTypes = [   varchar,      varchar,    boolean,       sint64,            sint64,         sint64,         varchar,      varchar],
      Quantum = find_quantum_field(PKSpec),
      Rows =
          [[Name, list_to_binary(atom_to_list(Type)), Nullable,
            column_pk_position_or_blank(Name, PKSpec),
            column_lk_position_or_blank(Name, LKSpec)] ++
            columns_quantum_or_blank(Name, Quantum) ++
            column_lk_order(Name, LKSpec)
           || #riak_field_v1{name = Name,
                             type = Type,
                             optional = Nullable} <- FieldSpecs],
      {ok, {ColumnNames, ColumnTypes, Rows}}.
  
  %% Return the sort order of the local key for this column, or null if it is not
  %% a local key or has an undefined sort order.
  column_lk_order(Name, LK) when is_binary(Name) ->
      case lists:keyfind([Name], #riak_field_v1.name, LK) of
          ?SQL_PARAM{ordering = descending} ->
              [<<"DESC">>];
          ?SQL_PARAM{ordering = ascending} ->
              [<<"ASC">>];
          _ ->
              [[]]
      end.
  
  %% the following two functions are identical, for the way fields and
  %% keys are represented as of 2015-12-18; duplication here is a hint
  %% of things to come.
  -spec column_pk_position_or_blank(binary(), [?SQL_PARAM{}]) -> integer() | [].
  column_pk_position_or_blank(Col, KSpec) ->
      count_to_position(Col, KSpec, 1).
  
  -spec column_lk_position_or_blank(binary(), [?SQL_PARAM{}]) -> integer() | [].
  column_lk_position_or_blank(Col, KSpec) ->
      count_to_position(Col, KSpec, 1).
  
  %% Extract the quantum column information, if it exists in the table definition
  %% and put in two additional columns
  -spec columns_quantum_or_blank(Col :: binary(), PKSpec :: [?SQL_PARAM{}|#hash_fn_v1{}]) ->
        [binary() | []].
  columns_quantum_or_blank(Col, #hash_fn_v1{args = [?SQL_PARAM{name = [Col]}, Interval, Unit]}) ->
      [Interval, list_to_binary(io_lib:format("~p", [Unit]))];
  columns_quantum_or_blank(_Col, _PKSpec) ->
      [[], []].
  
  %% Find the field associated with the quantum, if there is one
  -spec find_quantum_field([?SQL_PARAM{}|#hash_fn_v1{}]) -> [] | #hash_fn_v1{}.
  find_quantum_field([]) ->
      [];
  find_quantum_field([Q = #hash_fn_v1{}|_]) ->
      Q;
  find_quantum_field([_|T]) ->
      find_quantum_field(T).
  
  count_to_position(_, [], _) ->
      [];
  count_to_position(Col, [?SQL_PARAM{name = [Col]} | _], Pos) ->
      Pos;
  count_to_position(Col, [#hash_fn_v1{args = [?SQL_PARAM{name = [Col]} | _]} | _], Pos) ->
      Pos;
  count_to_position(Col, [_ | Rest], Pos) ->
      count_to_position(Col, Rest, Pos + 1).
  
  
  %% SELECT
  
negative.code:     end;
  
  submit(#riak_sql_describe_v1{}, DDL) ->
      riak_ql_describe:describe(DDL);
  submit(SQL = #riak_sql_insert_v1{}, _DDL) ->
      do_insert(SQL);
  submit(SQL = ?SQL_SELECT{}, DDL) ->
  