This is an automated email from the ASF dual-hosted git repository.
panxiaolei 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 06034959a64 [Fix](function) fix coredump of function StDistanceSphere
and StAngleSphere (#45508)
06034959a64 is described below
commit 06034959a64ddb732024ac45f2bedca54d1fee15
Author: zclllyybb <[email protected]>
AuthorDate: Tue Dec 17 15:51:21 2024 +0800
[Fix](function) fix coredump of function StDistanceSphere and StAngleSphere
(#45508)
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: https://github.com/apache/doris/pull/40107
Problem Summary:
In https://github.com/apache/doris/pull/40107 we introduced a wrong
behaviour which would lead to BE crash because of dangling reference.
now fix it.
### Release note
fix BE crash of function StDistanceSphere and StAngleSphere
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [x] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [x] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [x] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
---
be/src/vec/functions/functions_geo.cpp | 43 ++++++++++++++--------
.../spatial_functions/test_gis_function.out | 6 +++
.../spatial_functions/test_gis_function.groovy | 18 +++++++++
3 files changed, 51 insertions(+), 16 deletions(-)
diff --git a/be/src/vec/functions/functions_geo.cpp
b/be/src/vec/functions/functions_geo.cpp
index 7b833f91a8d..6d75258d146 100644
--- a/be/src/vec/functions/functions_geo.cpp
+++ b/be/src/vec/functions/functions_geo.cpp
@@ -249,15 +249,21 @@ struct StDistanceSphere {
DCHECK_EQ(arguments.size(), 4);
auto return_type = block.get_data_type(result);
- const auto* x_lng = check_and_get_column<ColumnFloat64>(
-
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const());
- const auto* x_lat = check_and_get_column<ColumnFloat64>(
-
block.get_by_position(arguments[1]).column->convert_to_full_column_if_const());
- const auto* y_lng = check_and_get_column<ColumnFloat64>(
-
block.get_by_position(arguments[2]).column->convert_to_full_column_if_const());
- const auto* y_lat = check_and_get_column<ColumnFloat64>(
-
block.get_by_position(arguments[3]).column->convert_to_full_column_if_const());
+ ColumnPtr x_lng_origin =
+
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+ ColumnPtr x_lat_origin =
+
block.get_by_position(arguments[1]).column->convert_to_full_column_if_const();
+ ColumnPtr y_lng_origin =
+
block.get_by_position(arguments[2]).column->convert_to_full_column_if_const();
+ ColumnPtr y_lat_origin =
+
block.get_by_position(arguments[3]).column->convert_to_full_column_if_const();
+
+ const auto* x_lng = check_and_get_column<ColumnFloat64>(x_lng_origin);
+ const auto* x_lat = check_and_get_column<ColumnFloat64>(x_lat_origin);
+ const auto* y_lng = check_and_get_column<ColumnFloat64>(y_lng_origin);
+ const auto* y_lat = check_and_get_column<ColumnFloat64>(y_lat_origin);
CHECK(x_lng && x_lat && y_lng && y_lat);
+
const auto size = x_lng->size();
auto res = ColumnFloat64::create();
res->reserve(size);
@@ -290,14 +296,19 @@ struct StAngleSphere {
DCHECK_EQ(arguments.size(), 4);
auto return_type = block.get_data_type(result);
- const auto* x_lng = check_and_get_column<ColumnFloat64>(
-
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const());
- const auto* x_lat = check_and_get_column<ColumnFloat64>(
-
block.get_by_position(arguments[1]).column->convert_to_full_column_if_const());
- const auto* y_lng = check_and_get_column<ColumnFloat64>(
-
block.get_by_position(arguments[2]).column->convert_to_full_column_if_const());
- const auto* y_lat = check_and_get_column<ColumnFloat64>(
-
block.get_by_position(arguments[3]).column->convert_to_full_column_if_const());
+ ColumnPtr x_lng_origin =
+
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+ ColumnPtr x_lat_origin =
+
block.get_by_position(arguments[1]).column->convert_to_full_column_if_const();
+ ColumnPtr y_lng_origin =
+
block.get_by_position(arguments[2]).column->convert_to_full_column_if_const();
+ ColumnPtr y_lat_origin =
+
block.get_by_position(arguments[3]).column->convert_to_full_column_if_const();
+
+ const auto* x_lng = check_and_get_column<ColumnFloat64>(x_lng_origin);
+ const auto* x_lat = check_and_get_column<ColumnFloat64>(x_lat_origin);
+ const auto* y_lng = check_and_get_column<ColumnFloat64>(y_lng_origin);
+ const auto* y_lat = check_and_get_column<ColumnFloat64>(y_lat_origin);
CHECK(x_lng && x_lat && y_lng && y_lat);
const auto size = x_lng->size();
diff --git
a/regression-test/data/nereids_p0/sql_functions/spatial_functions/test_gis_function.out
b/regression-test/data/nereids_p0/sql_functions/spatial_functions/test_gis_function.out
index db1b1ffcae5..df93348581b 100644
---
a/regression-test/data/nereids_p0/sql_functions/spatial_functions/test_gis_function.out
+++
b/regression-test/data/nereids_p0/sql_functions/spatial_functions/test_gis_function.out
@@ -113,3 +113,9 @@ LINESTRING (1 1, 2 2)
-- !sql --
POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057,
114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119))
+-- !sql_part_const_dis_sph --
+3335.853035325018
+
+-- !sql_part_const_ang_sph --
+0.030000000000004495
+
diff --git
a/regression-test/suites/nereids_p0/sql_functions/spatial_functions/test_gis_function.groovy
b/regression-test/suites/nereids_p0/sql_functions/spatial_functions/test_gis_function.groovy
index d50ac65719a..8c384f51ff7 100644
---
a/regression-test/suites/nereids_p0/sql_functions/spatial_functions/test_gis_function.groovy
+++
b/regression-test/suites/nereids_p0/sql_functions/spatial_functions/test_gis_function.groovy
@@ -71,4 +71,22 @@ suite("test_gis_function") {
qt_sql "SELECT
ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_GeometryFromText(\"LINESTRING (1 1, 2
2)\"))));"
qt_sql "SELECT ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon(\"POLYGON
((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229
22.539826,114.106203 22.542680,114.104486 22.547119))\"))));"
+ // test const
+ sql "drop table if exists test_gis_const"
+ sql """
+ CREATE TABLE test_gis_const (
+ `userid` varchar(32) NOT NULL COMMENT '个人账号id',
+ `c_1` double NOT NULL COMMENT '发送时间',
+ `c_2` double NOT NULL COMMENT '信源类型'
+ ) ENGINE=OLAP
+ UNIQUE KEY(`userid`)
+ COMMENT 'OLAP'
+ DISTRIBUTED BY HASH(`userid`) BUCKETS 6
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1"
+ );
+ """
+ sql "insert into test_gis_const values ('xxxx',78.73,31.5);"
+ qt_sql_part_const_dis_sph "select st_distance_sphere(78.73,31.53,c_1,c_2)
from test_gis_const; "
+ qt_sql_part_const_ang_sph "select st_angle_sphere(78.73,31.53,c_1,c_2)
from test_gis_const; "
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]