This is an automated email from the ASF dual-hosted git repository.
jianliangqi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 368e6a4f9c [Bug](array filter) Fix bug due to
`ColumnArray::filter_generic` invalid inplace `size_at` after `set_end_ptr`
(#17554)
368e6a4f9c is described below
commit 368e6a4f9c5e3e19bdf094773a71b55417e127fb
Author: lihangyu <[email protected]>
AuthorDate: Thu Mar 9 10:59:29 2023 +0800
[Bug](array filter) Fix bug due to `ColumnArray::filter_generic` invalid
inplace `size_at` after `set_end_ptr` (#17554)
We should make a new PodArray to add items instead of do it inplace
---
be/src/vec/columns/column_array.cpp | 14 ++---
.../test_array_functions_with_where.out | 10 ++++
.../test_array_functions_with_where.groovy | 61 ++++++++++++++++++++++
3 files changed, 78 insertions(+), 7 deletions(-)
diff --git a/be/src/vec/columns/column_array.cpp
b/be/src/vec/columns/column_array.cpp
index 0cd72f26c7..d6b595bb58 100644
--- a/be/src/vec/columns/column_array.cpp
+++ b/be/src/vec/columns/column_array.cpp
@@ -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 {
diff --git
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_with_where.out
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_with_where.out
index 042c5337f5..7950b59cc0 100644
---
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_with_where.out
+++
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_with_where.out
@@ -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]
+
diff --git
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_with_where.groovy
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_with_where.groovy
index 4dc7e6af9d..6ee5ae1b54 100644
---
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_with_where.groovy
+++
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_with_where.groovy
@@ -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- [...]
+ (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-0 [...]
+ """
+ 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- [...]
+ (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-0 [...]
+ """
+ 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- [...]
+ (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-0 [...]
+ """
+ qt_select "select * from ${tableName} where substring(test2, 2) =
'ext2';"
+ qt_select "select c_unsigned_long from ${tableName} where not
substring(test2, 2) = 'ext2';"
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]