Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Nikita Pettik <korablev@tarantool.org>,
	tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 6/6] sql: extend result set with alias
Date: Thu, 28 Nov 2019 23:41:51 +0100	[thread overview]
Message-ID: <8652d840-2b81-9e49-eb5a-1133673b11bf@tarantool.org> (raw)
In-Reply-To: <b396f9a6750eec5daa1b1e23f0cce00359c7a82c.1574846892.git.korablev@tarantool.org>

Thanks for the patch!

On 27/11/2019 13:15, Nikita Pettik wrote:
> Each column of result set can feature its name alias. For instance:
> 
> SELECT x + 1 AS add FROM ...;
> 
> In this case real name of resulting set column is "x + 1" meanwhile
> "add" is its alias. This patch extends metadata with optional metadata
> member which corresponds to column's alias.

I was always thinking that the alias should be returned as a
name. And the real name should be returned as meta. And looks
like it is so:

    tarantool> box.execute('SELECT 1 AS kek')
    ---
    - metadata:
      - name: KEK
        type: integer
      rows:
      - [1]
    ...

That makes me think we should not break it. And
meta should return the real name in case there is
an alias. Because otherwise the aliases are useless
in meta.

Btw the example above is executed on this commit. So
now the results are inconsistent. Some queries return
alias in 'name'. Some return a real name in 'name'. I
think we should keep it as was, and return alias in
'name'.

> 
> Closes #4407
> ---
>  src/box/execute.c              | 18 +++++++++++++----
>  src/box/iproto_constants.h     |  1 +
>  src/box/lua/execute.c          |  5 +++++
>  src/box/lua/net_box.c          |  6 +++++-
>  src/box/sql/select.c           |  9 +++++++--
>  src/box/sql/sqlInt.h           |  3 +++
>  src/box/sql/vdbe.h             |  3 +++
>  src/box/sql/vdbeInt.h          |  1 +
>  src/box/sql/vdbeapi.c          |  8 ++++++++
>  src/box/sql/vdbeaux.c          | 15 ++++++++++++++
>  test/sql-tap/badutf1.test.lua  | 46 +++++++++++++++++++++---------------------
>  test/sql-tap/colname.test.lua  | 16 +++++++--------
>  test/sql-tap/lua/sqltester.lua | 29 ++++++++++++++++++++++++++
>  test/sql-tap/select1.test.lua  | 18 ++++++++---------
>  test/sql-tap/select4.test.lua  |  4 ++--
>  test/sql-tap/view.test.lua     |  2 +-
>  test/sql/bind.result           | 15 ++++++++------
>  test/sql/boolean.result        |  6 ++++--
>  test/sql/collation.result      | 16 +++++++++------
>  test/sql/iproto.result         |  5 +++--
>  20 files changed, 160 insertions(+), 66 deletions(-)
> 
> diff --git a/test/sql-tap/badutf1.test.lua b/test/sql-tap/badutf1.test.lua
> index 9079dfe25..6623999d0 100755
> --- a/test/sql-tap/badutf1.test.lua
> +++ b/test/sql-tap/badutf1.test.lua
> @@ -248,6 +269,14 @@ local function execsql2(self, sql)
>  end
>  test.execsql2 = execsql2
>  
> +local function execsql_aliases(self, sql)
> +    local result, metadata = execsql_one_by_one(sql)
> +    if type(result) ~= 'table' then return end
> +    result = flattern_with_column_aliases(result, metadata)
> +    return result
> +end
> +test.execsql_aliases = execsql_aliases

Well, these dancing with aliases is really weird. Seems like
your patch broke the names. AFAIU, as a name you should return
the alias, when it is specified. And the real name is returned
optionally, in meta.

> +
>  local function sortsql(self, sql)
>      local result = execsql(self, sql)
>      table.sort(result, function(a,b) return a[2] < b[2] end)

  reply	other threads:[~2019-11-28 22:41 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-27 12:15 [Tarantool-patches] [PATCH 0/6] sql: extend response metadata Nikita Pettik
2019-11-27 12:15 ` [Tarantool-patches] [PATCH 1/6] sql: refactor resulting set metadata Nikita Pettik
2019-11-28 22:41   ` Vladislav Shpilevoy
2019-12-05 11:39     ` Nikita Pettik
2019-12-05 23:58       ` Vladislav Shpilevoy
2019-12-06 12:48         ` Nikita Pettik
2019-12-17 13:23   ` Sergey Ostanevich
2019-11-27 12:15 ` [Tarantool-patches] [PATCH 2/6] sql: fix possible null dereference in sql_expr_coll() Nikita Pettik
2019-11-28 22:42   ` Vladislav Shpilevoy
2019-12-05 11:40     ` Nikita Pettik
2019-12-05 23:59       ` Vladislav Shpilevoy
2019-12-06 12:48         ` Nikita Pettik
2019-12-17 13:30           ` Sergey Ostanevich
2019-12-17 14:44             ` Nikita Pettik
2019-12-17 19:53               ` Nikita Pettik
2019-11-27 12:15 ` [Tarantool-patches] [PATCH 3/6] sql: extend result set with collation Nikita Pettik
2019-11-28 22:41   ` Vladislav Shpilevoy
2019-12-05 11:50     ` Nikita Pettik
2019-12-18 11:08   ` Sergey Ostanevich
2019-12-24  0:44     ` Nikita Pettik
2019-11-27 12:15 ` [Tarantool-patches] [PATCH 4/6] sql: extend result set with nullability Nikita Pettik
2019-11-28 22:41   ` Vladislav Shpilevoy
2019-12-05 11:50     ` Nikita Pettik
2019-12-06  0:00       ` Vladislav Shpilevoy
2019-12-06 12:49         ` Nikita Pettik
2019-12-18 13:31   ` Sergey Ostanevich
2019-11-27 12:15 ` [Tarantool-patches] [PATCH 5/6] sql: extend result set with autoincrement Nikita Pettik
2019-11-28 22:41   ` Vladislav Shpilevoy
2019-12-05 11:51     ` Nikita Pettik
2019-12-18 15:17   ` Sergey Ostanevich
2019-12-24  0:47     ` Nikita Pettik
2019-11-27 12:15 ` [Tarantool-patches] [PATCH 6/6] sql: extend result set with alias Nikita Pettik
2019-11-28 22:41   ` Vladislav Shpilevoy [this message]
2019-12-05 11:51     ` Nikita Pettik
2019-12-06  0:02       ` Vladislav Shpilevoy
2019-12-06 12:50         ` Nikita Pettik
2019-12-06 21:52           ` Vladislav Shpilevoy
2019-12-19 15:17   ` Sergey Ostanevich
2019-12-24  0:27     ` Nikita Pettik
2019-11-28 22:55 ` [Tarantool-patches] [PATCH 0/6] sql: extend response metadata Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8652d840-2b81-9e49-eb5a-1133673b11bf@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 6/6] sql: extend result set with alias' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox