Tarantool development patches archive
 help / color / mirror / Atom feed
From: Timur Safin via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: "'Mergen Imeev'" <imeevma@tarantool.org>
Cc: <tarantool-patches@dev.tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH 1/3] sql: fixes for boolean expressions in explicit converstion tables
Date: Thu, 3 Jun 2021 00:10:35 +0300	[thread overview]
Message-ID: <053e01d757f3$bae97350$30bc59f0$@tarantool.org> (raw)
In-Reply-To: 

Pushed "Send" button too early. Continue...

: From: Timur Safin <tsafin@tarantool.org>
: Sent: Thursday, June 3, 2021 12:04 AM
: To: 'Mergen Imeev' <imeevma@tarantool.org>
: Cc: 'tarantool-patches@dev.tarantool.org' <tarantool-
: patches@dev.tarantool.org>
: Subject: RE: [PATCH 1/3] sql: fixes for boolean expressions in explicit
: converstion tables
: 
...

: : > diff --git a/test/sql-tap/e_select1.test.lua b/test/sql-
: : tap/e_select1.test.lua
: : > index ab0faa376..28ea1d82f 100755
: : > --- a/test/sql-tap/e_select1.test.lua
: : > +++ b/test/sql-tap/e_select1.test.lua
: : > @@ -910,7 +910,7 @@ test:do_select_tests(
: : >
: : >          {"3", "SELECT sum(b+1) FROM z1 NATURAL LEFT JOIN z3", {-
: 43.06}},
: : >          {"4", "SELECT sum(b+2) FROM z1 NATURAL LEFT JOIN z3", {-
: 38.06}},
: : > -        {"5", "SELECT sum(CAST(b IS NOT NULL AS INTEGER)) FROM z1
: NATURAL
: : LEFT JOIN z3", {5}},
: : > +        {"5", "SELECT sum(CASE WHEN b IS NOT NULL THEN 1 ELSE 0 END)
: FROM
: : z1 NATURAL LEFT JOIN z3", {5}},
: : >      })
: : >
: : >  -- EVIDENCE-OF: R-26684-40576 Each non-aggregate expression in the
: : > diff --git a/test/sql-tap/in1.test.lua b/test/sql-tap/in1.test.lua
: : > index 4b51da6e8..0fb059760 100755
: : > --- a/test/sql-tap/in1.test.lua
: : > +++ b/test/sql-tap/in1.test.lua
: : > @@ -97,13 +97,13 @@ test:do_execsql_test(
: : >          -- </in-1.6>
: : >      })
: : >
: : > -test:do_execsql_test(
: : > +test:do_catchsql_test(
: : 13. Do you really need to change type of the test? I believe you can do
: the
: : same you did in the previous test.

Good point. I've updated this result file via --update-result before 
I realized the more accurate way in the different test.

: :
: : >      "in-1.7",
: : >      [[
: : >          SELECT a+ 100*CAST((a BETWEEN 1 and 3) AS INTEGER) FROM t1
: ORDER
: : BY b
: : >      ]], {
: : >          -- <in-1.7>
: : > -        101, 102, 103, 4, 5, 6, 7, 8, 9, 10
: : > +        1, "Type mismatch: can not convert TRUE to integer"
: : >          -- </in-1.7>
: : >      })
: : >
: : > @@ -154,13 +154,13 @@ test:do_execsql_test(
: : >          -- </in-2.4>
: : >      })
: : >
: : > -test:do_execsql_test(
: : > +test:do_catchsql_test(
: : 14. Same.
: :
: : >      "in-2.5",
: : >      [[
: : >          SELECT a+100*(CAST(b IN (8,16,24) AS INTEGER)) FROM t1 ORDER BY
: b
: : >      ]], {
: : >          -- <in-2.5>
: : > -        1, 2, 103, 104, 5, 6, 7, 8, 9, 10
: : > +        1, "Type mismatch: can not convert FALSE to integer"
: : >          -- </in-2.5>
: : >      })
: : >
: : > @@ -204,13 +204,13 @@ test:do_execsql_test(
: : >          -- </in-2.9>
: : >      })
: : >
: : > -test:do_execsql_test(
: : > +test:do_catchsql_test(
: : 15. Same.
: :
: : >      "in-2.10",
: : >      [[
: : >          SELECT a FROM t1 WHERE LEAST(0, CAST(b IN (a,30) AS INT)) <> 0
: : >      ]], {
: : >          -- <in-2.10>
: : > -
: : > +        1, "Type mismatch: can not convert FALSE to integer"
: : >          -- </in-2.10>
: : >      })
: : >
: : > @@ -250,13 +250,13 @@ test:do_execsql_test(
: : >          -- </in-3.2>
: : >      })
: : >
: : > -test:do_execsql_test(
: : > +test:do_catchsql_test(
: : 16. Same.
: :
: : >      "in-3.3",
: : >      [[
: : >          SELECT a + 100*(CAST(b IN (SELECT b FROM t1 WHERE a<5) AS
: : INTEGER)) FROM t1 ORDER BY b
: : >      ]], {
: : >          -- <in-3.3>
: : > -        101, 102, 103, 104, 5, 6, 7, 8, 9, 10
: : > +        1, "Type mismatch: can not convert TRUE to integer"
: : >          -- </in-3.3>
: : >      })
: : >
: : > diff --git a/test/sql-tap/misc3.test.lua b/test/sql-tap/misc3.test.lua
: : > index 313484b5d..c2dc67355 100755
: : > --- a/test/sql-tap/misc3.test.lua
: : > +++ b/test/sql-tap/misc3.test.lua
: : > @@ -510,7 +510,7 @@ test:do_execsql_test(
: : >  test:do_execsql_test(
: : >      "misc-8.2",
: : >      [[
: : > -        SELECT count(*) FROM t3 WHERE 1+CAST((b IN ('abc','xyz')) AS
: : INTEGER)==2
: : > +        SELECT count(*) FROM t3 WHERE b IN ('abc','xyz')
: : 17. Somehow this change looks a bit too much. What checks this test?
: :
: : >      ]], {
: : >          -- <misc-8.2>
: : >          2
: : > diff --git a/test/sql/boolean.result b/test/sql/boolean.result
: : > index 177a39fb9..b268eb2fe 100644
: : > --- a/test/sql/boolean.result
: : > +++ b/test/sql/boolean.result
: : > @@ -502,23 +502,13 @@ INSERT INTO t3 VALUES (4, false)
: : >  -- Check CAST from BOOLEAN to the other types.
: : >  SELECT cast(true AS INTEGER), cast(false AS INTEGER);
: : >   | ---
: : > - | - metadata:
: : > - |   - name: COLUMN_1
: : > - |     type: integer
: : > - |   - name: COLUMN_2
: : > - |     type: integer
: : > - |   rows:
: : > - |   - [1, 0]
: : > + | - null
: : > + | - 'Type mismatch: can not convert TRUE to integer'
: : >   | ...
: : >  SELECT cast(true AS NUMBER), cast(false AS NUMBER);
: : >   | ---
: : > - | - metadata:
: : > - |   - name: COLUMN_1
: : > - |     type: number
: : > - |   - name: COLUMN_2
: : > - |     type: number
: : > - |   rows:
: : > - |   - [1, 0]
: : > + | - null
: : > + | - 'Type mismatch: can not convert TRUE to number'
: : >   | ...
: : >  -- gh-4462: ensure that text representation is uppercase.
: : >  SELECT cast(true AS TEXT), cast(false AS TEXT);
: : > @@ -545,25 +535,13 @@ SELECT cast(true AS BOOLEAN), cast(false AS
: : BOOLEAN);
: : >  -- Check CAST to BOOLEAN from the other types.
: : >  SELECT cast(100 AS BOOLEAN), cast(1 AS BOOLEAN), cast(0 AS BOOLEAN);
: : >   | ---
: : > - | - metadata:
: : > - |   - name: COLUMN_1
: : > - |     type: boolean
: : > - |   - name: COLUMN_2
: : > - |     type: boolean
: : > - |   - name: COLUMN_3
: : > - |     type: boolean
: : > - |   rows:
: : > - |   - [true, true, false]
: : > + | - null
: : > + | - 'Type mismatch: can not convert 100 to boolean'
: : >   | ...
: : >  SELECT cast(0.123 AS BOOLEAN), cast(0.0 AS BOOLEAN);
: : >   | ---
: : > - | - metadata:
: : > - |   - name: COLUMN_1
: : > - |     type: boolean
: : > - |   - name: COLUMN_2
: : > - |     type: boolean
: : > - |   rows:
: : > - |   - [true, false]
: : > + | - null
: : > + | - 'Type mismatch: can not convert 0.123 to boolean'
: : >   | ...
: : >  SELECT cast('true' AS BOOLEAN), cast('false' AS BOOLEAN);
: : >   | ---
: : > diff --git a/test/sql/types.result b/test/sql/types.result
: : > index 687ca3b15..d59cbef7d 100644
: : > --- a/test/sql/types.result
: : > +++ b/test/sql/types.result
: : > @@ -1035,11 +1035,8 @@ box.execute("SELECT CAST(18446744073709551615 AS
: : SCALAR);")
: : >  ...
: : >  box.execute("SELECT CAST(18446744073709551615 AS BOOLEAN);")
: : >  ---
: : > -- metadata:
: : > -  - name: COLUMN_1
: : > -    type: boolean
: : > -  rows:
: : > -  - [true]
: : > +- null
: : > +- 'Type mismatch: can not convert 18446744073709551615 to boolean'
: : >  ...
: : >  box.execute("SELECT CAST('18446744073709551615' AS INTEGER);")
: : >  ---
: : > @@ -1105,11 +1102,8 @@ box.execute("SELECT CAST(-1.5 AS UNSIGNED);")
: : >  ...
: : >  box.execute("SELECT CAST(true AS UNSIGNED);")
: : >  ---
: : > -- metadata:
: : > -  - name: COLUMN_1
: : > -    type: unsigned
: : > -  rows:
: : > -  - [1]
: : > +- null
: : > +- 'Type mismatch: can not convert TRUE to unsigned'
: : >  ...
: : >  box.execute("SELECT CAST('123' AS UNSIGNED);")
: : >  ---
: : > --
: : > 2.29.2
: : >

: : 18. Please add tests for this patch.

Are you serious here? Updates of older tests and extensive matrix in e_casts.test.lua 
are tests for this patch. There is no point to create any kind of result-based test,
neither manual tap test, at the moment when we have full conversion table covered in
e_casts.test.lua.

Timur


  parent reply	other threads:[~2021-06-02 21:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25  9:00 [Tarantool-patches] [PATCH 0/3] sql: modify explicit conversion tables Timur Safin via Tarantool-patches
2021-05-25  9:01 ` [Tarantool-patches] [PATCH 1/3] sql: fixes for boolean expressions in explicit converstion tables Timur Safin via Tarantool-patches
2021-06-01 14:02   ` Mergen Imeev via Tarantool-patches
2021-06-02 21:03     ` Timur Safin via Tarantool-patches
2021-06-02 21:10     ` Timur Safin via Tarantool-patches [this message]
2021-05-25  9:01 ` [Tarantool-patches] [PATCH 2/3] sql: enabled ANY as target for explicit conversions Timur Safin via Tarantool-patches
2021-06-01 14:02   ` Mergen Imeev via Tarantool-patches
2021-06-02 21:04     ` Timur Safin via Tarantool-patches
2021-05-25  9:01 ` [Tarantool-patches] [PATCH 3/3] sql: introduced explicit casts test e_casts.test.lua Timur Safin via Tarantool-patches
2021-06-01 14:02   ` Mergen Imeev via Tarantool-patches
2021-06-02 21:04     ` Timur Safin via Tarantool-patches
2021-06-01 14:02 ` [Tarantool-patches] [PATCH 0/3] sql: modify explicit conversion tables Mergen Imeev via Tarantool-patches
2021-06-02 21:04   ` Timur Safin 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='053e01d757f3$bae97350$30bc59f0$@tarantool.org' \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tsafin@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 1/3] sql: fixes for boolean expressions in explicit converstion tables' \
    /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