Fixed tests

This commit is contained in:
Maksim Kita 2021-09-28 12:52:07 +03:00
parent e290f19957
commit f2402e1a10
3 changed files with 268 additions and 26 deletions

View File

@ -16,8 +16,6 @@
#include <Parsers/ASTLiteral.h>
#include <Parsers/ASTSubquery.h>
#include <Core/Defines.h>
#include <Columns/ColumnMap.h>
#include <DataTypes/DataTypeMap.h>
#include <Poco/Logger.h>
@ -550,7 +548,7 @@ bool MergeTreeConditionFullText::traverseASTEquals(
else if (function_name == "equals")
{
out.key_column = key_column_num;
return createFunctionEqualsCondition(out, value_field, params, token_extractor);
return createFunctionEqualsCondition(out, const_value, params, token_extractor);
}
else if (function_name == "like")
{

View File

@ -1,4 +1,104 @@
Map full text bloom filter tokenbf mapKeys
Equals with existing key
0 {'K0':'V0'} {'K0':'V0'}
Equals with non existing key
Equals with non existing key and default value
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
2 {'K2':'V2'} {'K2':'V2'}
Not equals with existing key
1 {'K1':'V1'} {'K1':'V1'}
2 {'K2':'V2'} {'K2':'V2'}
Not equals with non existing key
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
Not equals with non existing key and default value
Map fixed full text bloom filter tokenbf mapKeys
Equals with existing key
0 {'K0':'V0'} {'K0':'V0'}
Equals with non existing key
Equals with non existing key and default value
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
Not equals with existing key
1 {'K1':'V1'} {'K1':'V1'}
Not equals with non existing key
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
Not equals with non existing key and default value
Map full text bloom filter tokenbf mapValues
Equals with existing key
0 {'K0':'V0'} {'K0':'V0'}
Equals with non existing key
Equals with non existing key and default value
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
Not equals with existing key
1 {'K1':'V1'} {'K1':'V1'}
Not equals with non existing key
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
Not equals with non existing key and default value
Map fixed full text bloom filter tokenbf mapKeys
Equals with existing key
0 {'K0':'V0'} {'K0':'V0'}
Equals with non existing key
Equals with non existing key and default value
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
Not equals with existing key
1 {'K1':'V1'} {'K1':'V1'}
Not equals with non existing key
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
Not equals with non existing key and default value
Map full text bloom filter ngrambf mapKeys
Equals with existing key
0 {'K0':'V0'} {'K0':'V0'}
Equals with non existing key
Equals with non existing key and default value
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
Not equals with existing key
1 {'K1':'V1'} {'K1':'V1'}
Not equals with non existing key
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
Not equals with non existing key and default value
Map fixed full text bloom filter ngrambf mapKeys
Equals with existing key
0 {'K0':'V0'} {'K0':'V0'}
Equals with non existing key
Equals with non existing key and default value
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
Not equals with existing key
1 {'K1':'V1'} {'K1':'V1'}
Not equals with non existing key
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
Not equals with non existing key and default value
Map full text bloom filter ngrambf mapValues
Equals with existing key
0 {'K0':'V0'} {'K0':'V0'}
Equals with non existing key
Equals with non existing key and default value
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
Not equals with existing key
1 {'K1':'V1'} {'K1':'V1'}
Not equals with non existing key
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
Not equals with non existing key and default value
Map fixed full text bloom filter ngrambf mapKeys
Equals with existing key
0 {'K0':'V0'} {'K0':'V0'}
Equals with non existing key
Equals with non existing key and default value
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
Not equals with existing key
1 {'K1':'V1'} {'K1':'V1'}
Not equals with non existing key
0 {'K0':'V0'} {'K0':'V0'}
1 {'K1':'V1'} {'K1':'V1'}
Not equals with non existing key and default value

View File

@ -1,30 +1,174 @@
DROP TABLE IF EXISTS bf_tokenbf_map_test;
DROP TABLE IF EXISTS bf_ngram_map_test;
DROP TABLE IF EXISTS bf_tokenbf_map_keys_test;
DROP TABLE IF EXISTS bf_ngrambf_map_keys_test;
CREATE TABLE bf_tokenbf_map_test
(
row_id UInt32,
map Map(String, String),
INDEX map_tokenbf map TYPE tokenbf_v1(256,2,0) GRANULARITY 1
) Engine=MergeTree() ORDER BY row_id SETTINGS index_granularity = 2;
CREATE TABLE bf_ngram_map_test
CREATE TABLE bf_tokenbf_map_keys_test
(
row_id UInt32,
map Map(String, String),
map_fixed Map(FixedString(2), String),
INDEX map_ngram map TYPE ngrambf_v1(4,256,2,0) GRANULARITY 1,
INDEX map_fixed_ngram map_fixed TYPE ngrambf_v1(4,256,2,0) GRANULARITY 1
) Engine=MergeTree() ORDER BY row_id SETTINGS index_granularity = 2;
INDEX map_keys_tokenbf mapKeys(map) TYPE tokenbf_v1(256,2,0) GRANULARITY 1,
INDEX map_fixed_keys_tokenbf mapKeys(map_fixed) TYPE ngrambf_v1(4,256,2,0) GRANULARITY 1
) Engine=MergeTree() ORDER BY row_id SETTINGS index_granularity = 1;
INSERT INTO bf_tokenbf_map_test VALUES (1, {'K1':'V1'}, {'K1':'V1'}), (2, {'K2':'V2'}, {'K2':'V2'});
INSERT INTO bf_ngram_map_test VALUES (1, {'K1':'V1'}, {'K1':'V1'}), (2, {'K2':'V2'}, {'K2':'V2'});
INSERT INTO bf_tokenbf_map_keys_test VALUES (0, {'K0':'V0'}, {'K0':'V0'}), (1, {'K1':'V1'}, {'K1':'V1'});
SELECT * FROM bf_tokenbf_map_test WHERE map['K1']='V1';
SELECT * FROM bf_ngram_map_test WHERE map['K2']='V2';
SELECT 'Map full text bloom filter tokenbf mapKeys';
SELECT * FROM bf_tokenbf_map_test WHERE map_fixed['K1']='V1';
SELECT * FROM bf_ngram_map_test WHERE map_fixed['K2']='V2';
SELECT 'Equals with existing key';
SELECT * FROM bf_tokenbf_map_keys_test WHERE map['K0'] = 'V0' SETTINGS force_data_skipping_indices='map_keys_tokenbf';
SELECT 'Equals with non existing key';
SELECT * FROM bf_tokenbf_map_keys_test WHERE map['K2'] = 'V2' SETTINGS force_data_skipping_indices='map_keys_tokenbf';
SELECT 'Equals with non existing key and default value';
SELECT * FROM bf_tokenbf_map_keys_test WHERE map['K3'] = '';
SELECT 'Not equals with existing key';
SELECT * FROM bf_tokenbf_map_keys_test WHERE map['K0'] != 'V0' SETTINGS force_data_skipping_indices='map_keys_tokenbf';
SELECT 'Not equals with non existing key';
SELECT * FROM bf_tokenbf_map_keys_test WHERE map['K2'] != 'V2' SETTINGS force_data_skipping_indices='map_keys_tokenbf';
SELECT 'Not equals with non existing key and default value';
SELECT * FROM bf_tokenbf_map_keys_test WHERE map['K3'] != '';
DROP TABLE bf_tokenbf_map_test;
DROP TABLE bf_ngram_map_test;
SELECT 'Map fixed full text bloom filter tokenbf mapKeys';
SELECT 'Equals with existing key';
SELECT * FROM bf_tokenbf_map_keys_test WHERE map_fixed['K0'] = 'V0' SETTINGS force_data_skipping_indices='map_fixed_keys_tokenbf';
SELECT 'Equals with non existing key';
SELECT * FROM bf_tokenbf_map_keys_test WHERE map_fixed['K2'] = 'V2' SETTINGS force_data_skipping_indices='map_fixed_keys_tokenbf';
SELECT 'Equals with non existing key and default value';
SELECT * FROM bf_tokenbf_map_keys_test WHERE map_fixed['K3'] = '';
SELECT 'Not equals with existing key';
SELECT * FROM bf_tokenbf_map_keys_test WHERE map_fixed['K0'] != 'V0' SETTINGS force_data_skipping_indices='map_fixed_keys_tokenbf';
SELECT 'Not equals with non existing key';
SELECT * FROM bf_tokenbf_map_keys_test WHERE map_fixed['K2'] != 'V2' SETTINGS force_data_skipping_indices='map_fixed_keys_tokenbf';
SELECT 'Not equals with non existing key and default value';
SELECT * FROM bf_tokenbf_map_keys_test WHERE map_fixed['K3'] != '';
DROP TABLE bf_tokenbf_map_keys_test;
CREATE TABLE bf_tokenbf_map_values_test
(
row_id UInt32,
map Map(String, String),
map_fixed Map(FixedString(2), String),
INDEX map_values_tokenbf mapValues(map) TYPE tokenbf_v1(256,2,0) GRANULARITY 1,
INDEX map_fixed_values_tokenbf mapValues(map_fixed) TYPE ngrambf_v1(4,256,2,0) GRANULARITY 1
) Engine=MergeTree() ORDER BY row_id SETTINGS index_granularity = 1;
INSERT INTO bf_tokenbf_map_values_test VALUES (0, {'K0':'V0'}, {'K0':'V0'}), (1, {'K1':'V1'}, {'K1':'V1'});
SELECT 'Map full text bloom filter tokenbf mapValues';
SELECT 'Equals with existing key';
SELECT * FROM bf_tokenbf_map_values_test WHERE map['K0'] = 'V0' SETTINGS force_data_skipping_indices='map_values_tokenbf';
SELECT 'Equals with non existing key';
SELECT * FROM bf_tokenbf_map_values_test WHERE map['K2'] = 'V2' SETTINGS force_data_skipping_indices='map_values_tokenbf';
SELECT 'Equals with non existing key and default value';
SELECT * FROM bf_tokenbf_map_values_test WHERE map['K3'] = '';
SELECT 'Not equals with existing key';
SELECT * FROM bf_tokenbf_map_values_test WHERE map['K0'] != 'V0' SETTINGS force_data_skipping_indices='map_values_tokenbf';
SELECT 'Not equals with non existing key';
SELECT * FROM bf_tokenbf_map_values_test WHERE map['K2'] != 'V2' SETTINGS force_data_skipping_indices='map_values_tokenbf';
SELECT 'Not equals with non existing key and default value';
SELECT * FROM bf_tokenbf_map_values_test WHERE map['K3'] != '';
SELECT 'Map fixed full text bloom filter tokenbf mapKeys';
SELECT 'Equals with existing key';
SELECT * FROM bf_tokenbf_map_values_test WHERE map_fixed['K0'] = 'V0' SETTINGS force_data_skipping_indices='map_fixed_values_tokenbf';
SELECT 'Equals with non existing key';
SELECT * FROM bf_tokenbf_map_values_test WHERE map_fixed['K2'] = 'V2' SETTINGS force_data_skipping_indices='map_fixed_values_tokenbf';
SELECT 'Equals with non existing key and default value';
SELECT * FROM bf_tokenbf_map_values_test WHERE map_fixed['K3'] = '';
SELECT 'Not equals with existing key';
SELECT * FROM bf_tokenbf_map_values_test WHERE map_fixed['K0'] != 'V0' SETTINGS force_data_skipping_indices='map_fixed_values_tokenbf';
SELECT 'Not equals with non existing key';
SELECT * FROM bf_tokenbf_map_values_test WHERE map_fixed['K2'] != 'V2' SETTINGS force_data_skipping_indices='map_fixed_values_tokenbf';
SELECT 'Not equals with non existing key and default value';
SELECT * FROM bf_tokenbf_map_values_test WHERE map_fixed['K3'] != '';
DROP TABLE bf_tokenbf_map_values_test;
CREATE TABLE bf_ngrambf_map_keys_test
(
row_id UInt32,
map Map(String, String),
map_fixed Map(FixedString(2), String),
INDEX map_keys_ngrambf mapKeys(map) TYPE ngrambf_v1(4,256,2,0) GRANULARITY 1,
INDEX map_fixed_keys_ngrambf mapKeys(map_fixed) TYPE ngrambf_v1(4,256,2,0) GRANULARITY 1
) Engine=MergeTree() ORDER BY row_id SETTINGS index_granularity = 1;
INSERT INTO bf_ngrambf_map_keys_test VALUES (0, {'K0':'V0'}, {'K0':'V0'}), (1, {'K1':'V1'}, {'K1':'V1'});
SELECT 'Map full text bloom filter ngrambf mapKeys';
SELECT 'Equals with existing key';
SELECT * FROM bf_ngrambf_map_keys_test WHERE map['K0'] = 'V0' SETTINGS force_data_skipping_indices='map_keys_ngrambf';
SELECT 'Equals with non existing key';
SELECT * FROM bf_ngrambf_map_keys_test WHERE map['K2'] = 'V2' SETTINGS force_data_skipping_indices='map_keys_ngrambf';
SELECT 'Equals with non existing key and default value';
SELECT * FROM bf_ngrambf_map_keys_test WHERE map['K3'] = '';
SELECT 'Not equals with existing key';
SELECT * FROM bf_ngrambf_map_keys_test WHERE map['K0'] != 'V0' SETTINGS force_data_skipping_indices='map_keys_ngrambf';
SELECT 'Not equals with non existing key';
SELECT * FROM bf_ngrambf_map_keys_test WHERE map['K2'] != 'V2' SETTINGS force_data_skipping_indices='map_keys_ngrambf';
SELECT 'Not equals with non existing key and default value';
SELECT * FROM bf_ngrambf_map_keys_test WHERE map['K3'] != '';
SELECT 'Map fixed full text bloom filter ngrambf mapKeys';
SELECT 'Equals with existing key';
SELECT * FROM bf_ngrambf_map_keys_test WHERE map_fixed['K0'] = 'V0' SETTINGS force_data_skipping_indices='map_fixed_keys_ngrambf';
SELECT 'Equals with non existing key';
SELECT * FROM bf_ngrambf_map_keys_test WHERE map_fixed['K2'] = 'V2' SETTINGS force_data_skipping_indices='map_fixed_keys_ngrambf';
SELECT 'Equals with non existing key and default value';
SELECT * FROM bf_ngrambf_map_keys_test WHERE map_fixed['K3'] = '';
SELECT 'Not equals with existing key';
SELECT * FROM bf_ngrambf_map_keys_test WHERE map_fixed['K0'] != 'V0' SETTINGS force_data_skipping_indices='map_fixed_keys_ngrambf';
SELECT 'Not equals with non existing key';
SELECT * FROM bf_ngrambf_map_keys_test WHERE map_fixed['K2'] != 'V2' SETTINGS force_data_skipping_indices='map_fixed_keys_ngrambf';
SELECT 'Not equals with non existing key and default value';
SELECT * FROM bf_ngrambf_map_keys_test WHERE map_fixed['K3'] != '';
DROP TABLE bf_ngrambf_map_keys_test;
CREATE TABLE bf_ngrambf_map_values_test
(
row_id UInt32,
map Map(String, String),
map_fixed Map(FixedString(2), String),
INDEX map_values_ngrambf mapKeys(map) TYPE ngrambf_v1(4,256,2,0) GRANULARITY 1,
INDEX map_fixed_values_ngrambf mapKeys(map_fixed) TYPE ngrambf_v1(4,256,2,0) GRANULARITY 1
) Engine=MergeTree() ORDER BY row_id SETTINGS index_granularity = 1;
INSERT INTO bf_ngrambf_map_values_test VALUES (0, {'K0':'V0'}, {'K0':'V0'}), (1, {'K1':'V1'}, {'K1':'V1'});
SELECT 'Map full text bloom filter ngrambf mapValues';
SELECT 'Equals with existing key';
SELECT * FROM bf_ngrambf_map_values_test WHERE map['K0'] = 'V0' SETTINGS force_data_skipping_indices='map_values_ngrambf';
SELECT 'Equals with non existing key';
SELECT * FROM bf_ngrambf_map_values_test WHERE map['K2'] = 'V2' SETTINGS force_data_skipping_indices='map_values_ngrambf';
SELECT 'Equals with non existing key and default value';
SELECT * FROM bf_ngrambf_map_values_test WHERE map['K3'] = '';
SELECT 'Not equals with existing key';
SELECT * FROM bf_ngrambf_map_values_test WHERE map['K0'] != 'V0' SETTINGS force_data_skipping_indices='map_values_ngrambf';
SELECT 'Not equals with non existing key';
SELECT * FROM bf_ngrambf_map_values_test WHERE map['K2'] != 'V2' SETTINGS force_data_skipping_indices='map_values_ngrambf';
SELECT 'Not equals with non existing key and default value';
SELECT * FROM bf_ngrambf_map_values_test WHERE map['K3'] != '';
SELECT 'Map fixed full text bloom filter ngrambf mapKeys';
SELECT 'Equals with existing key';
SELECT * FROM bf_ngrambf_map_values_test WHERE map_fixed['K0'] = 'V0' SETTINGS force_data_skipping_indices='map_fixed_values_ngrambf';
SELECT 'Equals with non existing key';
SELECT * FROM bf_ngrambf_map_values_test WHERE map_fixed['K2'] = 'V2' SETTINGS force_data_skipping_indices='map_fixed_values_ngrambf';
SELECT 'Equals with non existing key and default value';
SELECT * FROM bf_ngrambf_map_values_test WHERE map_fixed['K3'] = '';
SELECT 'Not equals with existing key';
SELECT * FROM bf_ngrambf_map_values_test WHERE map_fixed['K0'] != 'V0' SETTINGS force_data_skipping_indices='map_fixed_values_ngrambf';
SELECT 'Not equals with non existing key';
SELECT * FROM bf_ngrambf_map_values_test WHERE map_fixed['K2'] != 'V2' SETTINGS force_data_skipping_indices='map_fixed_values_ngrambf';
SELECT 'Not equals with non existing key and default value';
SELECT * FROM bf_ngrambf_map_values_test WHERE map_fixed['K3'] != '';
DROP TABLE bf_ngrambf_map_values_test;