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 79A8525254 for ; Thu, 18 Jul 2019 14:05:40 -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 rLU9BSgZa-iX for ; Thu, 18 Jul 2019 14:05:40 -0400 (EDT) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (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 E4ECA22941 for ; Thu, 18 Jul 2019 14:05:39 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: [tarantool-patches] Re: [PATCH v1 1/1] sql: test suite for BOOLEAN From: "n.pettik" In-Reply-To: <20190716095708.GA29957@tarantool.org> Date: Thu, 18 Jul 2019 21:05:37 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <2ecdecf63e68a73815c48d9ff369cbd129ad28d6.1563198457.git.imeevma@gmail.com> <20190716095708.GA29957@tarantool.org> 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: Imeev Mergen > =46rom 92649b7b53483d4bbb947e300acf569d85e25001 Mon Sep 17 00:00:00 = 2001 > Date: Tue, 16 Jul 2019 12:43:51 +0300 > Subject: [PATCH] sql: test suite for BOOLEAN >=20 > This patch provides a test suite that allows us to make sure that > the SQL BOOLEAN type works as intended. >=20 > Part of #4228 Could you remove duplicate tests from sql/types.test.lua ? That is let=E2=80=99s move all tests related to boolean to this suite. You added a lot of tests checking work with literals - that=E2=80=99s = OK, but I=E2=80=99d like to see the same amount of tests with table columns. I don=E2=80=99t ask you to duplicate these tests, but come up with new ones. At the end of letter I suggest several ways to extend this suite. I=E2=80=99d say it would be great job if you found a few bugs (at least = one). > diff --git a/test/sql/boolean.test.sql b/test/sql/boolean.test.sql > new file mode 100644 > index 0000000..7a1a0dc > --- /dev/null > +++ b/test/sql/boolean.test.sql > @@ -0,0 +1,405 @@ > +-- Create table for tests > +CREATE TABLE t (a BOOLEAN PRIMARY KEY); > +INSERT INTO t VALUES (true), (false); I=E2=80=99d add cases involving secondary index comprising nulls. > + > +-- Create user-defined function. > +\set language lua > +function return_type(arg) return type(arg) end > +box.internal.sql_create_function("return_type", "TEXT", return_type) > +\set language sql > + > +-- Check boolean as WHERE argument. > +SELECT a FROM t WHERE a; > +SELECT a FROM t WHERE a !=3D true; > + > +-- Check that we can create index on field of type BOOLEAN. > +CREATE INDEX i1 ON t(a); > + > +-- Check boolean as LIMIT argument. > +SELECT * FROM t LIMIT true; > +SELECT * FROM t LIMIT false; > + > +-- Check boolean as OFFSET argument. > +SELECT * FROM t LIMIT 1 OFFSET true; > +SELECT * FROM t LIMIT 1 OFFSET false; > + > +-- Check involvance in index search. > +EXPLAIN QUERY PLAN SELECT a FROM t WHERE a =3D true; > + > +-- Check that ephemeral tables are used with BOOLEAN. > +\set language lua > +result =3D box.execute('EXPLAIN SELECT * FROM (VALUES(true)), t;') > +i =3D 0 > +for _,v in pairs(result.rows) do if (v[2] =3D=3D 'OpenTEphemeral') = then i =3D i + 1 end end > +i > 0 > +\set language sql > + > +-- Check BOOLEAN as argument of user-defined function. > +SELECT return_type(a) FROM t; What about functions returning boolean type? > + > +-- Check BOOLEAN as argument of scalar function. > +SELECT typeof(a) FROM t; > + > +-- Check BOOLEAN as argument of aggregate function. > +SELECT count(a) FROM t GROUP BY a; Why only one aggregate? > + > +-- Check UNION, UNION ALL AND INTERSECT. > +INSERT INTO t5 VALUES (100, false); > +SELECT * FROM t4 UNION SELECT * FROM t5; > +SELECT * FROM t4 UNION ALL SELECT * FROM t5; > +SELECT * FROM t4 INTERSECT SELECT * FROM t5; > + > +-- Check SUBSELECT. > +INSERT INTO t5(b) SELECT a FROM t4; > +SELECT * FROM t5; > + > +-- Check VIEW. > +CREATE VIEW v AS SELECT b FROM t5; > +SELECT * FROM v; > + > +-- Check DISTINCT. > +SELECT DISTINCT * FROM v; Add tests on CTE, joins, UPDATE, switch-case, ORDER BY (which again requires check of OP_Sort), more sophisticated subquery examples.