diff --git a/be/src/vec/functions/functions_geo.cpp b/be/src/vec/functions/functions_geo.cpp index 7b833f91a8ddfd..6d75258d146ff7 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( - block.get_by_position(arguments[0]).column->convert_to_full_column_if_const()); - const auto* x_lat = check_and_get_column( - block.get_by_position(arguments[1]).column->convert_to_full_column_if_const()); - const auto* y_lng = check_and_get_column( - block.get_by_position(arguments[2]).column->convert_to_full_column_if_const()); - const auto* y_lat = check_and_get_column( - 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(x_lng_origin); + const auto* x_lat = check_and_get_column(x_lat_origin); + const auto* y_lng = check_and_get_column(y_lng_origin); + const auto* y_lat = check_and_get_column(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( - block.get_by_position(arguments[0]).column->convert_to_full_column_if_const()); - const auto* x_lat = check_and_get_column( - block.get_by_position(arguments[1]).column->convert_to_full_column_if_const()); - const auto* y_lng = check_and_get_column( - block.get_by_position(arguments[2]).column->convert_to_full_column_if_const()); - const auto* y_lat = check_and_get_column( - 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(x_lng_origin); + const auto* x_lat = check_and_get_column(x_lat_origin); + const auto* y_lng = check_and_get_column(y_lng_origin); + const auto* y_lat = check_and_get_column(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 db1b1ffcae52d3..df93348581bd64 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 d50ac65719af03..8c384f51ff7048 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; " }