Tarantool development patches archive
 help / color / mirror / Atom feed
From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Imeev Mergen <imeevma@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v1 1/1] sql: test suite for BOOLEAN
Date: Thu, 18 Jul 2019 21:05:37 +0300	[thread overview]
Message-ID: <C712909B-A1B9-458D-9E71-54D30A906438@tarantool.org> (raw)
In-Reply-To: <20190716095708.GA29957@tarantool.org>


> From 92649b7b53483d4bbb947e300acf569d85e25001 Mon Sep 17 00:00:00 2001
> Date: Tue, 16 Jul 2019 12:43:51 +0300
> Subject: [PATCH] sql: test suite for BOOLEAN
> 
> This patch provides a test suite that allows us to make sure that
> the SQL BOOLEAN type works as intended.
> 
> Part of #4228

Could you remove duplicate tests from sql/types.test.lua ?
That is let’s move all tests related to boolean to this suite.

You added a lot of tests checking work with literals - that’s OK,
but I’d like to see the same amount of tests with table columns.
I don’t 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’d 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’d 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 != 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 = true;
> +
> +-- Check that ephemeral tables are used with BOOLEAN.
> +\set language lua
> +result = box.execute('EXPLAIN SELECT * FROM (VALUES(true)), t;')
> +i = 0
> +for _,v in pairs(result.rows) do if (v[2] == 'OpenTEphemeral') then i = 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.

  reply	other threads:[~2019-07-18 18:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-15 13:49 [tarantool-patches] " imeevma
2019-07-15 14:39 ` [tarantool-patches] " Konstantin Osipov
2019-07-15 18:02 ` n.pettik
2019-07-16  9:57   ` Mergen Imeev
2019-07-18 18:05     ` n.pettik [this message]
2019-07-24 11:52       ` Mergen Imeev
2019-08-08 15:30         ` n.pettik
2019-08-28 14:11           ` Mergen Imeev
2019-08-28 16:51             ` Nikita Pettik
2019-09-12  5:12 ` Kirill Yukhin

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=C712909B-A1B9-458D-9E71-54D30A906438@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v1 1/1] sql: test suite for BOOLEAN' \
    /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