From bcf95cd920014573f69ea0bc10dc5128f5137f14 Mon Sep 17 00:00:00 2001 From: Liqf <109049295+LemonLiTree@users.noreply.github.com> Date: Mon, 27 Mar 2023 10:14:46 +0800 Subject: [PATCH] [feature](function)Add ST_Angle_Sphere function (#17919) --- be/src/geo/geo_types.cpp | 13 +++ be/src/geo/geo_types.h | 2 + be/src/vec/functions/functions_geo.cpp | 80 ++++++++++++------- be/test/vec/function/function_geo_test.cpp | 21 +++++ .../spatial-functions/st_angle_sphere.md | 59 ++++++++++++++ docs/sidebars.json | 1 + .../spatial-functions/st_angle_sphere.md | 59 ++++++++++++++ .../doris/catalog/BuiltinScalarFunctions.java | 2 + .../functions/scalar/StAngleSphere.java | 66 +++++++++++++++ .../visitor/ScalarFunctionVisitor.java | 5 ++ gensrc/script/doris_builtins_functions.py | 1 + .../nereids_function_p0/scalar_function/S.out | 29 +++++++ .../spatial_functions/test_gis_function.out | 6 ++ .../spatial_functions/test_gis_function.out | 6 ++ .../scalar_function/S.groovy | 2 + .../test_gis_function.groovy | 2 + .../test_gis_function.groovy | 3 + 17 files changed, 328 insertions(+), 29 deletions(-) create mode 100644 docs/en/docs/sql-manual/sql-functions/spatial-functions/st_angle_sphere.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/spatial-functions/st_angle_sphere.md create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAngleSphere.java diff --git a/be/src/geo/geo_types.cpp b/be/src/geo/geo_types.cpp index 80d0d6b65c..8dbbfe51a1 100644 --- a/be/src/geo/geo_types.cpp +++ b/be/src/geo/geo_types.cpp @@ -306,6 +306,19 @@ bool GeoPoint::ComputeDistance(double x_lng, double x_lat, double y_lng, double return true; } +bool GeoPoint::ComputeAngle(double x_lng, double x_lat, double y_lng, double y_lat, double* angle) { + S2LatLng x = S2LatLng::FromDegrees(x_lat, x_lng); + if (!x.is_valid()) { + return false; + } + S2LatLng y = S2LatLng::FromDegrees(y_lat, y_lng); + if (!y.is_valid()) { + return false; + } + *angle = (x.GetDistance(y)).degrees(); + return true; +} + GeoParseStatus GeoLine::from_coords(const GeoCoordinateList& list) { return to_s2polyline(list, &_polyline); } diff --git a/be/src/geo/geo_types.h b/be/src/geo/geo_types.h index bbaa3a0ccc..39116750ac 100644 --- a/be/src/geo/geo_types.h +++ b/be/src/geo/geo_types.h @@ -76,6 +76,8 @@ public: static bool ComputeDistance(double x_lng, double x_lat, double y_lng, double y_lat, double* distance); + static bool ComputeAngle(double x_lng, double x_lat, double y_lng, double y_lat, double* angle); + std::string to_string() const override; std::string as_wkt() const override; diff --git a/be/src/vec/functions/functions_geo.cpp b/be/src/vec/functions/functions_geo.cpp index bae8e162a4..68f67bc425 100644 --- a/be/src/vec/functions/functions_geo.cpp +++ b/be/src/vec/functions/functions_geo.cpp @@ -30,7 +30,7 @@ struct StPoint { static const size_t NUM_ARGS = 2; static Status execute(Block& block, const ColumnNumbers& arguments, size_t result) { DCHECK_EQ(arguments.size(), 2); - auto return_type = remove_nullable(block.get_data_type(result)); + auto return_type = block.get_data_type(result); auto column_x = block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); @@ -39,8 +39,7 @@ struct StPoint { const auto size = column_x->size(); - MutableColumnPtr res = nullptr; - res = ColumnNullable::create(return_type->create_column(), ColumnUInt8::create()); + MutableColumnPtr res = return_type->create_column(); GeoPoint point; std::string buf; @@ -76,15 +75,13 @@ struct StAsText { static const size_t NUM_ARGS = 1; static Status execute(Block& block, const ColumnNumbers& arguments, size_t result) { DCHECK_EQ(arguments.size(), 1); - auto return_type = remove_nullable(block.get_data_type(result)); + auto return_type = block.get_data_type(result); auto& input = block.get_by_position(arguments[0]).column; auto size = input->size(); - MutableColumnPtr res = nullptr; - auto null_type = std::reinterpret_pointer_cast(return_type); - res = ColumnNullable::create(return_type->create_column(), ColumnUInt8::create()); + MutableColumnPtr res = return_type->create_column(); std::unique_ptr shape; for (int row = 0; row < size; ++row) { @@ -110,15 +107,13 @@ struct StX { static const size_t NUM_ARGS = 1; static Status execute(Block& block, const ColumnNumbers& arguments, size_t result) { DCHECK_EQ(arguments.size(), 1); - auto return_type = remove_nullable(block.get_data_type(result)); + auto return_type = block.get_data_type(result); auto& input = block.get_by_position(arguments[0]).column; auto size = input->size(); - MutableColumnPtr res = nullptr; - auto null_type = std::reinterpret_pointer_cast(return_type); - res = ColumnNullable::create(return_type->create_column(), ColumnUInt8::create()); + MutableColumnPtr res = return_type->create_column(); GeoPoint point; for (int row = 0; row < size; ++row) { @@ -144,15 +139,13 @@ struct StY { static const size_t NUM_ARGS = 1; static Status execute(Block& block, const ColumnNumbers& arguments, size_t result) { DCHECK_EQ(arguments.size(), 1); - auto return_type = remove_nullable(block.get_data_type(result)); + auto return_type = block.get_data_type(result); auto& input = block.get_by_position(arguments[0]).column; auto size = input->size(); - MutableColumnPtr res = nullptr; - auto null_type = std::reinterpret_pointer_cast(return_type); - res = ColumnNullable::create(return_type->create_column(), ColumnUInt8::create()); + MutableColumnPtr res = return_type->create_column(); GeoPoint point; for (int row = 0; row < size; ++row) { @@ -178,7 +171,7 @@ struct StDistanceSphere { static const size_t NUM_ARGS = 4; static Status execute(Block& block, const ColumnNumbers& arguments, size_t result) { DCHECK_EQ(arguments.size(), 4); - auto return_type = remove_nullable(block.get_data_type(result)); + auto return_type = block.get_data_type(result); auto x_lng = block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); auto x_lat = block.get_by_position(arguments[1]).column->convert_to_full_column_if_const(); @@ -187,9 +180,7 @@ struct StDistanceSphere { const auto size = x_lng->size(); - MutableColumnPtr res = nullptr; - auto null_type = std::reinterpret_pointer_cast(return_type); - res = ColumnNullable::create(return_type->create_column(), ColumnUInt8::create()); + MutableColumnPtr res = return_type->create_column(); for (int row = 0; row < size; ++row) { double distance = 0; @@ -208,6 +199,40 @@ struct StDistanceSphere { } }; +struct StAngleSphere { + static constexpr auto NEED_CONTEXT = false; + static constexpr auto NAME = "st_angle_sphere"; + static const size_t NUM_ARGS = 4; + static Status execute(Block& block, const ColumnNumbers& arguments, size_t result) { + DCHECK_EQ(arguments.size(), 4); + auto return_type = block.get_data_type(result); + + auto x_lng = block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); + auto x_lat = block.get_by_position(arguments[1]).column->convert_to_full_column_if_const(); + auto y_lng = block.get_by_position(arguments[2]).column->convert_to_full_column_if_const(); + auto y_lat = block.get_by_position(arguments[3]).column->convert_to_full_column_if_const(); + + const auto size = x_lng->size(); + + MutableColumnPtr res = return_type->create_column(); + + for (int row = 0; row < size; ++row) { + double angle = 0; + if (!GeoPoint::ComputeAngle(x_lng->operator[](row).get(), + x_lat->operator[](row).get(), + y_lng->operator[](row).get(), + y_lat->operator[](row).get(), &angle)) { + res->insert_data(nullptr, 0); + continue; + } + res->insert_data(const_cast((char*)&angle), 0); + } + + block.replace_by_position(result, std::move(res)); + return Status::OK(); + } +}; + struct StCircle { static constexpr auto NEED_CONTEXT = true; static constexpr auto NAME = "st_circle"; @@ -215,7 +240,7 @@ struct StCircle { static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments, size_t result) { DCHECK_EQ(arguments.size(), 3); - auto return_type = remove_nullable(block.get_data_type(result)); + auto return_type = block.get_data_type(result); auto center_lng = block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); auto center_lat = @@ -224,9 +249,7 @@ struct StCircle { const auto size = center_lng->size(); - MutableColumnPtr res = nullptr; - auto null_type = std::reinterpret_pointer_cast(return_type); - res = ColumnNullable::create(return_type->create_column(), ColumnUInt8::create()); + MutableColumnPtr res = return_type->create_column(); GeoCircle circle; std::string buf; @@ -264,13 +287,12 @@ struct StContains { static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments, size_t result) { DCHECK_EQ(arguments.size(), 2); - auto return_type = remove_nullable(block.get_data_type(result)); + auto return_type = block.get_data_type(result); auto shape1 = block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); auto shape2 = block.get_by_position(arguments[1]).column->convert_to_full_column_if_const(); const auto size = shape1->size(); - auto null_type = std::reinterpret_pointer_cast(return_type); - auto res = ColumnNullable::create(return_type->create_column(), ColumnUInt8::create()); + MutableColumnPtr res = return_type->create_column(); int i; std::vector> shapes = {nullptr, nullptr}; @@ -348,12 +370,11 @@ struct StGeoFromText { static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments, size_t result) { DCHECK_EQ(arguments.size(), 1); - auto return_type = remove_nullable(block.get_data_type(result)); + auto return_type = block.get_data_type(result); auto& geo = block.get_by_position(arguments[0]).column; const auto size = geo->size(); - auto null_type = std::reinterpret_pointer_cast(return_type); - auto res = ColumnNullable::create(return_type->create_column(), ColumnUInt8::create()); + MutableColumnPtr res = return_type->create_column(); GeoParseStatus status; std::string buf; @@ -389,6 +410,7 @@ void register_function_geo(SimpleFunctionFactory& factory) { factory.register_function>(); factory.register_function>(); factory.register_function>(); + factory.register_function>(); factory.register_function>(); factory.register_function>(); factory.register_function>>(); diff --git a/be/test/vec/function/function_geo_test.cpp b/be/test/vec/function/function_geo_test.cpp index 544424f842..698f372502 100644 --- a/be/test/vec/function/function_geo_test.cpp +++ b/be/test/vec/function/function_geo_test.cpp @@ -136,6 +136,27 @@ TEST(VGeoFunctionsTest, function_geo_st_distance_sphere) { } } +TEST(VGeoFunctionsTest, function_geo_st_angle_sphere) { + std::string func_name = "st_angle_sphere"; + { + InputTypeSet input_types = {TypeIndex::Float64, TypeIndex::Float64, TypeIndex::Float64, + TypeIndex::Float64}; + + DataSet data_set = { + {{(double)116.35620117, (double)39.939093, (double)116.4274406433, + (double)39.9020987219}, + (double)0.0659823452409903}, + {{(double)116.35620117, (double)39.939093, (double)116.4274406433, Null()}, Null()}, + {{(double)116.35620117, (double)39.939093, Null(), (double)39.9020987219}, Null()}, + {{(double)116.35620117, Null(), (double)116.4274406433, (double)39.9020987219}, + Null()}, + {{Null(), (double)39.939093, (double)116.4274406433, (double)39.9020987219}, + Null()}}; + + check_function(func_name, input_types, data_set); + } +} + TEST(VGeoFunctionsTest, function_geo_st_contains) { std::string func_name = "st_contains"; { diff --git a/docs/en/docs/sql-manual/sql-functions/spatial-functions/st_angle_sphere.md b/docs/en/docs/sql-manual/sql-functions/spatial-functions/st_angle_sphere.md new file mode 100644 index 0000000000..7c82c6d3ce --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/spatial-functions/st_angle_sphere.md @@ -0,0 +1,59 @@ +--- +{ +"title": "ST_Angle_Sphere", +"language": "en" +} +--- + + + +## ST_Angle_Sphere +### description +#### Syntax + +`DOUBLE ST_Angle_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` + + +Calculates the central angle between two points on the Earth's surface. The incoming parameters are the longitude of point X, the latitude of point X, the longitude of point Y and the latitude of point Y. + +x_lng and y_lng are Longitude values, must be in the range [-180, 180]. +x_lat and y_lat are Latitude values, must be in the range [-90, 90]. + +### example + +``` +mysql> select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ++---------------------------------------------------------------------------+ +| st_angle_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | ++---------------------------------------------------------------------------+ +| 0.0659823452409903 | ++---------------------------------------------------------------------------+ +1 row in set (0.06 sec) + +mysql> select ST_Angle_Sphere(0, 0, 45, 0); ++----------------------------------------+ +| st_angle_sphere(0.0, 0.0, 45.0, 0.0) | ++----------------------------------------+ +| 45 | ++----------------------------------------+ +1 row in set (0.06 sec) +``` +### keywords +ST_ANGLE_SPHERE,ST,ANGLE,SPHERE diff --git a/docs/sidebars.json b/docs/sidebars.json index e3ca898d28..59ac5cb994 100644 --- a/docs/sidebars.json +++ b/docs/sidebars.json @@ -387,6 +387,7 @@ "sql-manual/sql-functions/spatial-functions/st_y", "sql-manual/sql-functions/spatial-functions/st_circle", "sql-manual/sql-functions/spatial-functions/st_distance_sphere", + "sql-manual/sql-functions/spatial-functions/st_angle_sphere", "sql-manual/sql-functions/spatial-functions/st_point", "sql-manual/sql-functions/spatial-functions/st_polygon", "sql-manual/sql-functions/spatial-functions/st_astext", diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/spatial-functions/st_angle_sphere.md b/docs/zh-CN/docs/sql-manual/sql-functions/spatial-functions/st_angle_sphere.md new file mode 100644 index 0000000000..a3ca53b0d6 --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/spatial-functions/st_angle_sphere.md @@ -0,0 +1,59 @@ +--- +{ +"title": "ST_Angle_Sphere", +"language": "zh-CN" +} +--- + + + +## ST_Angle_Sphere +### description +#### Syntax + +`DOUBLE ST_Angle_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` + + +计算地球表面两点之间的圆心角,单位为 度。传入的参数分别为X点的经度,X点的纬度,Y点的经度,Y点的纬度。 + +x_lng 和 y_lng 都是经度数据,合理的取值范围是 [-180, 180]。 +x_lat 和 y_lat 都是纬度数据,合理的取值范围是 [-90, 90]。 + +### example + +``` +mysql> select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ++---------------------------------------------------------------------------+ +| st_angle_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | ++---------------------------------------------------------------------------+ +| 0.0659823452409903 | ++---------------------------------------------------------------------------+ +1 row in set (0.06 sec) + +mysql> select ST_Angle_Sphere(0, 0, 45, 0); ++----------------------------------------+ +| st_angle_sphere(0.0, 0.0, 45.0, 0.0) | ++----------------------------------------+ +| 45 | ++----------------------------------------+ +1 row in set (0.06 sec) +``` +### keywords +ST_ANGLE_SPHERE,ST,ANGLE,SPHERE diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java index 57ef13813c..ff04bbca3a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java @@ -263,6 +263,7 @@ import org.apache.doris.nereids.trees.expressions.functions.scalar.SplitByChar; import org.apache.doris.nereids.trees.expressions.functions.scalar.SplitByString; import org.apache.doris.nereids.trees.expressions.functions.scalar.SplitPart; import org.apache.doris.nereids.trees.expressions.functions.scalar.Sqrt; +import org.apache.doris.nereids.trees.expressions.functions.scalar.StAngleSphere; import org.apache.doris.nereids.trees.expressions.functions.scalar.StAstext; import org.apache.doris.nereids.trees.expressions.functions.scalar.StAswkt; import org.apache.doris.nereids.trees.expressions.functions.scalar.StCircle; @@ -586,6 +587,7 @@ public class BuiltinScalarFunctions implements FunctionHelper { scalar(StCircle.class, "st_circle"), scalar(StContains.class, "st_contains"), scalar(StDistanceSphere.class, "st_distance_sphere"), + scalar(StAngleSphere.class, "st_angle_sphere"), scalar(StGeometryfromtext.class, "st_geometryfromtext"), scalar(StGeomfromtext.class, "st_geomfromtext"), scalar(StLinefromtext.class, "st_linefromtext"), diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAngleSphere.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAngleSphere.java new file mode 100644 index 0000000000..00dc3153b7 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAngleSphere.java @@ -0,0 +1,66 @@ +// 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. + +package org.apache.doris.nereids.trees.expressions.functions.scalar; + +import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable; +import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.DoubleType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'st_Angle_sphere'. This class is generated by GenerateFunction. + */ +public class StAngleSphere extends ScalarFunction + implements ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE) + .args(DoubleType.INSTANCE, DoubleType.INSTANCE, DoubleType.INSTANCE, DoubleType.INSTANCE) + ); + + /** + * constructor with 4 arguments. + */ + public StAngleSphere(Expression arg0, Expression arg1, Expression arg2, Expression arg3) { + super("st_angle_sphere", arg0, arg1, arg2, arg3); + } + + @Override + public Expression withChildren(List children) { + Preconditions.checkArgument(children.size() == 4); + return new StAngleSphere(children.get(0), children.get(1), children.get(2), children.get(3)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStAngleSphere(this, context); + } +} + diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java index d345678e2f..60fcc02ddd 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java @@ -265,6 +265,7 @@ import org.apache.doris.nereids.trees.expressions.functions.scalar.SplitByChar; import org.apache.doris.nereids.trees.expressions.functions.scalar.SplitByString; import org.apache.doris.nereids.trees.expressions.functions.scalar.SplitPart; import org.apache.doris.nereids.trees.expressions.functions.scalar.Sqrt; +import org.apache.doris.nereids.trees.expressions.functions.scalar.StAngleSphere; import org.apache.doris.nereids.trees.expressions.functions.scalar.StAstext; import org.apache.doris.nereids.trees.expressions.functions.scalar.StAswkt; import org.apache.doris.nereids.trees.expressions.functions.scalar.StCircle; @@ -1346,6 +1347,10 @@ public interface ScalarFunctionVisitor { return visitScalarFunction(stDistanceSphere, context); } + default R visitStAngleSphere(StAngleSphere stAngleSphere, C context) { + return visitScalarFunction(stAngleSphere, context); + } + default R visitStGeometryfromtext(StGeometryfromtext stGeometryfromtext, C context) { return visitScalarFunction(stGeometryfromtext, context); } diff --git a/gensrc/script/doris_builtins_functions.py b/gensrc/script/doris_builtins_functions.py index 503f4912ac..3078b96ca0 100644 --- a/gensrc/script/doris_builtins_functions.py +++ b/gensrc/script/doris_builtins_functions.py @@ -1668,6 +1668,7 @@ visible_functions = [ [['ST_Y'], 'DOUBLE', ['STRING'], 'ALWAYS_NULLABLE'], [['ST_Distance_Sphere'], 'DOUBLE', ['DOUBLE', 'DOUBLE', 'DOUBLE', 'DOUBLE'], 'ALWAYS_NULLABLE'], + [['ST_Angle_Sphere'], 'DOUBLE', ['DOUBLE', 'DOUBLE', 'DOUBLE', 'DOUBLE'], 'ALWAYS_NULLABLE'], [['ST_AsText', 'ST_AsWKT'], 'VARCHAR', ['VARCHAR'], 'ALWAYS_NULLABLE'], [['ST_AsText', 'ST_AsWKT'], 'VARCHAR', ['STRING'], 'ALWAYS_NULLABLE'], diff --git a/regression-test/data/nereids_function_p0/scalar_function/S.out b/regression-test/data/nereids_function_p0/scalar_function/S.out index 82a5e75982..5b9c0272fc 100644 --- a/regression-test/data/nereids_function_p0/scalar_function/S.out +++ b/regression-test/data/nereids_function_p0/scalar_function/S.out @@ -1652,6 +1652,35 @@ bd9a11352a4d84a4725035750ddea145189a72b6eb89c0e07fa9d3b21d70004a 0.0 0.0 +-- !sql_st_angle_sphere_Double_Double_Double_Double -- +\N +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 + +-- !sql_st_angle_sphere_Double_Double_Double_Double_notnull -- +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 + -- !sql_st_geometryfromtext_Varchar -- \N \N 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 985e1ed7da..c0adb69ecb 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 @@ -17,6 +17,12 @@ false -- !sql -- 7336.913554999592 +-- !sql -- +0.0659823452409903 + +-- !sql -- +45.0 + -- !sql -- LINESTRING (1 1, 2 2) diff --git a/regression-test/data/query_p0/sql_functions/spatial_functions/test_gis_function.out b/regression-test/data/query_p0/sql_functions/spatial_functions/test_gis_function.out index 985e1ed7da..c0adb69ecb 100644 --- a/regression-test/data/query_p0/sql_functions/spatial_functions/test_gis_function.out +++ b/regression-test/data/query_p0/sql_functions/spatial_functions/test_gis_function.out @@ -17,6 +17,12 @@ false -- !sql -- 7336.913554999592 +-- !sql -- +0.0659823452409903 + +-- !sql -- +45.0 + -- !sql -- LINESTRING (1 1, 2 2) diff --git a/regression-test/suites/nereids_function_p0/scalar_function/S.groovy b/regression-test/suites/nereids_function_p0/scalar_function/S.groovy index e97e48ce41..a4dbd66fb2 100644 --- a/regression-test/suites/nereids_function_p0/scalar_function/S.groovy +++ b/regression-test/suites/nereids_function_p0/scalar_function/S.groovy @@ -143,6 +143,8 @@ suite("nereids_scalar_fn_S") { qt_sql_st_contains_Varchar_Varchar_notnull "select st_contains(kvchrs1, kvchrs1) from fn_test_not_nullable order by kvchrs1, kvchrs1" qt_sql_st_distance_sphere_Double_Double_Double_Double "select st_distance_sphere(kdbl, kdbl, kdbl, kdbl) from fn_test order by kdbl, kdbl, kdbl, kdbl" qt_sql_st_distance_sphere_Double_Double_Double_Double_notnull "select st_distance_sphere(kdbl, kdbl, kdbl, kdbl) from fn_test_not_nullable order by kdbl, kdbl, kdbl, kdbl" + qt_sql_st_angle_sphere_Double_Double_Double_Double "select st_angle_sphere(kdbl, kdbl, kdbl, kdbl) from fn_test order by kdbl, kdbl, kdbl, kdbl" + qt_sql_st_angle_sphere_Double_Double_Double_Double_notnull "select st_angle_sphere(kdbl, kdbl, kdbl, kdbl) from fn_test_not_nullable order by kdbl, kdbl, kdbl, kdbl" qt_sql_st_geometryfromtext_Varchar "select st_geometryfromtext(kvchrs1) from fn_test order by kvchrs1" qt_sql_st_geometryfromtext_Varchar_notnull "select st_geometryfromtext(kvchrs1) from fn_test_not_nullable order by kvchrs1" qt_sql_st_geometryfromtext_String "select st_geometryfromtext(kstr) from fn_test order by kstr" 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 e67ba54048..dcb6b853d7 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 @@ -28,6 +28,8 @@ suite("test_gis_function") { qt_sql "SELECT ST_Contains(ST_Polygon(\"POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))\"), ST_Point(50, 50));" qt_sql "SELECT ST_DISTANCE_SPHERE(116.35620117, 39.939093, 116.4274406433, 39.9020987219);" + qt_sql "SELECT ST_ANGLE_SPHERE(116.35620117, 39.939093, 116.4274406433, 39.9020987219);" + qt_sql "SELECT ST_ANGLE_SPHERE(0, 0, 45, 0);" qt_sql "SELECT ST_AsText(ST_GeometryFromText(\"LINESTRING (1 1, 2 2)\"));" qt_sql "SELECT ST_AsText(ST_GeomFromText(\"LINESTRING (1 1, 2 2)\"));" diff --git a/regression-test/suites/query_p0/sql_functions/spatial_functions/test_gis_function.groovy b/regression-test/suites/query_p0/sql_functions/spatial_functions/test_gis_function.groovy index 4052893945..27397b066d 100644 --- a/regression-test/suites/query_p0/sql_functions/spatial_functions/test_gis_function.groovy +++ b/regression-test/suites/query_p0/sql_functions/spatial_functions/test_gis_function.groovy @@ -27,6 +27,9 @@ suite("test_gis_function") { qt_sql "SELECT ST_DISTANCE_SPHERE(116.35620117, 39.939093, 116.4274406433, 39.9020987219);" + qt_sql "SELECT ST_ANGLE_SPHERE(116.35620117, 39.939093, 116.4274406433, 39.9020987219);" + qt_sql "SELECT ST_ANGLE_SPHERE(0, 0, 45, 0);" + qt_sql "SELECT ST_AsText(ST_GeometryFromText(\"LINESTRING (1 1, 2 2)\"));" qt_sql "SELECT ST_AsText(ST_GeomFromText(\"LINESTRING (1 1, 2 2)\"));"