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 7746927195 for ; Wed, 28 Aug 2019 10:11:15 -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 BQbXqkcuKc_X for ; Wed, 28 Aug 2019 10:11:15 -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 2EE0226938 for ; Wed, 28 Aug 2019 10:11:15 -0400 (EDT) Date: Wed, 28 Aug 2019 17:11:12 +0300 From: Mergen Imeev Subject: [tarantool-patches] Re: [PATCH v1 1/1] sql: test suite for BOOLEAN Message-ID: <20190828141112.GA19164@tarantool.org> References: <2ecdecf63e68a73815c48d9ff369cbd129ad28d6.1563198457.git.imeevma@gmail.com> <20190716095708.GA29957@tarantool.org> <20190724115237.GA22402@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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: "n.pettik" Cc: tarantool-patches@freelists.org Hi! Thank you for review! My answers below. On Thu, Aug 08, 2019 at 06:30:57PM +0300, n.pettik wrote: > > > >> 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). > >> > > Not sure if these are bugs: > > > > 1) Different results in case of internal convertion from > > BOOLEAN to TEXT: > > > > tarantool> CREATE TABLE t(a BOOLEAN PRIMARY KEY); > > --- > > - row_count: 1 > > ... > > > > tarantool> INSERT INTO t VALUES (true), (false); > > --- > > - row_count: 2 > > ... > > > > tarantool> SELECT GROUP_CONCAT(a, '+++') FROM t; > > --- > > - metadata: > > - name: GROUP_CONCAT(a, '+++') > > type: string > > rows: > > - ['false+++true'] > > … > > I’d say it’s a tiny bug. > > > tarantool> SELECT GROUP_CONCAT(CAST(a AS TEXT), '+++') FROM t; > > --- > > - metadata: > > - name: GROUP_CONCAT(CAST(a AS TEXT), '+++') > > type: string > > rows: > > - ['FALSE+++TRUE'] > > ... > > > > 2) CAST() does not cast from BOOLEAN to FLOAT, but it works > > in case FLOAT casted to BOOLEAN: > > > > tarantool> SELECT cast(0.123 AS BOOLEAN), cast(0.0 AS BOOLEAN); > > --- > > - metadata: > > - name: cast(0.123 AS BOOLEAN) > > type: boolean > > - name: cast(0.0 AS BOOLEAN) > > type: boolean > > rows: > > - [true, false] > > … > > It’s OK by design. > > > 3) Operator IN works in one case and doesn't work in > > another: > > > > tarantool> SELECT true in (1,2,3); > > --- > > - metadata: > > - name: true in (1,2,3) > > type: boolean > > rows: > > - [false] > > ... > > > > tarantool> SELECT true IN (VALUES(1), (2), (3)); > > --- > > - error: 'Type mismatch: can not convert true to integer' > > ... > > > > 4) Function LENGTH() returns NULL when argument is BOOLEAN: > > > > tarantool> SELECT length(false); > > --- > > - metadata: > > - name: length(false) > > type: integer > > rows: > > - [null] > > … > > Please, file one issue containing first, third and fourth > points. > Done: https://github.com/tarantool/tarantool/issues/4462 > > > > 5) Operator AND works differently for these cases: > > > > tarantool> SELECT 'abc' AND false; > > --- > > - metadata: > > - name: '''abc'' AND false' > > type: boolean > > rows: > > - [false] > > ... > > > > tarantool> SELECT 'abc' AND a FROM t WHERE a == false; > > --- > > - error: 'Type mismatch: can not convert abc to boolean' > > … > > Yep, I guess it is due to AND optimisation. > Not sure if we should care about it or not. > > > diff --git a/test/sql/boolean.test.sql b/test/sql/boolean.test.sql > > new file mode 100644 > > index 0000000..e45e554 > > --- /dev/null > > +++ b/test/sql/boolean.test.sql > > > > +-- Check SWITCH-CASE. > > +SELECT i, \ > > +CASE \ > > + WHEN a == true AND i % 2 == 1 THEN false \ > > + WHEN a == true and i % 2 == 0 THEN true \ > > + WHEN a != true then false \ > > +END AS a0 \ > > +FROM t4; > > + > > +-- Check OPDER BY. > > Nit: ORDER BY > Fixed. > > +SELECT * FROM t4 UNION SELECT * FROM t5 ORDER BY a, i; > > + > > +-- Check GROUP BY. > > +SELECT a, COUNT(*) FROM (SELECT * FROM t4 UNION SELECT * FROM t5) GROUP BY a; > > The rest seems to be OK. >