From: Nikita Pettik <korablev@tarantool.org> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH 6/6] sql: extend result set with alias Date: Thu, 5 Dec 2019 14:51:21 +0300 [thread overview] Message-ID: <20191205115121.GA4490@tarantool.org> (raw) In-Reply-To: <8652d840-2b81-9e49-eb5a-1133673b11bf@tarantool.org> On 28 Nov 23:41, Vladislav Shpilevoy wrote: > 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. (ANSI parts which concern Java and CLI are quite complicated to read and understand, so I refer to Oracle docs). https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSetMetaData.html#getColumnLabel-int- 'The suggested title is usually specified by the SQL AS clause.' https://stackoverflow.com/questions/4271152/getcolumnlabel-vs-getcolumnname I assume that :getColumnLabel() returns name of label, not real name (at least it seems to be rational). > 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'. Sorry, now it is fixed: - metadata: - type: integer name: '1' alias: KEK rows: - [1] ... I've extended commit message with doc bot request: sql: extend result set with alias 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. Closes #4407 @TarantoolBot document Title: extended SQL metadata Before this patch metadata for SQL DQL contained only two fields: name and type of each column of result set. Now it may contain following properties: - collation (in case type of resulting set column is string and collation is different from default "none"); is encoded with IPROTO_FIELD_COLL key in IPROTO_METADATA map; - is_nullable (in case column of result set corresponds to space's field; for expressions like x+1 for the sake of simplicity nullability is omitted); is encoded with IPROTO_FIELD_IS_NULLABLE key in IPROTO_METADATA; - is_autoincrement (is set only for autoincrement column in result set); is encoded with IPROTO_FIELD_IS_AUNTOINCREMENT key in IPROTO_METADATA; - alias (if column of result set is specified with AS label); is encoded with IPROTO_FIELD_ALIAS key in IPROTO_METADATA map.
next prev parent reply other threads:[~2019-12-05 11:51 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 2019-12-05 11:51 ` Nikita Pettik [this message] 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=20191205115121.GA4490@tarantool.org \ --to=korablev@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@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