From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 156832A5CC for ; Wed, 17 Apr 2019 08:50:07 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5A3NM-UtaSzh for ; Wed, 17 Apr 2019 08:50:06 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 6AAF92A5C7 for ; Wed, 17 Apr 2019 08:50:06 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.0 \(3445.100.39\)) Subject: [tarantool-patches] Re: [PATCH 2/2] sql: make aggregate functions types more strict From: "i.koptelov" In-Reply-To: <20190405194815.GH3789@chai> Date: Wed, 17 Apr 2019 15:50:02 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <49e4ae0bc187dc02f908427692c0ddb2cc2d36a8.1554475881.git.ivan.koptelov@tarantool.org> <20190405194815.GH3789@chai> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Konstantin Osipov , "n.pettik" Thank you for the comments! I agree with all your suggestions and would send fixes a little bit later. Now I have one thing to discuss.=20 > On 5 Apr 2019, at 22:48, Konstantin Osipov = wrote: >=20 > * Ivan Koptelov [19/04/05 18:02]: >=20 > Besides, I guess you can get rid of this check for most common > cases - averaging a column of the same type - so this is perhaps > better to make a separate opcode, not part of the main opcode, and > emit only when we're not sure the type is going to be the same > across all values. I don't know how hard this is to do, however - > perhaps should be moved into a separate patch, but I'd guess > detecting that the aggregate function argument has a non-mutable > type is not hard.=20 >=20 > --=20 > Konstantin Osipov, Moscow, Russia, +7 903 626 22 32 > http://tarantool.io - www.twitter.com/kostja_osipov I am not quite understand why do you use word =E2=80=98opcode=E2=80=99. Functions are implemented as C code. Considering your suggestion (one =E2=80=98opcode=E2=80=99 for simple = cases, another one - for complex) I want to do the following: 1) Add a bunch of INTERNAL functions, for example max_number, max_text = and max_scalar. max_number and max_text would not have excess type checks, while = max_scalar would have all necessary type checks. So a bunch of INTERNAL functions would = implement one EXTERNAL function (just max() in this example). 2) In runtime determine proper INTERNAL function (max_number, max_text = or max_scalar) to implement given function. It would be done only once (not on the every step of = aggregate function) using information about column type. For example: SELECT MAX(b) FROM test_table; If test_table.b has TEXT type we would use max_text. If test_table.b has = SCALAR type we would max_scalar. =20 If this question seem for you to be too =E2=80=98low-level=E2=80=99 I = can just send the code for the next review round.