Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions be/src/vec/columns/column_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,19 +624,19 @@ size_t ColumnArray::filter_generic(const Filter& filter) {
}

data->filter(nested_filter);

auto& res_offsets = get_offsets();
res_offsets.set_end_ptr(res_offsets.data());

// Make a new offset to avoid inplace operation
auto res_offset = ColumnOffsets::create();
auto& res_offset_data = res_offset->get_data();
res_offset_data.reserve(size);
size_t current_offset = 0;
for (size_t i = 0; i < size; ++i) {
if (filter[i]) {
current_offset += size_at(i);
res_offsets.push_back(current_offset);
res_offset_data.push_back(current_offset);
}
}

return res_offsets.size();
get_offsets().swap(res_offset_data);
return get_offsets().size();
}

ColumnPtr ColumnArray::filter_nullable(const Filter& filt, ssize_t result_size_hint) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,13 @@
2 [NULL, 2]
3 [NULL, 3]

-- !select --
1 [1, 0, 1, 1] [1, -2, -3, 4] [2020-01-01, 2020-01-02] [2020-01-01 12:00:00, 2020-01-02 13:01:01] [1, 2, 3, 4] [1, 1.1, 1.2, 1.3] [1, 2, 3, 4] [32768, 32769, -32769, -32770] ['192.168.0.1', '127.0.0.1'] ['a', 'b', 'c'] [-1, 0, 1, 2] \N [1, 2, 3, 4] [128, 129, -129, -130] ['d', 'e', 'f'] [0, 1, 2, 3] string2 text2 4.0 2022-08-08T00:00 2022-08-09T12:10:10 1660018210000 2022-08-09 12:10:10
1 [1, 0, 1, 1] [1, -2, -3, 4] [2020-01-01, 2020-01-02] [2020-01-01 12:00:00, 2020-01-02 13:01:01] [1, 2, 3, 4] [1, 1.1, 1.2, 1.3] [1, 2, 3, 4] [32768, 32769, -32769, -32770] ['192.168.0.1', '127.0.0.1'] ['a', 'b', 'c'] [-1, 0, 1, 2] \N [1, 2, 3, 4] [128, 129, -129, -130] ['d', 'e', 'f'] [0, 1, 2, 3] string2 text2 4.0 2022-08-08T00:00 2022-08-09T12:10:10 1660018210000 2022-08-09 12:10:10
1 [1, 0, 1, 1] [1, -2, -3, 4] [2020-01-01, 2020-01-02] [2020-01-01 12:00:00, 2020-01-02 13:01:01] [1, 2, 3, 4] [1, 1.1, 1.2, 1.3] [1, 2, 3, 4] [32768, 32769, -32769, -32770] ['192.168.0.1', '127.0.0.1'] ['a', 'b', 'c'] [-1, 0, 1, 2] \N [1, 2, 3, 4] [128, 129, -129, -130] ['d', 'e', 'f'] [0, 1, 2, 3] string2 text2 4.0 2022-08-08T00:00 2022-08-09T12:10:10 1660018210000 2022-08-09 12:10:10

-- !select --
[0, 1, 2, 3]
[0, 1, 2, 3]
[0, 1, 2, 3]

Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,65 @@ suite("test_array_functions_with_where") {
// check exception message contains
exception "Array type dose not support operand"
}

tableName = "tbl_test_array_functions_with_where2"
sql """DROP TABLE IF EXISTS ${tableName}"""
sql """
CREATE TABLE ${tableName} (
`id` int(11) NULL,
`c_bool` array<boolean> NULL COMMENT ' type is boolean',
`c_byte` array<tinyint(4)> NULL COMMENT ' type is byte',
`c_date` array<datev2> NULL COMMENT ' type is date, format is yyyy-MM-dd',
`c_datetime` array<datetimev2(0)> NULL COMMENT ' type is date, format is yyyy-MM-dd HH:mm:ss',
`c_double` array<double> NULL COMMENT ' type is double',
`c_float` array<float> NULL COMMENT ' type is float',
`c_half_float` array<float> NULL COMMENT ' type is half_float',
`c_integer` array<int(11)> NULL COMMENT ' type is integer',
`c_ip` array<text> NULL COMMENT ' type is ip',
`c_keyword` array<text> NULL COMMENT ' type is keyword',
`c_long` array<bigint(20)> NULL COMMENT ' type is long',
`c_person` array<text> NULL COMMENT ' no type',
`c_scaled_float` array<double> NULL COMMENT ' type is scaled_float',
`c_short` array<smallint(6)> NULL COMMENT ' type is short',
`c_text` array<text> NULL COMMENT ' type is text',
`c_unsigned_long` array<largeint(40)> NULL COMMENT ' type is unsigned_long',
`test1` text NULL COMMENT ' type is keyword',
`test2` text NULL COMMENT ' type is text',
`test3` double NULL COMMENT ' type is double',
`test4` datetimev2(0) NULL COMMENT ' type is date, no format',
`test5` datetimev2(0) NULL COMMENT ' type is date, format is yyyy-MM-dd HH:mm:ss',
`test6` bigint(20) NULL COMMENT ' type is date, format is epoch_millis',
`test7` text NULL COMMENT ' type is date, format is yyyy-MM-dd HH:mm:ss not support, use String type'
) ENGINE=OLAP
DUPLICATE KEY(`id`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"in_memory" = "false",
"storage_format" = "V2",
"light_schema_change" = "true",
"disable_auto_compaction" = "false"
);
"""
sql """
INSERT INTO ${tableName} (id, c_bool, c_byte, c_date, c_datetime, c_double, c_float, c_half_float, c_integer, c_ip, c_keyword, c_long, c_person, c_scaled_float, c_short, c_text, c_unsigned_long, test1, test2, test3, test4, test5, test6, test7)
VALUES
(1, '[1, 0, 1, 1]', '[1, -2, -3, 4]', '[2020-01-01, 2020-01-02]', '[2020-01-01 12:00:00, 2020-01-02 13:01:01]', '[1, 2, 3, 4]', '[1, 1.1, 1.2, 1.3]', '[1, 2, 3, 4]', '[32768, 32769, -32769, -32770]', "['192.168.0.1', '127.0.0.1']", "['a', 'b', 'c']", '[-1, 0, 1, 2]', '["{\\"name\\":\\"Andy\\",\\"age\\":18}", "{\\"name\\":\\"Tim\\",\\"age\\":28}"]', '[1, 2, 3, 4]', '[128, 129, -129, -130]', "['d', 'e', 'f']", '[0, 1, 2, 3]', 'string3', 'text3_4*5', 5, '2022-08-08 00:00:00', '2022-08-10 12:10:10', 1660018210000, '2022-08-10 12:10:10'),
(1, '[1, 0, 1, 1]', '[1, -2, -3, 4]', '[2020-01-01, 2020-01-02]', '[2020-01-01 12:00:00, 2020-01-02 13:01:01]', '[1, 2, 3, 4]', '[1, 1.1, 1.2, 1.3]', '[1, 2, 3, 4]', '[32768, 32769, -32769, -32770]', "['192.168.0.1', '127.0.0.1']", "['a', 'b', 'c']", '[-1, 0, 1, 2]', '["{\\"name\\":\\"Andy\\",\\"age\\":18}", "{\\"name\\":\\"Tim\\",\\"age\\":28}"]', '[1, 2, 3, 4]', '[128, 129, -129, -130]', "['d', 'e', 'f']", '[0, 1, 2, 3]', 'string2', 'text2', 4, '2022-08-08 00:00:00', '2022-08-09 12:10:10', 1660018210000, '2022-08-09 12:10:10')
"""
sql """
INSERT INTO ${tableName} (id, c_bool, c_byte, c_date, c_datetime, c_double, c_float, c_half_float, c_integer, c_ip, c_keyword, c_long, c_person, c_scaled_float, c_short, c_text, c_unsigned_long, test1, test2, test3, test4, test5, test6, test7)
VALUES
(1, '[1, 0, 1, 1]', '[1, -2, -3, 4]', '[2020-01-01, 2020-01-02]', '[2020-01-01 12:00:00, 2020-01-02 13:01:01]', '[1, 2, 3, 4]', '[1, 1.1, 1.2, 1.3]', '[1, 2, 3, 4]', '[32768, 32769, -32769, -32770]', "['192.168.0.1', '127.0.0.1']", "['a', 'b', 'c']", '[-1, 0, 1, 2]', '["{\\"name\\":\\"Andy\\",\\"age\\":18}", "{\\"name\\":\\"Tim\\",\\"age\\":28}"]', '[1, 2, 3, 4]', '[128, 129, -129, -130]', "['d', 'e', 'f']", '[0, 1, 2, 3]', 'string3', 'text3_4*5', 5, '2022-08-08 00:00:00', '2022-08-10 12:10:10', 1660018210000, '2022-08-10 12:10:10'),
(1, '[1, 0, 1, 1]', '[1, -2, -3, 4]', '[2020-01-01, 2020-01-02]', '[2020-01-01 12:00:00, 2020-01-02 13:01:01]', '[1, 2, 3, 4]', '[1, 1.1, 1.2, 1.3]', '[1, 2, 3, 4]', '[32768, 32769, -32769, -32770]', "['192.168.0.1', '127.0.0.1']", "['a', 'b', 'c']", '[-1, 0, 1, 2]', '["{\\"name\\":\\"Andy\\",\\"age\\":18}", "{\\"name\\":\\"Tim\\",\\"age\\":28}"]', '[1, 2, 3, 4]', '[128, 129, -129, -130]', "['d', 'e', 'f']", '[0, 1, 2, 3]', 'string2', 'text2', 4, '2022-08-08 00:00:00', '2022-08-09 12:10:10', 1660018210000, '2022-08-09 12:10:10')
"""
sql """
INSERT INTO ${tableName} (id, c_bool, c_byte, c_date, c_datetime, c_double, c_float, c_half_float, c_integer, c_ip, c_keyword, c_long, c_person, c_scaled_float, c_short, c_text, c_unsigned_long, test1, test2, test3, test4, test5, test6, test7)
VALUES
(1, '[1, 0, 1, 1]', '[1, -2, -3, 4]', '[2020-01-01, 2020-01-02]', '[2020-01-01 12:00:00, 2020-01-02 13:01:01]', '[1, 2, 3, 4]', '[1, 1.1, 1.2, 1.3]', '[1, 2, 3, 4]', '[32768, 32769, -32769, -32770]', "['192.168.0.1', '127.0.0.1']", "['a', 'b', 'c']", '[-1, 0, 1, 2]', '["{\\"name\\":\\"Andy\\",\\"age\\":18}", "{\\"name\\":\\"Tim\\",\\"age\\":28}"]', '[1, 2, 3, 4]', '[128, 129, -129, -130]', "['d', 'e', 'f']", '[0, 1, 2, 3]', 'string3', 'text3_4*5', 5, '2022-08-08 00:00:00', '2022-08-10 12:10:10', 1660018210000, '2022-08-10 12:10:10'),
(1, '[1, 0, 1, 1]', '[1, -2, -3, 4]', '[2020-01-01, 2020-01-02]', '[2020-01-01 12:00:00, 2020-01-02 13:01:01]', '[1, 2, 3, 4]', '[1, 1.1, 1.2, 1.3]', '[1, 2, 3, 4]', '[32768, 32769, -32769, -32770]', "['192.168.0.1', '127.0.0.1']", "['a', 'b', 'c']", '[-1, 0, 1, 2]', '["{\\"name\\":\\"Andy\\",\\"age\\":18}", "{\\"name\\":\\"Tim\\",\\"age\\":28}"]', '[1, 2, 3, 4]', '[128, 129, -129, -130]', "['d', 'e', 'f']", '[0, 1, 2, 3]', 'string2', 'text2', 4, '2022-08-08 00:00:00', '2022-08-09 12:10:10', 1660018210000, '2022-08-09 12:10:10')
"""
qt_select "select * from ${tableName} where substring(test2, 2) = 'ext2';"
qt_select "select c_unsigned_long from ${tableName} where not substring(test2, 2) = 'ext2';"
}