This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch dev-1.1.2
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/dev-1.1.2 by this push:
     new d668504ece [bugfix] fix coredump caused by nullable const column 
compare to non-nullable const column (#11227)
d668504ece is described below

commit d668504ecef179782267a5c1fb6a8df35a71cb68
Author: TengJianPing <[email protected]>
AuthorDate: Wed Jul 27 12:00:26 2022 +0800

    [bugfix] fix coredump caused by nullable const column compare to 
non-nullable const column (#11227)
---
 be/src/vec/columns/column_const.h                     | 19 +++++++++++++++++--
 .../data/correctness/sql/test_ifnull_function1.out    |  4 ++++
 .../data/correctness/sql/test_ifnull_function2.out    |  4 ++++
 .../suites/correctness/sql/test_ifnull_function1.sql  | 18 ++++++++++++++++++
 .../suites/correctness/sql/test_ifnull_function2.sql  | 18 ++++++++++++++++++
 5 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/be/src/vec/columns/column_const.h 
b/be/src/vec/columns/column_const.h
index 16be16692d..1202339a3d 100644
--- a/be/src/vec/columns/column_const.h
+++ b/be/src/vec/columns/column_const.h
@@ -21,6 +21,7 @@
 #pragma once
 
 #include "vec/columns/column.h"
+#include "vec/columns/column_nullable.h"
 #include "vec/common/assert_cast.h"
 #include "vec/common/exception.h"
 #include "vec/common/typeid_cast.h"
@@ -128,8 +129,22 @@ public:
     size_t allocated_bytes() const override { return data->allocated_bytes() + 
sizeof(s); }
 
     int compare_at(size_t, size_t, const IColumn& rhs, int nan_direction_hint) 
const override {
-        return data->compare_at(0, 0, *assert_cast<const 
ColumnConst&>(rhs).data,
-                                nan_direction_hint);
+        auto rhs_const_column = assert_cast<const ColumnConst&>(rhs);
+
+        auto* this_nullable = check_and_get_column<ColumnNullable>(data.get());
+        auto* rhs_nullable = 
check_and_get_column<ColumnNullable>(rhs_const_column.data.get());
+        if (this_nullable && rhs_nullable) {
+            return data->compare_at(0, 0, *rhs_const_column.data, 
nan_direction_hint);
+        } else if (this_nullable) {
+            auto rhs_nullable_column = make_nullable(rhs_const_column.data, 
false);
+            return this_nullable->compare_at(0, 0, *rhs_nullable_column, 
nan_direction_hint);
+        } else if (rhs_nullable) {
+            auto this_nullable_column = make_nullable(data, false);
+            return this_nullable_column->compare_at(0, 0, 
*rhs_const_column.data,
+                                                    nan_direction_hint);
+        } else {
+            return data->compare_at(0, 0, *rhs_const_column.data, 
nan_direction_hint);
+        }
     }
 
     MutableColumns scatter(ColumnIndex num_columns, const Selector& selector) 
const override;
diff --git a/regression-test/data/correctness/sql/test_ifnull_function1.out 
b/regression-test/data/correctness/sql/test_ifnull_function1.out
new file mode 100644
index 0000000000..ba9b10bdc7
--- /dev/null
+++ b/regression-test/data/correctness/sql/test_ifnull_function1.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !test_ifnull_function1 --
+false
+
diff --git a/regression-test/data/correctness/sql/test_ifnull_function2.out 
b/regression-test/data/correctness/sql/test_ifnull_function2.out
new file mode 100644
index 0000000000..3d52df1406
--- /dev/null
+++ b/regression-test/data/correctness/sql/test_ifnull_function2.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !test_ifnull_function2 --
+true
+
diff --git a/regression-test/suites/correctness/sql/test_ifnull_function1.sql 
b/regression-test/suites/correctness/sql/test_ifnull_function1.sql
new file mode 100644
index 0000000000..f082be6c6a
--- /dev/null
+++ b/regression-test/suites/correctness/sql/test_ifnull_function1.sql
@@ -0,0 +1,18 @@
+-- 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.
+
+select IFNULL(get_json_string('{"k1":"v1", "k2":"v2"}', "$.k1"), 'SUCCESS')= 
'FAIL';
diff --git a/regression-test/suites/correctness/sql/test_ifnull_function2.sql 
b/regression-test/suites/correctness/sql/test_ifnull_function2.sql
new file mode 100644
index 0000000000..e330be6e8e
--- /dev/null
+++ b/regression-test/suites/correctness/sql/test_ifnull_function2.sql
@@ -0,0 +1,18 @@
+-- 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.
+
+select IFNULL(get_json_string('{"k1":"FAIL", "k2":"v2"}', "$.k1"), 'SUCCESS')= 
'FAIL';


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to