diff --git a/be/src/geo/geo_types.cpp b/be/src/geo/geo_types.cpp index b201c3739b..8949e33855 100644 --- a/be/src/geo/geo_types.cpp +++ b/be/src/geo/geo_types.cpp @@ -302,11 +302,12 @@ bool GeoPoint::ComputeDistance(double x_lng, double x_lat, double y_lng, double if (!y.is_valid()) { return false; } - *distance = S2Earth::ToMeters(x.GetDistance(y)); + *distance = S2Earth::GetDistanceMeters(x, y); return true; } -bool GeoPoint::ComputeAngle(double x_lng, double x_lat, double y_lng, double y_lat, double* angle) { +bool GeoPoint::ComputeAngleSphere(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; @@ -319,6 +320,44 @@ bool GeoPoint::ComputeAngle(double x_lng, double x_lat, double y_lng, double y_l return true; } +bool GeoPoint::ComputeAngle(GeoPoint* point1, GeoPoint* point2, GeoPoint* point3, double* angle) { + S2LatLng latLng1 = S2LatLng::FromDegrees(point1->x(), point1->y()); + S2LatLng latLng2 = S2LatLng::FromDegrees(point2->x(), point2->y()); + S2LatLng latLng3 = S2LatLng::FromDegrees(point3->x(), point3->y()); + + //If points 2 and 3 are the same or points 2 and 1 are the same, returns NULL. + if (latLng2.operator==(latLng1) || latLng2.operator==(latLng3)) { + return false; + } + double x = 0; + double y = 0; + //If points 2 and 3 are exactly antipodal or points 2 and 1 are exactly antipodal, returns NULL. + if (GeoPoint::ComputeAngleSphere(point1->x(), point1->y(), point2->x(), point2->y(), &x) && + GeoPoint::ComputeAngleSphere(point3->x(), point3->y(), point2->x(), point2->y(), &y)) { + if (x == 180 || y == 180) { + return false; + } + } else { + return false; + } + //Computes the initial bearing (radians) from latLng2 to latLng3 + double a = S2Earth::GetInitialBearing(latLng2, latLng3).radians(); + //Computes the initial bearing (radians) from latLng2 to latLng1 + double b = S2Earth::GetInitialBearing(latLng2, latLng1).radians(); + //range [0, 2pi) + if (b - a < 0) { + *angle = b - a + 2 * M_PI; + } else { + *angle = b - a; + } + return true; +} +bool GeoPoint::ComputeAzimuth(GeoPoint* p1, GeoPoint* p2, double* angle) { + GeoPoint north; + north.from_coord(0, 90); + return GeoPoint::ComputeAngle(&north, p1, p2, angle); +} + GeoParseStatus GeoLine::from_coords(const GeoCoordinateList& list) { return to_s2polyline(list, &_polyline); } @@ -473,6 +512,14 @@ bool GeoShape::ComputeArea(GeoShape* rhs, double* area, std::string square_unit) steradians = polygon->getArea(); break; } + case GEO_SHAPE_POINT: { + *area = 0; + return true; + } + case GEO_SHAPE_LINE_STRING: { + *area = 0; + return true; + } default: return false; } diff --git a/be/src/geo/geo_types.h b/be/src/geo/geo_types.h index aabd5fd059..bb7e65fbdd 100644 --- a/be/src/geo/geo_types.h +++ b/be/src/geo/geo_types.h @@ -78,7 +78,10 @@ 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); + static bool ComputeAngleSphere(double x_lng, double x_lat, double y_lng, double y_lat, + double* angle); + static bool ComputeAngle(GeoPoint* p1, GeoPoint* p2, GeoPoint* p3, double* angle); + static bool ComputeAzimuth(GeoPoint* p1, GeoPoint* p2, 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 7c81daa48c..b3b0809877 100644 --- a/be/src/vec/functions/functions_geo.cpp +++ b/be/src/vec/functions/functions_geo.cpp @@ -218,10 +218,10 @@ struct StAngleSphere { 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)) { + if (!GeoPoint::ComputeAngleSphere(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; } @@ -233,6 +233,100 @@ struct StAngleSphere { } }; +struct StAngle { + static constexpr auto NEED_CONTEXT = false; + static constexpr auto NAME = "st_angle"; + static const size_t NUM_ARGS = 3; + static Status execute(Block& block, const ColumnNumbers& arguments, size_t result) { + DCHECK_EQ(arguments.size(), 3); + auto return_type = block.get_data_type(result); + MutableColumnPtr res = return_type->create_column(); + + auto p1 = block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); + auto p2 = block.get_by_position(arguments[1]).column->convert_to_full_column_if_const(); + auto p3 = block.get_by_position(arguments[2]).column->convert_to_full_column_if_const(); + const auto size = p1->size(); + + GeoPoint point1; + GeoPoint point2; + GeoPoint point3; + + for (int row = 0; row < size; ++row) { + auto shape_value1 = p1->get_data_at(row); + auto pt1 = point1.decode_from(shape_value1.data, shape_value1.size); + if (!pt1) { + res->insert_data(nullptr, 0); + continue; + } + + auto shape_value2 = p2->get_data_at(row); + auto pt2 = point2.decode_from(shape_value2.data, shape_value2.size); + if (!pt2) { + res->insert_data(nullptr, 0); + continue; + } + auto shape_value3 = p3->get_data_at(row); + auto pt3 = point3.decode_from(shape_value3.data, shape_value3.size); + if (!pt3) { + res->insert_data(nullptr, 0); + continue; + } + + double angle = 0; + if (!GeoPoint::ComputeAngle(&point1, &point2, &point3, &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 StAzimuth { + static constexpr auto NEED_CONTEXT = false; + static constexpr auto NAME = "st_azimuth"; + 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 = block.get_data_type(result); + MutableColumnPtr res = return_type->create_column(); + + auto p1 = block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); + auto p2 = block.get_by_position(arguments[1]).column->convert_to_full_column_if_const(); + const auto size = p1->size(); + + GeoPoint point1; + GeoPoint point2; + + for (int row = 0; row < size; ++row) { + auto shape_value1 = p1->get_data_at(row); + auto pt1 = point1.decode_from(shape_value1.data, shape_value1.size); + if (!pt1) { + res->insert_data(nullptr, 0); + continue; + } + + auto shape_value2 = p2->get_data_at(row); + auto pt2 = point2.decode_from(shape_value2.data, shape_value2.size); + if (!pt2) { + res->insert_data(nullptr, 0); + continue; + } + + double angle = 0; + if (!GeoPoint::ComputeAzimuth(&point1, &point2, &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 StAreaSquareMeters { static constexpr auto NEED_CONTEXT = false; static constexpr auto NAME = "st_area_square_meters"; @@ -481,6 +575,8 @@ 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>(); factory.register_function>>(); diff --git a/be/test/vec/function/function_geo_test.cpp b/be/test/vec/function/function_geo_test.cpp index 580b681e5e..de0b27e6ff 100644 --- a/be/test/vec/function/function_geo_test.cpp +++ b/be/test/vec/function/function_geo_test.cpp @@ -157,6 +157,61 @@ TEST(VGeoFunctionsTest, function_geo_st_angle_sphere) { } } +TEST(VGeoFunctionsTest, function_geo_st_angle) { + std::string func_name = "st_angle"; + { + InputTypeSet input_types = {TypeIndex::String, TypeIndex::String, TypeIndex::String}; + + GeoPoint point1; + auto cur_res1 = point1.from_coord(1, 0); + EXPECT_TRUE(cur_res1 == GEO_PARSE_OK); + GeoPoint point2; + auto cur_res2 = point2.from_coord(0, 0); + EXPECT_TRUE(cur_res2 == GEO_PARSE_OK); + GeoPoint point3; + auto cur_res3 = point3.from_coord(0, 1); + EXPECT_TRUE(cur_res3 == GEO_PARSE_OK); + std::string buf1; + point1.encode_to(&buf1); + std::string buf2; + point2.encode_to(&buf2); + std::string buf3; + point3.encode_to(&buf3); + + DataSet data_set = {{{buf1, buf2, buf3}, (double)4.71238898038469}, + {{buf1, buf2, Null()}, Null()}, + {{buf1, Null(), buf3}, Null()}, + {{Null(), buf2, buf3}, Null()}}; + + check_function(func_name, input_types, data_set); + } +} + +TEST(VGeoFunctionsTest, function_geo_st_azimuth) { + std::string func_name = "st_azimuth"; + { + InputTypeSet input_types = {TypeIndex::String, TypeIndex::String}; + + GeoPoint point1; + auto cur_res1 = point1.from_coord(0, 0); + EXPECT_TRUE(cur_res1 == GEO_PARSE_OK); + GeoPoint point2; + auto cur_res2 = point2.from_coord(1, 0); + EXPECT_TRUE(cur_res2 == GEO_PARSE_OK); + + std::string buf1; + point1.encode_to(&buf1); + std::string buf2; + point2.encode_to(&buf2); + + DataSet data_set = {{{buf1, buf2}, (double)1.5707963267948966}, + {{buf1, Null()}, Null()}, + {{Null(), buf2}, 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.md b/docs/en/docs/sql-manual/sql-functions/spatial-functions/st_angle.md new file mode 100644 index 0000000000..61cd1a9d76 --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/spatial-functions/st_angle.md @@ -0,0 +1,89 @@ +--- +{ + "title": "ST_Angle", + "language": "en" +} +--- + + + +## ST_Angle + +### Syntax + +`DOUBLE ST_Angle(GEOPOINT point1, GEOPOINT point2, GEOPOINT point3)` + +### description + +Enter three point, which represent two intersecting lines. Returns the angle between these lines. Point 2 and point 1 represent the first line and point 2 and point 3 represent the second line. The angle between these lines is in radians, in the range [0, 2pi). The angle is measured clockwise from the first line to the second line. + +ST_ANGLE has the following edge cases: + +* If points 2 and 3 are the same, returns NULL. +* If points 2 and 1 are the same, returns NULL. +* If points 2 and 3 are exactly antipodal, returns NULL. +* If points 2 and 1 are exactly antipodal, returns NULL. +* If any of the input geographies are not single points or are the empty geography, then throws an error. + +### example + +``` +mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); ++----------------------------------------------------------------------+ +| st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 1.0)) | ++----------------------------------------------------------------------+ +| 4.71238898038469 | ++----------------------------------------------------------------------+ +1 row in set (0.04 sec) + +mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); ++----------------------------------------------------------------------+ +| st_angle(st_point(0.0, 0.0), st_point(1.0, 0.0), st_point(0.0, 1.0)) | ++----------------------------------------------------------------------+ +| 0.78547432161873854 | ++----------------------------------------------------------------------+ +1 row in set (0.02 sec) + +mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); ++----------------------------------------------------------------------+ +| st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(1.0, 0.0)) | ++----------------------------------------------------------------------+ +| 0 | ++----------------------------------------------------------------------+ +1 row in set (0.02 sec) + +mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); ++----------------------------------------------------------------------+ +| st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 0.0)) | ++----------------------------------------------------------------------+ +| NULL | ++----------------------------------------------------------------------+ +1 row in set (0.03 sec) + +mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); ++--------------------------------------------------------------------------+ +| st_angle(st_point(0.0, 0.0), st_point(-30.0, 0.0), st_point(150.0, 0.0)) | ++--------------------------------------------------------------------------+ +| NULL | ++--------------------------------------------------------------------------+ +1 row in set (0.02 sec) +``` +### keywords +ST_ANGLE,ST,ANGLE 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 index 7c82c6d3ce..5a9856465d 100644 --- 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 @@ -1,7 +1,7 @@ --- { -"title": "ST_Angle_Sphere", -"language": "en" + "title": "ST_Angle_Sphere", + "language": "en" } --- diff --git a/docs/en/docs/sql-manual/sql-functions/spatial-functions/st_area.md b/docs/en/docs/sql-manual/sql-functions/spatial-functions/st_area.md index 7831f65c3e..beb2d5a72d 100644 --- a/docs/en/docs/sql-manual/sql-functions/spatial-functions/st_area.md +++ b/docs/en/docs/sql-manual/sql-functions/spatial-functions/st_area.md @@ -1,7 +1,7 @@ --- { -"title": "ST_Area", -"language": "en" + "title": "ST_Area", + "language": "en" } --- @@ -34,7 +34,11 @@ under the License. ### description -Calculate the area of the area on the earth's sphere. Currently, the parameter geo supports ST_Circle and ST_Polygon. Among them, the unit returned by ST_Area_Square_Meters (GEOMETRY geo) is square meters, and the unit returned by ST_Area_Square_Km (GEOMETRY geo) is square kilometers. +Calculate the area of the area on the earth's sphere. Currently, the parameter geo supports St_Point, St_LineString, St_Circle and St_Polygon. + +Returns zero if the input is St_Point, St_LineString. + +Among them, the unit returned by ST_Area_Square_Meters (GEOMETRY geo) is square meters, and the unit returned by ST_Area_Square_Km (GEOMETRY geo) is square kilometers. ### example @@ -54,6 +58,22 @@ mysql> SELECT ST_Area_Square_Km(ST_Polygon("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))" | 12364.036567076409 | +----------------------------------------------------------------------+ 1 row in set (0.01 sec) + +mysql> SELECT ST_Area_Square_Meters(ST_Point(0, 1)); ++-------------------------------------------+ +| st_area_square_meters(st_point(0.0, 1.0)) | ++-------------------------------------------+ +| 0 | ++-------------------------------------------+ +1 row in set (0.05 sec) + +mysql> SELECT ST_Area_Square_Meters(ST_LineFromText("LINESTRING (1 1, 2 2)")); ++-----------------------------------------------------------------+ +| st_area_square_meters(st_linefromtext('LINESTRING (1 1, 2 2)')) | ++-----------------------------------------------------------------+ +| 0 | ++-----------------------------------------------------------------+ +1 row in set (0.03 sec) ``` ### keywords ST_Area_Square_Meters,ST_Area_Square_Km,ST_Area,ST,Area diff --git a/docs/en/docs/sql-manual/sql-functions/spatial-functions/st_azimuth.md b/docs/en/docs/sql-manual/sql-functions/spatial-functions/st_azimuth.md new file mode 100644 index 0000000000..4aa1b06b23 --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/spatial-functions/st_azimuth.md @@ -0,0 +1,95 @@ +--- +{ + "title": "ST_Azimuth", + "language": "en" +} +--- + + + +## ST_Azimuth + +### Syntax + +`DOUBLE ST_Azimuth(GEOPOINT point1, GEOPOINT point2)` + +### description + +Enter two point, and returns the azimuth of the line segment formed by points 1 and 2. The azimuth is the angle in radians measured between the line from point 1 facing true North to the line segment from point 1 to point 2. + +The positive angle is measured clockwise on the surface of a sphere. For example, the azimuth for a line segment: + +* Pointing North is 0 +* Pointing East is PI/2 +* Pointing South is PI +* Pointing West is 3PI/2 + +ST_Azimuth has the following edge cases: + +* If the two input points are the same, returns NULL. +* If the two input points are exactly antipodal, returns NULL. +* If either of the input geographies are not single points or are the empty geography, throws an error. + +### example + +``` +mysql> SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); ++----------------------------------------------------+ +| st_azimuth(st_point(1.0, 0.0), st_point(0.0, 0.0)) | ++----------------------------------------------------+ +| 4.71238898038469 | ++----------------------------------------------------+ +1 row in set (0.03 sec) + +mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); ++----------------------------------------------------+ +| st_azimuth(st_point(0.0, 0.0), st_point(1.0, 0.0)) | ++----------------------------------------------------+ +| 1.5707963267948966 | ++----------------------------------------------------+ +1 row in set (0.01 sec) + +mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); ++----------------------------------------------------+ +| st_azimuth(st_point(0.0, 0.0), st_point(0.0, 1.0)) | ++----------------------------------------------------+ +| 0 | ++----------------------------------------------------+ +1 row in set (0.01 sec) + +mysql> SELECT st_azimuth(ST_Point(0, 1),ST_Point(0, 1)); ++----------------------------------------------------+ +| st_azimuth(st_point(0.0, 1.0), st_point(0.0, 1.0)) | ++----------------------------------------------------+ +| NULL | ++----------------------------------------------------+ +1 row in set (0.02 sec) + +mysql> SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); ++--------------------------------------------------------+ +| st_azimuth(st_point(-30.0, 0.0), st_point(150.0, 0.0)) | ++--------------------------------------------------------+ +| NULL | ++--------------------------------------------------------+ +1 row in set (0.02 sec) + +``` +### keywords +ST_AZIMUTH,ST,AZIMUTH diff --git a/docs/sidebars.json b/docs/sidebars.json index d64e226e96..3283ac15c3 100644 --- a/docs/sidebars.json +++ b/docs/sidebars.json @@ -389,6 +389,8 @@ "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", + "sql-manual/sql-functions/spatial-functions/st_azimuth", "sql-manual/sql-functions/spatial-functions/st_angle_sphere", "sql-manual/sql-functions/spatial-functions/st_area", "sql-manual/sql-functions/spatial-functions/st_point", diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/spatial-functions/st_angle.md b/docs/zh-CN/docs/sql-manual/sql-functions/spatial-functions/st_angle.md new file mode 100644 index 0000000000..3f383aa182 --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/spatial-functions/st_angle.md @@ -0,0 +1,89 @@ +--- +{ + "title": "ST_Angle", + "language": "zh-CN" +} +--- + + + +## ST_Angle + +### Syntax + +`DOUBLE ST_Angle(GEOPOINT point1, GEOPOINT point2, GEOPOINT point3)` + +### description + +输入三个点,它们表示两条相交的线。返回这些线之间的夹角。点 2 和点 1 表示第一条线,点 2 和点 3 表示第二条线。这些线之间的夹角以弧度表示,范围为 [0, 2pi)。夹角按顺时针方向从第一条线开始测量,直至第二条线。 + +ST_ANGLE 存在以下边缘情况: + +* 如果点 2 和点 3 相同,则返回 NULL。 +* 如果点 2 和点 1 相同,则返回 NULL。 +* 如果点 2 和点 3 是完全对映点,则返回 NULL。 +* 如果点 2 和点 1 是完全对映点,则返回 NULL。 +* 如果任何输入地理位置不是单点或为空地理位置,则会抛出错误。 + +### example + +``` +mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); ++----------------------------------------------------------------------+ +| st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 1.0)) | ++----------------------------------------------------------------------+ +| 4.71238898038469 | ++----------------------------------------------------------------------+ +1 row in set (0.04 sec) + +mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); ++----------------------------------------------------------------------+ +| st_angle(st_point(0.0, 0.0), st_point(1.0, 0.0), st_point(0.0, 1.0)) | ++----------------------------------------------------------------------+ +| 0.78547432161873854 | ++----------------------------------------------------------------------+ +1 row in set (0.02 sec) + +mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); ++----------------------------------------------------------------------+ +| st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(1.0, 0.0)) | ++----------------------------------------------------------------------+ +| 0 | ++----------------------------------------------------------------------+ +1 row in set (0.02 sec) + +mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); ++----------------------------------------------------------------------+ +| st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 0.0)) | ++----------------------------------------------------------------------+ +| NULL | ++----------------------------------------------------------------------+ +1 row in set (0.03 sec) + +mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); ++--------------------------------------------------------------------------+ +| st_angle(st_point(0.0, 0.0), st_point(-30.0, 0.0), st_point(150.0, 0.0)) | ++--------------------------------------------------------------------------+ +| NULL | ++--------------------------------------------------------------------------+ +1 row in set (0.02 sec) +``` +### keywords +ST_ANGLE,ST,ANGLE 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 index 96e8bb96a1..61acdd5e37 100644 --- 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 @@ -1,7 +1,7 @@ --- { -"title": "ST_Angle_Sphere", -"language": "zh-CN" + "title": "ST_Angle_Sphere", + "language": "zh-CN" } --- diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/spatial-functions/st_area.md b/docs/zh-CN/docs/sql-manual/sql-functions/spatial-functions/st_area.md index 4c514ba607..dda26bde35 100644 --- a/docs/zh-CN/docs/sql-manual/sql-functions/spatial-functions/st_area.md +++ b/docs/zh-CN/docs/sql-manual/sql-functions/spatial-functions/st_area.md @@ -1,7 +1,7 @@ --- { -"title": "ST_Area", -"language": "zh-CN" + "title": "ST_Area", + "language": "zh-CN" } --- @@ -34,7 +34,11 @@ under the License. ### description -计算地球球面上区域的面积,目前参数geo支持st_circle和st_polygon。其中,ST_Area_Square_Meters(GEOMETRY geo)返回的单位是平方米,ST_Area_Square_Km(GEOMETRY geo)返回的单位是平方千米。 +计算地球球面上区域的面积,目前参数geo支持St_Point,St_LineString,St_Circle和St_Polygon。 + +如果输入的是St_Point,St_LineString,则返回零。 + +其中,ST_Area_Square_Meters(GEOMETRY geo)返回的单位是平方米,ST_Area_Square_Km(GEOMETRY geo)返回的单位是平方千米。 ### example @@ -54,6 +58,22 @@ mysql> SELECT ST_Area_Square_Km(ST_Polygon("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))" | 12364.036567076409 | +----------------------------------------------------------------------+ 1 row in set (0.01 sec) + +mysql> SELECT ST_Area_Square_Meters(ST_Point(0, 1)); ++-------------------------------------------+ +| st_area_square_meters(st_point(0.0, 1.0)) | ++-------------------------------------------+ +| 0 | ++-------------------------------------------+ +1 row in set (0.05 sec) + +mysql> SELECT ST_Area_Square_Meters(ST_LineFromText("LINESTRING (1 1, 2 2)")); ++-----------------------------------------------------------------+ +| st_area_square_meters(st_linefromtext('LINESTRING (1 1, 2 2)')) | ++-----------------------------------------------------------------+ +| 0 | ++-----------------------------------------------------------------+ +1 row in set (0.03 sec) ``` ### keywords ST_Area_Square_Meters,ST_Area_Square_Km,ST_Area,ST,Area diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/spatial-functions/st_azimuth.md b/docs/zh-CN/docs/sql-manual/sql-functions/spatial-functions/st_azimuth.md new file mode 100644 index 0000000000..50ea080f34 --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/spatial-functions/st_azimuth.md @@ -0,0 +1,87 @@ +--- +{ + "title": "ST_Azimuth", + "language": "zh-CN" +} +--- + + + +## ST_Azimuth + +### Syntax + +`DOUBLE ST_Azimuth(GEOPOINT point1, GEOPOINT point2)` + +### description + +输入两个点,并返回由点 1 和点 2 形成的线段的方位角。方位角是点 1 的真北方向线与点 1 和点 2 形成的线段之间的角的弧度。 + +正角在球面上按顺时针方向测量。 例如,线段的方位角: + +* 指北是 0 +* 指东是 PI/2 +* 指南是 PI +* 指西是 3PI/2 + +ST_Azimuth 存在以下边缘情况: + +* 如果两个输入点相同,则返回 NULL。 +* 如果两个输入点是完全对映点,则返回 NULL。 +* 如果任一输入地理位置不是单点或为空地理位置,则会抛出错误。 + +### example + +``` +mysql> SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); ++----------------------------------------------------+ +| st_azimuth(st_point(1.0, 0.0), st_point(0.0, 0.0)) | ++----------------------------------------------------+ +| 4.71238898038469 | ++----------------------------------------------------+ +1 row in set (0.03 sec) + +mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); ++----------------------------------------------------+ +| st_azimuth(st_point(0.0, 0.0), st_point(1.0, 0.0)) | ++----------------------------------------------------+ +| 1.5707963267948966 | ++----------------------------------------------------+ +1 row in set (0.01 sec) + +mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); ++----------------------------------------------------+ +| st_azimuth(st_point(0.0, 0.0), st_point(0.0, 1.0)) | ++----------------------------------------------------+ +| 0 | ++----------------------------------------------------+ +1 row in set (0.01 sec) + +mysql> SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); ++--------------------------------------------------------+ +| st_azimuth(st_point(-30.0, 0.0), st_point(150.0, 0.0)) | ++--------------------------------------------------------+ +| NULL | ++--------------------------------------------------------+ +1 row in set (0.02 sec) + +``` +### keywords +ST_AZIMUTH,ST,AZIMUTH 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 e72a730aae..e952be58a1 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 @@ -267,11 +267,13 @@ 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.StAngle; import org.apache.doris.nereids.trees.expressions.functions.scalar.StAngleSphere; import org.apache.doris.nereids.trees.expressions.functions.scalar.StAreaSquareKm; import org.apache.doris.nereids.trees.expressions.functions.scalar.StAreaSquareMeters; 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.StAzimuth; import org.apache.doris.nereids.trees.expressions.functions.scalar.StCircle; import org.apache.doris.nereids.trees.expressions.functions.scalar.StContains; import org.apache.doris.nereids.trees.expressions.functions.scalar.StDistanceSphere; @@ -598,6 +600,8 @@ public class BuiltinScalarFunctions implements FunctionHelper { scalar(StContains.class, "st_contains"), scalar(StDistanceSphere.class, "st_distance_sphere"), scalar(StAngleSphere.class, "st_angle_sphere"), + scalar(StAngle.class, "st_angle"), + scalar(StAzimuth.class, "st_azimuth"), scalar(StAreaSquareMeters.class, "st_area_square_meters"), scalar(StAreaSquareKm.class, "st_area_square_km"), scalar(StGeometryfromtext.class, "st_geometryfromtext"), diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAngle.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAngle.java new file mode 100644 index 0000000000..ee2bc588c2 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAngle.java @@ -0,0 +1,70 @@ +// 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.shape.TernaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.DoubleType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'st_angle'. This class is generated by GenerateFunction. + */ + +public class StAngle extends ScalarFunction + implements TernaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE) + .args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 3 argument. + */ + public StAngle(Expression arg0, Expression arg1, Expression arg2) { + super("st_angle", arg0, arg1, arg2); + } + + /** + * withChildren. + */ + @Override + public StAngle withChildren(List children) { + Preconditions.checkArgument(children.size() == 3); + return new StAngle(children.get(0), children.get(1), children.get(2)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStAngle(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAzimuth.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAzimuth.java new file mode 100644 index 0000000000..ba23d33b54 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StAzimuth.java @@ -0,0 +1,69 @@ +// 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.shape.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.DoubleType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'st_azimuth'. This class is generated by GenerateFunction. + */ + +public class StAzimuth extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(DoubleType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 2 argument. + */ + public StAzimuth(Expression arg0, Expression arg1) { + super("st_azimuth", arg0, arg1); + } + + /** + * withChildren. + */ + @Override + public StAzimuth withChildren(List children) { + Preconditions.checkArgument(children.size() == 2); + return new StAzimuth(children.get(0), children.get(1)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitStAzimuth(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 21811c40d9..e4ed308994 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 @@ -269,11 +269,13 @@ 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.StAngle; import org.apache.doris.nereids.trees.expressions.functions.scalar.StAngleSphere; import org.apache.doris.nereids.trees.expressions.functions.scalar.StAreaSquareKm; import org.apache.doris.nereids.trees.expressions.functions.scalar.StAreaSquareMeters; 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.StAzimuth; import org.apache.doris.nereids.trees.expressions.functions.scalar.StCircle; import org.apache.doris.nereids.trees.expressions.functions.scalar.StContains; import org.apache.doris.nereids.trees.expressions.functions.scalar.StDistanceSphere; @@ -1373,6 +1375,14 @@ public interface ScalarFunctionVisitor { return visitScalarFunction(stAngleSphere, context); } + default R visitStAngle(StAngle stAngle, C context) { + return visitScalarFunction(stAngle, context); + } + + default R visitStAzimuth(StAzimuth stAzimuth, C context) { + return visitScalarFunction(stAzimuth, context); + } + default R visitStAreaSquareMeters(StAreaSquareMeters stAreaSquareMeters, C context) { return visitScalarFunction(stAreaSquareMeters, context); } diff --git a/gensrc/script/doris_builtins_functions.py b/gensrc/script/doris_builtins_functions.py index b1063f77d1..23365a03a7 100644 --- a/gensrc/script/doris_builtins_functions.py +++ b/gensrc/script/doris_builtins_functions.py @@ -1698,6 +1698,11 @@ visible_functions = [ [['ST_Distance_Sphere'], 'DOUBLE', ['DOUBLE', 'DOUBLE', 'DOUBLE', 'DOUBLE'], 'ALWAYS_NULLABLE'], [['ST_Angle_Sphere'], 'DOUBLE', ['DOUBLE', 'DOUBLE', 'DOUBLE', 'DOUBLE'], 'ALWAYS_NULLABLE'], + [['ST_Angle'], 'DOUBLE', ['VARCHAR','VARCHAR','VARCHAR'], 'ALWAYS_NULLABLE'], + [['ST_Angle'], 'DOUBLE', ['STRING','STRING','STRING'], 'ALWAYS_NULLABLE'], + [['ST_Azimuth'], 'DOUBLE', ['VARCHAR','VARCHAR'], 'ALWAYS_NULLABLE'], + [['ST_Azimuth'], 'DOUBLE', ['STRING','STRING'], 'ALWAYS_NULLABLE'], + [['ST_Area_Square_Meters'], 'DOUBLE', ['VARCHAR'], 'ALWAYS_NULLABLE'], [['ST_Area_Square_Meters'], 'DOUBLE', ['STRING'], 'ALWAYS_NULLABLE'], [['ST_Area_Square_Km'], 'DOUBLE', ['VARCHAR'], 'ALWAYS_NULLABLE'], diff --git a/regression-test/data/nereids_function_p0/fn_test.dat b/regression-test/data/nereids_function_p0/fn_test.dat index 8ca5495729..54877f74b5 100644 --- a/regression-test/data/nereids_function_p0/fn_test.dat +++ b/regression-test/data/nereids_function_p0/fn_test.dat @@ -1,13 +1,13 @@ -0;0;1;1;1;1;1;0.1;0.1;0.1;0.1;0.1;0.1;0.1;0.1;char11;char21;char31;varchar11;varchar21;varchar31;string1;2012-03-01;2012-03-01;2012-03-01 01:00:01;2012-03-01 01:00:01;2012-03-01 01:00:01;2012-03-01 01:00:01;[0];[0];[1];[1];[1];[1];[1];[0.1];[2012-03-01,2012-03-01];[2012-03-01 01:00:01];[2012-03-01,2012-03-01];[2012-03-01 01:00:01,2012-03-01 01:00:01,2012-03-01 01:00:01,2012-03-01 01:00:01];[char11,char21,char31];[char11,char21,char31,varchar11,varchar21,varchar31];[char21,char31,varchar11,varchar21,varchar31,string1];[0.1,0.1];ST_Point(12.1, 32.1);ST_Point(12.1, 32.1);5;5;116.4274406433;39.9020987219;4.321;LINESTRING (1 1, 2 2);POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0)) -1;0;2;2;2;2;2;0.2;0.2;0.2;0.2;0.2;0.2;0.2;0.2;char12;char22;char32;varchar12;varchar22;varchar32;string2;2012-03-02;2012-03-02;2012-03-02 02:01:02;2012-03-02 02:01:02;2012-03-02 02:01:02;2012-03-02 02:01:02;[0];[0];[2];[2];[2];[2];[2];[0.2];[2012-03-02,2012-03-02];[2012-03-02 02:01:02];[2012-03-02,2012-03-02];[2012-03-02 02:01:02,2012-03-02 02:01:02,2012-03-02 02:01:02,2012-03-02 02:01:02];[char12,char22,char32];[char12,char22,char32,varchar12,varchar22,varchar32];[char22,char32,varchar12,varchar22,varchar32,string2];[0.2,0.2];ST_Point(12.2, 32.2);ST_Point(12.2, 32.2);126.35620117;-39.939093;56.4274406433;66.9020987219;5.3;LINESTRING (1 1, 2 2);POLYGON ((1 1, 4 1, 4 4, 1 4, 1 1)) -2;0;3;3;3;3;3;0.3;0.3;0.3;0.3;0.3;0.3;0.3;0.3;char13;char23;char33;varchar13;varchar23;varchar33;string3;2012-03-03;2012-03-03;2012-03-03 03:02:03;2012-03-03 03:02:03;2012-03-03 03:02:03;2012-03-03 03:02:03;[0];[0];[3];[3];[3];[3];[3];[0.3];[2012-03-03,2012-03-03];[2012-03-03 03:02:03];[2012-03-03,2012-03-03];[2012-03-03 03:02:03,2012-03-03 03:02:03,2012-03-03 03:02:03,2012-03-03 03:02:03];[char13,char23,char33];[char13,char23,char33,varchar13,varchar23,varchar33];[char23,char33,varchar13,varchar23,varchar33,string3];[0.3,0.3];ST_Point(12.3, 32.3);ST_Point(12.3, 32.3);16.35620117;19.939093;76.4274406433;46.9020987219;7.321;LINESTRING (1 1, 2 2);POLYGON ((0 0, 12 0, 10 16, 1 10, 0 0)) -3;0;4;4;4;4;4;0.4;0.4;0.4;0.4;0.4;0.4;0.4;0.4;char11;char21;char31;varchar11;varchar21;varchar31;string1;2012-03-04;2012-03-04;2012-03-04 04:03:04;2012-03-04 04:03:04;2012-03-04 04:03:04;2012-03-04 04:03:04;[0];[0];[4];[4];[4];[4];[4];[0.4];[2012-03-04,2012-03-04];[2012-03-04 04:03:04];[2012-03-04,2012-03-04];[2012-03-04 04:03:04,2012-03-04 04:03:04,2012-03-04 04:03:04,2012-03-04 04:03:04];[char11,char21,char31];[char11,char21,char31,varchar11,varchar21,varchar31];[char21,char31,varchar11,varchar21,varchar31,string1];[0.4,0.4];ST_Point(12.4, 32.4);ST_Point(12.4, 32.4);-46.35620117;39.939093;23.4274406433;-26.9020987219;3.321;LINESTRING (1 1, 2 2);POLYGON ((1 1, 11 4, 42 44, 4 18, 1 1)) -4;0;5;5;5;5;5;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.5;char12;char22;char32;varchar12;varchar22;varchar32;string2;2012-03-05;2012-03-05;2012-03-05 05:04:05;2012-03-05 05:04:05;2012-03-05 05:04:05;2012-03-05 05:04:05;[0];[0];[5];[5];[5];[5];[5];[0.5];[2012-03-05,2012-03-05];[2012-03-05 05:04:05];[2012-03-05,2012-03-05];[2012-03-05 05:04:05,2012-03-05 05:04:05,2012-03-05 05:04:05,2012-03-05 05:04:05];[char12,char22,char32];[char12,char22,char32,varchar12,varchar22,varchar32];[char22,char32,varchar12,varchar22,varchar32,string2];[0.5,0.5];ST_Point(12.5, 32.5);ST_Point(12.5, 32.5);43.35620117;35.939093;35.4274406433;35.9020987219;2.321;LINESTRING (1 1, 2 2);POLYGON ((1 1, 16 1, 16 16, 1 16, 1 1)) -5;0;6;6;6;6;6;0.6;0.6;0.6;0.6;0.6;0.6;0.6;0.6;char13;char23;char33;varchar13;varchar23;varchar33;string3;2012-03-06;2012-03-06;2012-03-06 06:05:06;2012-03-06 06:05:06;2012-03-06 06:05:06;2012-03-06 06:05:06;[0];[0];[6];[6];[6];[6];[6];[0.6];[2012-03-06,2012-03-06];[2012-03-06 06:05:06];[2012-03-06,2012-03-06];[2012-03-06 06:05:06,2012-03-06 06:05:06,2012-03-06 06:05:06,2012-03-06 06:05:06];[char13,char23,char33];[char13,char23,char33,varchar13,varchar23,varchar33];[char23,char33,varchar13,varchar23,varchar33,string3];[0.6,0.6];ST_Point(12.6, 32.6);ST_Point(12.6, 32.6);47.35620117;26.939093;47.4274406433;75.9020987219;33.321;LINESTRING (1 1, 2 2);POLYGON ((4 4, 45 4, 45 45, 4 45, 4 4)) -6;0;7;7;7;7;7;0.7;0.7;0.7;0.7;0.7;0.7;0.7;0.7;char11;char21;char31;varchar11;varchar21;varchar31;string1;2012-03-07;2012-03-07;2012-03-07 07:06:07;2012-03-07 07:06:07;2012-03-07 07:06:07;2012-03-07 07:06:07;[0];[0];[7];[7];[7];[7];[7];[0.7];[2012-03-07,2012-03-07];[2012-03-07 07:06:07];[2012-03-07,2012-03-07];[2012-03-07 07:06:07,2012-03-07 07:06:07,2012-03-07 07:06:07,2012-03-07 07:06:07];[char11,char21,char31];[char11,char21,char31,varchar11,varchar21,varchar31];[char21,char31,varchar11,varchar21,varchar31,string1];[0.7,0.7];ST_Point(12.7, 32.7);ST_Point(12.7, 32.7);98.35620117;36.939093;57.4274406433;57.9020987219;45.321;LINESTRING (1 1, 2 2);POLYGON ((1 1, 34 1, 34 34, 1 34, 1 1)) -7;1;8;8;8;8;8;0.8;0.8;0.8;0.8;0.8;0.8;0.8;0.8;char12;char22;char32;varchar12;varchar22;varchar32;string2;2012-03-08;2012-03-08;2012-03-08 08:07:08;2012-03-08 08:07:08;2012-03-08 08:07:08;2012-03-08 08:07:08;[1];[1];[8];[8];[8];[8];[8];[0.8];[2012-03-08,2012-03-08];[2012-03-08 08:07:08];[2012-03-08,2012-03-08];[2012-03-08 08:07:08,2012-03-08 08:07:08,2012-03-08 08:07:08,2012-03-08 08:07:08];[char12,char22,char32];[char12,char22,char32,varchar12,varchar22,varchar32];[char22,char32,varchar12,varchar22,varchar32,string2];[0.8,0.8];ST_Point(11.1, 31.1);ST_Point(11.1, 31.1);-74.35620117;79.939093;59.4274406433;85.9020987219;66.321;LINESTRING (1 1, 2 2);POLYGON ((0 0, 38 4, 38 37, 4 1, 0 0)) -8;1;9;9;9;9;9;0.9;0.9;0.9;0.9;0.9;0.9;0.9;0.9;char13;char23;char33;varchar13;varchar23;varchar33;string3;2012-03-09;2012-03-09;2012-03-09 09:08:09;2012-03-09 09:08:09;2012-03-09 09:08:09;2012-03-09 09:08:09;[1];[1];[9];[9];[9];[9];[9];[0.9];[2012-03-09,2012-03-09];[2012-03-09 09:08:09];[2012-03-09,2012-03-09];[2012-03-09 09:08:09,2012-03-09 09:08:09,2012-03-09 09:08:09,2012-03-09 09:08:09];[char13,char23,char33];[char13,char23,char33,varchar13,varchar23,varchar33];[char23,char33,varchar13,varchar23,varchar33,string3];[0.9,0.9];ST_Point(12.1, 32.1);ST_Point(12.1, 32.1);90.35620117;47.939093;89.4274406433;58.9020987219;88.321;LINESTRING (1 1, 2 2);POLYGON ((1 1, 56 0, 67 89, 4 32, 1 1)) -9;1;10;10;10;10;10;1;1;1;1;1;1;1;1;char11;char21;char31;varchar11;varchar21;varchar31;string1;2012-03-10;2012-03-10;2012-03-10 10:09:10;2012-03-10 10:09:10;2012-03-10 10:09:10;2012-03-10 10:09:10;[1];[1];[10];[10];[10];[10];[10];[1];[2012-03-10,2012-03-10];[2012-03-10 10:09:10];[2012-03-10,2012-03-10];[2012-03-10 10:09:10,2012-03-10 10:09:10,2012-03-10 10:09:10,2012-03-10 10:09:10];[char11,char21,char31];[char11,char21,char31,varchar11,varchar21,varchar31];[char21,char31,varchar11,varchar21,varchar31,string1];[1,1];ST_Point(19.1, 39.1);ST_Point(19.1, 39.1);90.35620117;49.939093;89.4274406433;58.9020987219;76.321;LINESTRING (1 1, 2 2);POLYGON ((1 1, 5 0, 10 4, 4 3, 1 1)) -10;1;11;11;11;11;11;1.1;1.1;1.1;1.1;1.1;1.1;1.1;1.1;char12;char22;char32;varchar12;varchar22;varchar32;string2;2012-03-11;2012-03-11;2012-03-11 11:10:11;2012-03-11 11:10:11;2012-03-11 11:10:11;2012-03-11 11:10:11;[1];[1];[11];[11];[11];[11];[11];[1.1];[2012-03-11,2012-03-11];[2012-03-11 11:10:11];[2012-03-11,2012-03-11];[2012-03-11 11:10:11,2012-03-11 11:10:11,2012-03-11 11:10:11,2012-03-11 11:10:11];[char12,char22,char32];[char12,char22,char32,varchar12,varchar22,varchar32];[char22,char32,varchar12,varchar22,varchar32,string2];[1.1,1.1];ST_Point(17.1, 37.1);ST_Point(17.1, 37.1);90.35620117;59.939093;89.4274406433;58.9020987219;75.321;LINESTRING (1 1, 2 2);POLYGON ((1 1, 8 0, 48 34, 4 10, 1 1)) -11;1;12;12;12;12;12;1.2;1.2;1.2;1.2;1.2;1.2;1.2;1.2;char13;char23;char33;varchar13;varchar23;varchar33;string3;2012-03-12;2012-03-12;2012-03-12 12:11:12;2012-03-12 12:11:12;2012-03-12 12:11:12;2012-03-12 12:11:12;[1];[1];[12];[12];[12];[12];[12];[1.2];[2012-03-12,2012-03-12];[2012-03-12 12:11:12];[2012-03-12,2012-03-12];[2012-03-12 12:11:12,2012-03-12 12:11:12,2012-03-12 12:11:12,2012-03-12 12:11:12];[char13,char23,char33];[char13,char23,char33,varchar13,varchar23,varchar33];[char23,char33,varchar13,varchar23,varchar33,string3];[1.2,1.2];ST_Point(22.1, 22.1);ST_Point(22.1, 22.1);90.35620117;39.939093;89.4274406433;58.9020987219;100.321;LINESTRING (1 1, 2 2);POLYGON ((1 1, 9 4, 10 4, 4 1, 1 1)) -null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null \ No newline at end of file +0;0;1;1;1;1;1;0.1;0.1;0.1;0.1;0.1;0.1;0.1;0.1;char11;char21;char31;varchar11;varchar21;varchar31;string1;2012-03-01;2012-03-01;2012-03-01 01:00:01;2012-03-01 01:00:01;2012-03-01 01:00:01;2012-03-01 01:00:01;[0];[0];[1];[1];[1];[1];[1];[0.1];[2012-03-01,2012-03-01];[2012-03-01 01:00:01];[2012-03-01,2012-03-01];[2012-03-01 01:00:01,2012-03-01 01:00:01,2012-03-01 01:00:01,2012-03-01 01:00:01];[char11,char21,char31];[char11,char21,char31,varchar11,varchar21,varchar31];[char21,char31,varchar11,varchar21,varchar31,string1];[0.1,0.1];ST_Point(12.1, 32.1);ST_Point(12.1, 32.1);5;5;116.4274406433;39.9020987219;0;1;4.321;LINESTRING (1 1, 2 2);POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0)) +1;0;2;2;2;2;2;0.2;0.2;0.2;0.2;0.2;0.2;0.2;0.2;char12;char22;char32;varchar12;varchar22;varchar32;string2;2012-03-02;2012-03-02;2012-03-02 02:01:02;2012-03-02 02:01:02;2012-03-02 02:01:02;2012-03-02 02:01:02;[0];[0];[2];[2];[2];[2];[2];[0.2];[2012-03-02,2012-03-02];[2012-03-02 02:01:02];[2012-03-02,2012-03-02];[2012-03-02 02:01:02,2012-03-02 02:01:02,2012-03-02 02:01:02,2012-03-02 02:01:02];[char12,char22,char32];[char12,char22,char32,varchar12,varchar22,varchar32];[char22,char32,varchar12,varchar22,varchar32,string2];[0.2,0.2];ST_Point(12.2, 32.2);ST_Point(12.2, 32.2);126.35620117;-39.939093;56.4274406433;66.9020987219;0;2;5.3;LINESTRING (1 1, 2 2);POLYGON ((1 1, 4 1, 4 4, 1 4, 1 1)) +2;0;3;3;3;3;3;0.3;0.3;0.3;0.3;0.3;0.3;0.3;0.3;char13;char23;char33;varchar13;varchar23;varchar33;string3;2012-03-03;2012-03-03;2012-03-03 03:02:03;2012-03-03 03:02:03;2012-03-03 03:02:03;2012-03-03 03:02:03;[0];[0];[3];[3];[3];[3];[3];[0.3];[2012-03-03,2012-03-03];[2012-03-03 03:02:03];[2012-03-03,2012-03-03];[2012-03-03 03:02:03,2012-03-03 03:02:03,2012-03-03 03:02:03,2012-03-03 03:02:03];[char13,char23,char33];[char13,char23,char33,varchar13,varchar23,varchar33];[char23,char33,varchar13,varchar23,varchar33,string3];[0.3,0.3];ST_Point(12.3, 32.3);ST_Point(12.3, 32.3);16.35620117;19.939093;76.4274406433;46.9020987219;0;3;7.321;LINESTRING (1 1, 2 2);POLYGON ((0 0, 12 0, 10 16, 1 10, 0 0)) +3;0;4;4;4;4;4;0.4;0.4;0.4;0.4;0.4;0.4;0.4;0.4;char11;char21;char31;varchar11;varchar21;varchar31;string1;2012-03-04;2012-03-04;2012-03-04 04:03:04;2012-03-04 04:03:04;2012-03-04 04:03:04;2012-03-04 04:03:04;[0];[0];[4];[4];[4];[4];[4];[0.4];[2012-03-04,2012-03-04];[2012-03-04 04:03:04];[2012-03-04,2012-03-04];[2012-03-04 04:03:04,2012-03-04 04:03:04,2012-03-04 04:03:04,2012-03-04 04:03:04];[char11,char21,char31];[char11,char21,char31,varchar11,varchar21,varchar31];[char21,char31,varchar11,varchar21,varchar31,string1];[0.4,0.4];ST_Point(12.4, 32.4);ST_Point(12.4, 32.4);-46.35620117;39.939093;23.4274406433;-26.9020987219;0;4;3.321;LINESTRING (1 1, 2 2);POLYGON ((1 1, 11 4, 42 44, 4 18, 1 1)) +4;0;5;5;5;5;5;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.5;char12;char22;char32;varchar12;varchar22;varchar32;string2;2012-03-05;2012-03-05;2012-03-05 05:04:05;2012-03-05 05:04:05;2012-03-05 05:04:05;2012-03-05 05:04:05;[0];[0];[5];[5];[5];[5];[5];[0.5];[2012-03-05,2012-03-05];[2012-03-05 05:04:05];[2012-03-05,2012-03-05];[2012-03-05 05:04:05,2012-03-05 05:04:05,2012-03-05 05:04:05,2012-03-05 05:04:05];[char12,char22,char32];[char12,char22,char32,varchar12,varchar22,varchar32];[char22,char32,varchar12,varchar22,varchar32,string2];[0.5,0.5];ST_Point(12.5, 32.5);ST_Point(12.5, 32.5);43.35620117;35.939093;35.4274406433;35.9020987219;0;5;2.321;LINESTRING (1 1, 2 2);POLYGON ((1 1, 16 1, 16 16, 1 16, 1 1)) +5;0;6;6;6;6;6;0.6;0.6;0.6;0.6;0.6;0.6;0.6;0.6;char13;char23;char33;varchar13;varchar23;varchar33;string3;2012-03-06;2012-03-06;2012-03-06 06:05:06;2012-03-06 06:05:06;2012-03-06 06:05:06;2012-03-06 06:05:06;[0];[0];[6];[6];[6];[6];[6];[0.6];[2012-03-06,2012-03-06];[2012-03-06 06:05:06];[2012-03-06,2012-03-06];[2012-03-06 06:05:06,2012-03-06 06:05:06,2012-03-06 06:05:06,2012-03-06 06:05:06];[char13,char23,char33];[char13,char23,char33,varchar13,varchar23,varchar33];[char23,char33,varchar13,varchar23,varchar33,string3];[0.6,0.6];ST_Point(12.6, 32.6);ST_Point(12.6, 32.6);47.35620117;26.939093;47.4274406433;75.9020987219;0;6;33.321;LINESTRING (1 1, 2 2);POLYGON ((4 4, 45 4, 45 45, 4 45, 4 4)) +6;0;7;7;7;7;7;0.7;0.7;0.7;0.7;0.7;0.7;0.7;0.7;char11;char21;char31;varchar11;varchar21;varchar31;string1;2012-03-07;2012-03-07;2012-03-07 07:06:07;2012-03-07 07:06:07;2012-03-07 07:06:07;2012-03-07 07:06:07;[0];[0];[7];[7];[7];[7];[7];[0.7];[2012-03-07,2012-03-07];[2012-03-07 07:06:07];[2012-03-07,2012-03-07];[2012-03-07 07:06:07,2012-03-07 07:06:07,2012-03-07 07:06:07,2012-03-07 07:06:07];[char11,char21,char31];[char11,char21,char31,varchar11,varchar21,varchar31];[char21,char31,varchar11,varchar21,varchar31,string1];[0.7,0.7];ST_Point(12.7, 32.7);ST_Point(12.7, 32.7);98.35620117;36.939093;57.4274406433;57.9020987219;0;7;45.321;LINESTRING (1 1, 2 2);POLYGON ((1 1, 34 1, 34 34, 1 34, 1 1)) +7;1;8;8;8;8;8;0.8;0.8;0.8;0.8;0.8;0.8;0.8;0.8;char12;char22;char32;varchar12;varchar22;varchar32;string2;2012-03-08;2012-03-08;2012-03-08 08:07:08;2012-03-08 08:07:08;2012-03-08 08:07:08;2012-03-08 08:07:08;[1];[1];[8];[8];[8];[8];[8];[0.8];[2012-03-08,2012-03-08];[2012-03-08 08:07:08];[2012-03-08,2012-03-08];[2012-03-08 08:07:08,2012-03-08 08:07:08,2012-03-08 08:07:08,2012-03-08 08:07:08];[char12,char22,char32];[char12,char22,char32,varchar12,varchar22,varchar32];[char22,char32,varchar12,varchar22,varchar32,string2];[0.8,0.8];ST_Point(11.1, 31.1);ST_Point(11.1, 31.1);-74.35620117;79.939093;59.4274406433;85.9020987219;0;8;66.321;LINESTRING (1 1, 2 2);POLYGON ((0 0, 38 4, 38 37, 4 1, 0 0)) +8;1;9;9;9;9;9;0.9;0.9;0.9;0.9;0.9;0.9;0.9;0.9;char13;char23;char33;varchar13;varchar23;varchar33;string3;2012-03-09;2012-03-09;2012-03-09 09:08:09;2012-03-09 09:08:09;2012-03-09 09:08:09;2012-03-09 09:08:09;[1];[1];[9];[9];[9];[9];[9];[0.9];[2012-03-09,2012-03-09];[2012-03-09 09:08:09];[2012-03-09,2012-03-09];[2012-03-09 09:08:09,2012-03-09 09:08:09,2012-03-09 09:08:09,2012-03-09 09:08:09];[char13,char23,char33];[char13,char23,char33,varchar13,varchar23,varchar33];[char23,char33,varchar13,varchar23,varchar33,string3];[0.9,0.9];ST_Point(12.1, 32.1);ST_Point(12.1, 32.1);90.35620117;47.939093;89.4274406433;58.9020987219;0;9;88.321;LINESTRING (1 1, 2 2);POLYGON ((1 1, 56 0, 67 89, 4 32, 1 1)) +9;1;10;10;10;10;10;1;1;1;1;1;1;1;1;char11;char21;char31;varchar11;varchar21;varchar31;string1;2012-03-10;2012-03-10;2012-03-10 10:09:10;2012-03-10 10:09:10;2012-03-10 10:09:10;2012-03-10 10:09:10;[1];[1];[10];[10];[10];[10];[10];[1];[2012-03-10,2012-03-10];[2012-03-10 10:09:10];[2012-03-10,2012-03-10];[2012-03-10 10:09:10,2012-03-10 10:09:10,2012-03-10 10:09:10,2012-03-10 10:09:10];[char11,char21,char31];[char11,char21,char31,varchar11,varchar21,varchar31];[char21,char31,varchar11,varchar21,varchar31,string1];[1,1];ST_Point(19.1, 39.1);ST_Point(19.1, 39.1);90.35620117;49.939093;89.4274406433;58.9020987219;0;10;76.321;LINESTRING (1 1, 2 2);POLYGON ((1 1, 5 0, 10 4, 4 3, 1 1)) +10;1;11;11;11;11;11;1.1;1.1;1.1;1.1;1.1;1.1;1.1;1.1;char12;char22;char32;varchar12;varchar22;varchar32;string2;2012-03-11;2012-03-11;2012-03-11 11:10:11;2012-03-11 11:10:11;2012-03-11 11:10:11;2012-03-11 11:10:11;[1];[1];[11];[11];[11];[11];[11];[1.1];[2012-03-11,2012-03-11];[2012-03-11 11:10:11];[2012-03-11,2012-03-11];[2012-03-11 11:10:11,2012-03-11 11:10:11,2012-03-11 11:10:11,2012-03-11 11:10:11];[char12,char22,char32];[char12,char22,char32,varchar12,varchar22,varchar32];[char22,char32,varchar12,varchar22,varchar32,string2];[1.1,1.1];ST_Point(17.1, 37.1);ST_Point(17.1, 37.1);90.35620117;59.939093;89.4274406433;58.9020987219;0;11;75.321;LINESTRING (1 1, 2 2);POLYGON ((1 1, 8 0, 48 34, 4 10, 1 1)) +11;1;12;12;12;12;12;1.2;1.2;1.2;1.2;1.2;1.2;1.2;1.2;char13;char23;char33;varchar13;varchar23;varchar33;string3;2012-03-12;2012-03-12;2012-03-12 12:11:12;2012-03-12 12:11:12;2012-03-12 12:11:12;2012-03-12 12:11:12;[1];[1];[12];[12];[12];[12];[12];[1.2];[2012-03-12,2012-03-12];[2012-03-12 12:11:12];[2012-03-12,2012-03-12];[2012-03-12 12:11:12,2012-03-12 12:11:12,2012-03-12 12:11:12,2012-03-12 12:11:12];[char13,char23,char33];[char13,char23,char33,varchar13,varchar23,varchar33];[char23,char33,varchar13,varchar23,varchar33,string3];[1.2,1.2];ST_Point(22.1, 22.1);ST_Point(22.1, 22.1);90.35620117;39.939093;89.4274406433;58.9020987219;0;12;100.321;LINESTRING (1 1, 2 2);POLYGON ((1 1, 9 4, 10 4, 4 1, 1 1)) +null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null \ No newline at end of file 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 a523755733..7d0e6c9607 100644 --- a/regression-test/data/nereids_function_p0/scalar_function/S.out +++ b/regression-test/data/nereids_function_p0/scalar_function/S.out @@ -1449,6 +1449,66 @@ true 102.90171567394134 119.16210498681423 +-- !sql_st_angle_Varchar_Varchar -- +\N +0.29640805436890805 +0.5845576630671012 +2.2514343365321805 +2.2985768978250287 +2.3435868570715472 +2.343933856604365 +2.34802834220062 +2.449573624637989 +3.0241913973486003 +4.933732381376881 +6.0197433678512455 +6.186722861065897 + +-- !sql_st_angle_Varchar_Varchar_notnull -- +\N +0.29640805436890805 +0.5845576630671012 +2.2514343365321805 +2.2985768978250287 +2.3435868570715472 +2.343933856604365 +2.34802834220062 +2.449573624637989 +3.0241913973486003 +4.933732381376881 +6.0197433678512455 +6.186722861065897 + +-- !sql_st_azimuth_Varchar_Varchar -- +\N +0.10887770754803192 +0.6831103181292284 +1.5514282110255961 +1.8473724820763877 +2.0312260636745996 +5.086326478855965 +5.170365116267284 +5.613823191254337 +5.653248008913474 +5.6670991049658905 +5.680456803008166 +5.74735717583794 + +-- !sql_st_azimuth_Varchar_Varchar_notnull -- +\N +0.10887770754803192 +0.6831103181292284 +1.5514282110255961 +1.8473724820763877 +2.0312260636745996 +5.086326478855965 +5.170365116267284 +5.613823191254337 +5.653248008913474 +5.6670991049658905 +5.680456803008166 +5.74735717583794 + -- !sql_st_area_square_meters_circle -- \N 16.92388987658693 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 edaee3be9b..8b4b03431a 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 @@ -65,3 +65,27 @@ POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0)) -- !sql -- 12364.03656707641 +-- !sql -- +4.71238898038469 + +-- !sql -- +0.7854743216187385 + +-- !sql -- +0.0 + +-- !sql -- +\N + +-- !sql -- +4.71238898038469 + +-- !sql -- +1.5707963267948966 + +-- !sql -- +0.0 + +-- !sql -- +\N + 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 edaee3be9b..8b4b03431a 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 @@ -65,3 +65,27 @@ POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0)) -- !sql -- 12364.03656707641 +-- !sql -- +4.71238898038469 + +-- !sql -- +0.7854743216187385 + +-- !sql -- +0.0 + +-- !sql -- +\N + +-- !sql -- +4.71238898038469 + +-- !sql -- +1.5707963267948966 + +-- !sql -- +0.0 + +-- !sql -- +\N + diff --git a/regression-test/suites/nereids_function_p0/load.groovy b/regression-test/suites/nereids_function_p0/load.groovy index 112fc91903..33ea1dd9f9 100644 --- a/regression-test/suites/nereids_function_p0/load.groovy +++ b/regression-test/suites/nereids_function_p0/load.groovy @@ -73,6 +73,8 @@ suite("load") { `x_lat` double null, `y_lng` double null, `y_lat` double null, + `z_lng` double null, + `z_lat` double null, `radius` double null, `linestring_wkt` varchar(50) null, `polygon_wkt` varchar(50) null @@ -133,6 +135,8 @@ suite("load") { `x_lat` double null, `y_lng` double null, `y_lat` double null, + `z_lng` double null, + `z_lat` double null, `radius` double null, `linestring_wkt` varchar(50) null, `polygon_wkt` varchar(50) null @@ -151,7 +155,7 @@ suite("load") { kdcmlv3s1, kdcmlv3s2, kdcmlv3s3, kchrs1, kchrs2, kchrs3, kvchrs1, kvchrs2, kvchrs3, kstr, kdt, kdtv2, kdtm, kdtmv2s1, kdtmv2s2, kdtmv2s3, kabool, katint, kasint, kaint, kabint, kalint, kafloat, kadbl, kadt, kadtm, kadtv2, kadtmv2, kachr, kavchr, kastr, kadcml, - st_point_str, st_point_vc, x_lng, x_lat, y_lng, y_lat, radius, linestring_wkt, polygon_wkt + st_point_str, st_point_vc, x_lng, x_lat, y_lng, y_lat, z_lng, z_lat, radius, linestring_wkt, polygon_wkt ''' file "fn_test.dat" } 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 be1a19b85e..c0f7317b67 100644 --- a/regression-test/suites/nereids_function_p0/scalar_function/S.groovy +++ b/regression-test/suites/nereids_function_p0/scalar_function/S.groovy @@ -194,6 +194,10 @@ suite("nereids_scalar_fn_S") { qt_sql_st_distance_sphere_Double_Double_Double_Double_notnull "select st_distance_sphere(x_lng, x_lat, y_lng, y_lat) from fn_test_not_nullable order by 1" qt_sql_st_angle_sphere_Double_Double_Double_Double "select st_angle_sphere(x_lng, x_lat, y_lng, y_lat) from fn_test order by 1" qt_sql_st_angle_sphere_Double_Double_Double_Double_notnull "select st_angle_sphere(x_lng, x_lat, y_lng, y_lat) from fn_test_not_nullable order by 1" + qt_sql_st_angle_Varchar_Varchar "select st_angle(st_point(x_lng, x_lat), st_point(y_lng, y_lat), st_point(z_lng, z_lat)) from fn_test order by 1" + qt_sql_st_angle_Varchar_Varchar_notnull "select st_angle(st_point(x_lng, x_lat), st_point(y_lng, y_lat), st_point(z_lng, z_lat)) from fn_test order by 1" + qt_sql_st_azimuth_Varchar_Varchar "select st_azimuth(st_point(x_lng, x_lat), st_point(y_lng, y_lat)) from fn_test order by 1" + qt_sql_st_azimuth_Varchar_Varchar_notnull "select st_azimuth(st_point(x_lng, x_lat), st_point(y_lng, y_lat)) from fn_test order by 1" qt_sql_st_area_square_meters_circle "select ST_Area_Square_Meters(ST_Circle(x_lng, x_lat, radius)) from fn_test order by 1" qt_sql_st_area_square_meters_circle_notnull "select ST_Area_Square_Meters(ST_Circle(x_lng, x_lat, radius)) from fn_test_not_nullable order by 1" qt_sql_st_area_square_meters_polygon "select ST_Area_Square_Meters(st_polygon(polygon_wkt)) from fn_test order by 1" 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 3a9f602609..3f42a14ca2 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 @@ -50,4 +50,14 @@ suite("test_gis_function") { qt_sql "SELECT ST_Area_Square_Km(ST_Circle(0, 0, 1));" qt_sql "SELECT ST_Area_Square_Meters(ST_Polygon(\"POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))\"));" qt_sql "SELECT ST_Area_Square_Km(ST_Polygon(\"POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))\"));" + + qt_sql "SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1));" + qt_sql "SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1));" + qt_sql "SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0));" + qt_sql "SELECT ST_Angle(ST_Point(1, 0),ST_Point(-30, 0),ST_Point(150, 0));" + + qt_sql "SELECT St_Azimuth(ST_Point(1, 0),ST_Point(0, 0));" + qt_sql "SELECT St_Azimuth(ST_Point(0, 0),ST_Point(1, 0));" + qt_sql "SELECT St_Azimuth(ST_Point(0, 0),ST_Point(0, 1));" + qt_sql "SELECT St_Azimuth(ST_Point(-30, 0),ST_Point(150, 0));" } 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 a831b89597..7ac3aa0c67 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 @@ -49,4 +49,14 @@ suite("test_gis_function") { qt_sql "SELECT ST_Area_Square_Km(ST_Circle(0, 0, 1));" qt_sql "SELECT ST_Area_Square_Meters(ST_Polygon(\"POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))\"));" qt_sql "SELECT ST_Area_Square_Km(ST_Polygon(\"POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))\"));" + + qt_sql "SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1));" + qt_sql "SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1));" + qt_sql "SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0));" + qt_sql "SELECT ST_Angle(ST_Point(1, 0),ST_Point(-30, 0),ST_Point(150, 0));" + + qt_sql "SELECT St_Azimuth(ST_Point(1, 0),ST_Point(0, 0));" + qt_sql "SELECT St_Azimuth(ST_Point(0, 0),ST_Point(1, 0));" + qt_sql "SELECT St_Azimuth(ST_Point(0, 0),ST_Point(0, 1));" + qt_sql "SELECT St_Azimuth(ST_Point(-30, 0),ST_Point(150, 0));" }