This is an automated email from the ASF dual-hosted git repository.
yiguolei 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 91af86bc787 [fix](function) fix error when use negative number in
explode_numbers #27020
91af86bc787 is described below
commit 91af86bc787701f58f5dce70fcb4c2675919c476
Author: Mryange <[email protected]>
AuthorDate: Fri Nov 17 12:02:14 2023 +0800
[fix](function) fix error when use negative number in explode_numbers #27020
---
.../vec/exprs/table_function/vexplode_numbers.cpp | 2 ++
.../data/correctness/test_explode_numbers.out | 13 +++++++++
.../suites/correctness/test_explode_numbers.groovy | 32 ++++++++++++++++++++++
3 files changed, 47 insertions(+)
diff --git a/be/src/vec/exprs/table_function/vexplode_numbers.cpp
b/be/src/vec/exprs/table_function/vexplode_numbers.cpp
index 8149d4d9583..c2f8d36c225 100644
--- a/be/src/vec/exprs/table_function/vexplode_numbers.cpp
+++ b/be/src/vec/exprs/table_function/vexplode_numbers.cpp
@@ -63,6 +63,8 @@ Status VExplodeNumbersTableFunction::process_init(Block*
block, RuntimeState* st
_cur_size = column_nested->get_int(0);
}
((ColumnInt32*)_elements_column.get())->clear();
+ //_cur_size may be a negative number
+ _cur_size = std::max(0L, _cur_size);
if (_cur_size &&
_cur_size <= state->batch_size()) { // avoid elements_column too
big or empty
_is_const = true; // use const optimize
diff --git a/regression-test/data/correctness/test_explode_numbers.out
b/regression-test/data/correctness/test_explode_numbers.out
new file mode 100644
index 00000000000..b302a51a920
--- /dev/null
+++ b/regression-test/data/correctness/test_explode_numbers.out
@@ -0,0 +1,13 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !select1 --
+0
+1
+2
+3
+4
+
+-- !select2 --
+
+-- !select3 --
+
+-- !select4 --
diff --git a/regression-test/suites/correctness/test_explode_numbers.groovy
b/regression-test/suites/correctness/test_explode_numbers.groovy
new file mode 100644
index 00000000000..cd85ba835e8
--- /dev/null
+++ b/regression-test/suites/correctness/test_explode_numbers.groovy
@@ -0,0 +1,32 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_explode_numbers") {
+ sql 'set enable_nereids_planner=true'
+ qt_select1 """
+ select e1 from (select 1 k1) as t lateral view explode_numbers(5) tmp1
as e1 order by e1;
+ """
+ qt_select2 """
+ select e1 from (select 1 k1) as t lateral view explode_numbers(0) tmp1
as e1;
+ """
+ qt_select3 """
+ select e1 from (select 1 k1) as t lateral view explode_numbers(null)
tmp1 as e1;
+ """
+ qt_select4 """
+ select e1 from (select 1 k1) as t lateral view explode_numbers(-5) tmp1
as e1;
+ """
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]