[MCOL-1178] empty result with "case .. when" with where condition and multiple parameter in "IN" clause Created: 2018-01-25 Updated: 2020-08-25 Resolved: 2018-02-02 |
|
| Status: | Closed |
| Project: | MariaDB ColumnStore |
| Component/s: | None |
| Affects Version/s: | 1.0.0 |
| Fix Version/s: | 1.1.3 |
| Type: | Bug | Priority: | Major |
| Reporter: | Richard Stracke | Assignee: | Daniel Lee (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Tested on Debian 9 + MCS 1.1.2 |
||
| Sprint: | 2018-03 |
| Description |
|
to reproduce: Preparation:
With one parameter , all is fine.
With two parameter, the columnstore table return no resultset, even the where condition is true.
|
| Comments |
| Comment by Richard Stracke [ 2018-01-26 ] | ||||||||||
|
Interesting is the error message for the (not) possible workaround with or
| ||||||||||
| Comment by David Hall (Inactive) [ 2018-02-02 ] | ||||||||||
|
The reason this works for a single item for IN is that the IN is optimized away to "astr = 'test'" which works fine. The problem is that case doesn't support a boolean in the THEN clause. Everything works as expected, but the lack of the getBoolVal() function meant it called the getIntVal() method instead. class ConstantFilter, which implements the IN clause, doesn't support getIntVal() so the default implementation was used, which always returns 0. The fix is to add getBoolVal() to case. | ||||||||||
| Comment by David Hall (Inactive) [ 2018-02-02 ] | ||||||||||
|
SELECT astr FROM test_mcs WHERE CASE WHEN COALESCE('0') = '0' THEN astr in ('test') or astr in ('fff') END; | ||||||||||
| Comment by Daniel Lee (Inactive) [ 2018-02-02 ] | ||||||||||
|
Build verified: Github source 1.1.3-1 root@stretch:~/columnstore/mariadb-columnstore-server# git show Merge pull request #92 from mariadb-corporation/ root@stretch:~/columnstore/mariadb-columnstore-server/mariadb-columnstore-engine# git show Merge pull request #395 from mariadb-corporation/ Reproduced the issue in 1.1.2-1 and verified fix in 1.1.3-1 Welcome to the MariaDB monitor. Commands end with ; or \g. Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> create database ct; MariaDB [(none)]> use ct; MariaDB [ct]> create table test_mcs (astr VARCHAR(50))ENGINE = COLUMNSTORE ; MariaDB [ct]> INSERT INTO test_inno (astr) value('test'); MariaDB [ct]> INSERT INTO test_mcs (astr) value('test'); MariaDB [ct]> SELECT astr FROM test_mcs WHERE CASE WHEN COALESCE('0') = '0' THEN astr IN ('test','unknown') END;
------
------ MariaDB [ct]> |