From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH v2 3/4] sql: introduce custom aggregate functions Date: Fri, 4 Feb 2022 00:29:55 +0100 [thread overview] Message-ID: <08ca2f7e-77fd-d4ce-fb87-e0c1b07e29cd@tarantool.org> (raw) In-Reply-To: <344a9ef9b7eca47ae257d0ea944866d27ff589e6.1643722506.git.imeevma@gmail.com> Hi! Thanks for the patch! See 3 comments below. After you done with them, send to a next reviewer right away. > diff --git a/src/box/sql/func.c b/src/box/sql/func.c > index b69bf7fd6..cda872194 100644 > --- a/src/box/sql/func.c > +++ b/src/box/sql/func.c > @@ -2060,9 +2060,12 @@ sql_func_find(struct Expr *expr) > return NULL; > } > int n = expr->x.pList != NULL ? expr->x.pList->nExpr : 0; > - if (func->def->param_count != n) { > + int argc = func->def->aggregate == FUNC_AGGREGATE_GROUP ? > + func->def->param_count - 1 : func->def->param_count; 1. Why -1 for aggregates? I see it is somehow related to the last argument being used for state, but it looks intricate. A comment here would be enough. > + assert(argc >= 0); > + if (argc != n) { > diag_set(ClientError, ER_FUNC_WRONG_ARG_COUNT, name, > - tt_sprintf("%d", func->def->param_count), n); > + tt_sprintf("%d", argc), n); > return NULL; > } > return func;> diff --git a/test/sql-tap/gh-2579-custom-aggregate.test.lua b/test/sql-tap/gh-2579-custom-aggregate.test.lua > new file mode 100755 > index 000000000..213e2e870 > --- /dev/null > +++ b/test/sql-tap/gh-2579-custom-aggregate.test.lua > @@ -0,0 +1,113 @@ > +#!/usr/bin/env tarantool > +local build_path = os.getenv("BUILDDIR") > +package.cpath = build_path..'/test/sql-tap/?.so;'..build_path..'/test/sql-tap/?.dylib;'..package.cpath 2. Lets split it at 80th line column. > + > +local test = require("sqltester") > +test:plan(5) > + > +test:execsql([[ > + CREATE TABLE t (i INT PRIMARY KEY); > + INSERT INTO t VALUES(1), (2), (3), (4), (5); > + ]]) 3. You probably forgot to left shift the expression for one tab.
next prev parent reply other threads:[~2022-02-03 23:29 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-01 13:37 [Tarantool-patches] [PATCH v2 0/4] Introduce custom aggregate function Mergen Imeev via Tarantool-patches 2022-02-01 13:37 ` [Tarantool-patches] [PATCH v2 1/4] sql: fix COUNT() optimization conditions Mergen Imeev via Tarantool-patches 2022-02-01 13:37 ` [Tarantool-patches] [PATCH v2 2/4] sql: drop unnecessary P2 register for OP_AggFinal Mergen Imeev via Tarantool-patches 2022-02-01 13:37 ` [Tarantool-patches] [PATCH v2 3/4] sql: introduce custom aggregate functions Mergen Imeev via Tarantool-patches 2022-02-03 23:29 ` Vladislav Shpilevoy via Tarantool-patches [this message] 2022-02-01 13:37 ` [Tarantool-patches] [PATCH v2 4/4] sql: introduce FINALIZE for custom aggregate Mergen Imeev via Tarantool-patches 2022-02-03 23:30 ` Vladislav Shpilevoy via Tarantool-patches 2022-02-10 9:21 ` Mergen Imeev via Tarantool-patches 2022-02-10 9:14 [Tarantool-patches] [PATCH v2 0/4] Introduce custom aggregate functions Mergen Imeev via Tarantool-patches 2022-02-10 9:14 ` [Tarantool-patches] [PATCH v2 3/4] sql: introduce " Mergen Imeev via Tarantool-patches
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=08ca2f7e-77fd-d4ce-fb87-e0c1b07e29cd@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imeevma@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 3/4] sql: introduce custom aggregate functions' \ /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