Fix issue #11286; add a test

This commit is contained in:
Alexey Milovidov 2020-05-30 00:32:35 +03:00
parent 94887f0c74
commit 8c8821475c
3 changed files with 124 additions and 2 deletions

View File

@ -181,8 +181,11 @@ const KeyCondition::AtomMap KeyCondition::atom_map
},
{
"empty",
[] (RPNElement & out, const Field &)
[] (RPNElement & out, const Field & value)
{
if (value.getType() != Field::Types::String)
return false;
out.function = RPNElement::FUNCTION_IN_RANGE;
out.range = Range("");
return true;
@ -190,8 +193,11 @@ const KeyCondition::AtomMap KeyCondition::atom_map
},
{
"notEmpty",
[] (RPNElement & out, const Field &)
[] (RPNElement & out, const Field & value)
{
if (value.getType() != Field::Types::String)
return false;
out.function = RPNElement::FUNCTION_NOT_IN_RANGE;
out.range = Range("");
return true;

View File

@ -0,0 +1,50 @@
--- notEmpty
['a'] 2
['a','b','c'] 3
['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'] 4
--- empty
[] 1
--- = []
[] 1
--- != []
['a'] 2
['a','b','c'] 3
['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'] 4
--- > []
['a'] 2
['a','b','c'] 3
['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'] 4
--- < []
--- >= []
[] 1
['a'] 2
['a','b','c'] 3
['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'] 4
--- <= []
[] 1
---
--- notEmpty
['a'] 2
['a','b','c'] 3
['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'] 4
--- empty
[] 1
--- = []
[] 1
--- != []
['a'] 2
['a','b','c'] 3
['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'] 4
--- > []
['a'] 2
['a','b','c'] 3
['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'] 4
--- < []
--- >= []
[] 1
['a'] 2
['a','b','c'] 3
['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'] 4
--- <= []
[] 1
---

View File

@ -0,0 +1,66 @@
drop table if exists count_lc_test;
CREATE TABLE count_lc_test
(
`s` LowCardinality(String),
`arr` Array(LowCardinality(String)),
`num` UInt64
)
ENGINE = MergeTree
ORDER BY (s, arr);
INSERT INTO count_lc_test(num, arr) VALUES (1,[]),(2,['a']),(3,['a','b','c']),(4,['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']);
SELECT '--- notEmpty';
select * from count_lc_test where notEmpty(arr);
SELECT '--- empty';
select * from count_lc_test where empty(arr);
SELECT '--- = []';
select * from count_lc_test where arr = [];
SELECT '--- != []';
select * from count_lc_test where arr != [];
SELECT '--- > []';
select * from count_lc_test where arr > [];
SELECT '--- < []';
select * from count_lc_test where arr < [];
SELECT '--- >= []';
select * from count_lc_test where arr >= [];
SELECT '--- <= []';
select * from count_lc_test where arr <= [];
SELECT '---';
DROP TABLE count_lc_test;
drop table if exists count_lc_test;
CREATE TABLE count_lc_test
(
`s` LowCardinality(String),
`arr` Array(String),
`num` UInt64
)
ENGINE = MergeTree
ORDER BY (s, arr);
INSERT INTO count_lc_test(num, arr) VALUES (1,[]),(2,['a']),(3,['a','b','c']),(4,['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']);
SELECT '--- notEmpty';
select * from count_lc_test where notEmpty(arr);
SELECT '--- empty';
select * from count_lc_test where empty(arr);
SELECT '--- = []';
select * from count_lc_test where arr = [];
SELECT '--- != []';
select * from count_lc_test where arr != [];
SELECT '--- > []';
select * from count_lc_test where arr > [];
SELECT '--- < []';
select * from count_lc_test where arr < [];
SELECT '--- >= []';
select * from count_lc_test where arr >= [];
SELECT '--- <= []';
select * from count_lc_test where arr <= [];
SELECT '---';
DROP TABLE count_lc_test;