Browse Source

Rename ST_CENTROID to ST_CENTROID_AGG (#107226)

* Rename ST_CENTROID to ST_CENTROID_AGG

In order to allow development of a scalar ST_CENTROID function.

* Fix table alignment
Craig Taverner 1 year ago
parent
commit
d915b964ba

+ 1 - 1
docs/reference/esql/functions/aggregation-functions.asciidoc

@@ -29,6 +29,6 @@ include::median.asciidoc[]
 include::median-absolute-deviation.asciidoc[]
 include::min.asciidoc[]
 include::percentile.asciidoc[]
-include::st_centroid.asciidoc[]
+include::st_centroid_agg.asciidoc[]
 include::sum.asciidoc[]
 include::values.asciidoc[]

+ 3 - 3
docs/reference/esql/functions/st_centroid.asciidoc → docs/reference/esql/functions/st_centroid_agg.asciidoc

@@ -1,6 +1,6 @@
 [discrete]
 [[esql-agg-st-centroid]]
-=== `ST_CENTROID`
+=== `ST_CENTROID_AGG`
 
 experimental::[]
 
@@ -8,11 +8,11 @@ Calculate the spatial centroid over a field with spatial point geometry type.
 
 [source.merge.styled,esql]
 ----
-include::{esql-specs}/spatial.csv-spec[tag=st_centroid-airports]
+include::{esql-specs}/spatial.csv-spec[tag=st_centroid_agg-airports]
 ----
 [%header.monospaced.styled,format=dsv,separator=|]
 |===
-include::{esql-specs}/spatial.csv-spec[tag=st_centroid-airports-result]
+include::{esql-specs}/spatial.csv-spec[tag=st_centroid_agg-airports-result]
 |===
 
 Supported types:

+ 2 - 2
x-pack/plugin/esql/qa/testFixtures/src/main/resources/enrich-IT_tests_only.csv-spec

@@ -294,7 +294,7 @@ required_feature: esql.mv_warn
 FROM airports
 | ENRICH city_boundaries ON city_location WITH airport, region, city_boundary
 | EVAL boundary_wkt_length = LENGTH(TO_STRING(city_boundary))
-| STATS city_centroid = ST_CENTROID(city_location), count = COUNT(city_location), min_wkt = MIN(boundary_wkt_length), max_wkt = MAX(boundary_wkt_length)
+| STATS city_centroid = ST_CENTROID_AGG(city_location), count = COUNT(city_location), min_wkt = MIN(boundary_wkt_length), max_wkt = MAX(boundary_wkt_length)
 ;
 warning:Line 3:30: evaluation of [LENGTH(TO_STRING(city_boundary))] failed, treating result as null. Only first 20 failures recorded.
 warning:Line 3:30: java.lang.IllegalArgumentException: single-value function encountered multi-value
@@ -325,7 +325,7 @@ FROM airports
 | ENRICH city_names ON city WITH airport, region, city_boundary
 | MV_EXPAND city_boundary
 | EVAL airport_in_city = ST_INTERSECTS(location, city_boundary)
-| STATS count=COUNT(*), centroid=ST_CENTROID(location) BY airport_in_city
+| STATS count=COUNT(*), centroid=ST_CENTROID_AGG(location) BY airport_in_city
 | SORT count ASC
 ;
 

+ 4 - 4
x-pack/plugin/esql/qa/testFixtures/src/main/resources/meta.csv-spec

@@ -64,7 +64,7 @@ double pi()
 "double sinh(angle:double|integer|long|unsigned_long)"
 "keyword split(string:keyword|text, delim:keyword|text)"
 "double sqrt(number:double|integer|long|unsigned_long)"
-"geo_point|cartesian_point st_centroid(field:geo_point|cartesian_point)"
+"geo_point|cartesian_point st_centroid_agg(field:geo_point|cartesian_point)"
 "boolean st_contains(geomA:geo_point|cartesian_point|geo_shape|cartesian_shape, geomB:geo_point|cartesian_point|geo_shape|cartesian_shape)"
 "boolean st_disjoint(geomA:geo_point|cartesian_point|geo_shape|cartesian_shape, geomB:geo_point|cartesian_point|geo_shape|cartesian_shape)"
 "boolean st_intersects(geomA:geo_point|cartesian_point|geo_shape|cartesian_shape, geomB:geo_point|cartesian_point|geo_shape|cartesian_shape)"
@@ -174,7 +174,7 @@ sin           |angle                               |"double|integer|long|unsigne
 sinh          |angle                               |"double|integer|long|unsigned_long"                                                                                               |An angle, in radians. If `null`, the function returns `null`.
 split         |[string, delim]                     |["keyword|text", "keyword|text"]                                                                                                  |[, ]
 sqrt          |number                              |"double|integer|long|unsigned_long"                                                                                               |[""]
-st_centroid   |field                               |"geo_point|cartesian_point"                                                                                                       |[""]
+st_centroid_ag|field                               |"geo_point|cartesian_point"                                                                                                       |[""]
 st_contains   |[geomA, geomB]                      |["geo_point|cartesian_point|geo_shape|cartesian_shape", "geo_point|cartesian_point|geo_shape|cartesian_shape"]                    |[Geometry column name or variable of geometry type, Geometry column name or variable of geometry type]
 st_disjoint   |[geomA, geomB]                      |["geo_point|cartesian_point|geo_shape|cartesian_shape", "geo_point|cartesian_point|geo_shape|cartesian_shape"]                    |[Geometry column name or variable of geometry type, Geometry column name or variable of geometry type]
 st_intersects |[geomA, geomB]                      |["geo_point|cartesian_point|geo_shape|cartesian_shape", "geo_point|cartesian_point|geo_shape|cartesian_shape"]                    |[Geometry column name or variable of geometry type, Geometry column name or variable of geometry type]
@@ -285,7 +285,7 @@ sin           |Returns ths {wikipedia}/Sine_and_cosine[Sine] trigonometric funct
 sinh          |Returns the {wikipedia}/Hyperbolic_functions[hyperbolic sine] of an angle.
 split         |Split a single valued string into multiple strings.
 sqrt          |Returns the square root of a number.
-st_centroid   |The centroid of a spatial field.
+st_centroid_ag|The centroid of a spatial field.
 st_contains   |Returns whether the first geometry contains the second geometry.
 st_disjoint   |Returns whether the two geometries or geometry columns are disjoint.
 st_intersects |Returns whether the two geometries or geometry columns intersect.
@@ -397,7 +397,7 @@ sin           |double
 sinh          |double                                                                                                                      |false                       |false           |false
 split         |keyword                                                                                                                     |[false, false]              |false           |false
 sqrt          |double                                                                                                                      |false                       |false           |false
-st_centroid   |"geo_point|cartesian_point"                                                                                                 |false                       |false           |true
+st_centroid_ag|"geo_point|cartesian_point"                                                                                                 |false                       |false           |true
 st_contains   |boolean                                                                                                                     |[false, false]              |false           |false
 st_disjoint   |boolean                                                                                                                     |[false, false]              |false           |false
 st_intersects |boolean                                                                                                                     |[false, false]              |false           |false

+ 93 - 93
x-pack/plugin/esql/qa/testFixtures/src/main/resources/spatial.csv-spec

@@ -38,46 +38,46 @@ wkt:keyword
 ;
 
 centroidFromStringNested
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 row wkt = "POINT(42.97109629958868 14.7552534006536)"
-| STATS c = ST_CENTROID(TO_GEOPOINT(wkt));
+| STATS c = ST_CENTROID_AGG(TO_GEOPOINT(wkt));
 
 c:geo_point
 POINT(42.97109629958868 14.7552534006536)
 ;
 
 centroidFromString1
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 ROW wkt = ["POINT(42.97109629958868 14.7552534006536)"]
 | MV_EXPAND wkt
 | EVAL pt = TO_GEOPOINT(wkt)
-| STATS c = ST_CENTROID(pt);
+| STATS c = ST_CENTROID_AGG(pt);
 
 c:geo_point
 POINT(42.97109629958868 14.7552534006536)
 ;
 
 centroidFromString2
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 ROW wkt = ["POINT(42.97109629958868 14.7552534006536)", "POINT(75.80929149873555 22.72774917539209)"]
 | MV_EXPAND wkt
 | EVAL pt = TO_GEOPOINT(wkt)
-| STATS c = ST_CENTROID(pt);
+| STATS c = ST_CENTROID_AGG(pt);
 
 c:geo_point
 POINT(59.390193899162114 18.741501288022846)
 ;
 
 centroidFromString3
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 ROW wkt = ["POINT(42.97109629958868 14.7552534006536)", "POINT(75.80929149873555 22.72774917539209)", "POINT(-0.030548143003023033 24.37553649504829)"]
 | MV_EXPAND wkt
 | EVAL pt = TO_GEOPOINT(wkt)
-| STATS c = ST_CENTROID(pt);
+| STATS c = ST_CENTROID_AGG(pt);
 
 c:geo_point
 POINT(39.58327988510707 20.619513023697994)
@@ -89,7 +89,7 @@ required_feature: esql.st_x_y
 ROW wkt = ["POINT(42.97109629958868 14.7552534006536)", "POINT(75.80929149873555 22.72774917539209)", "POINT(-0.030548143003023033 24.37553649504829)"]
 | MV_EXPAND wkt
 | EVAL pt = TO_GEOPOINT(wkt)
-| STATS c = ST_CENTROID(pt)
+| STATS c = ST_CENTROID_AGG(pt)
 | EVAL x = ST_X(c), y = ST_Y(c);
 
 c:geo_point                                 | x:double          | y:double
@@ -149,25 +149,25 @@ c:long  | x:double  | y:double
 # Tests for ST_CENTROID on GEO_POINT type
 
 centroidFromAirports
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
-// tag::st_centroid-airports[]
+// tag::st_centroid_agg-airports[]
 FROM airports
-| STATS centroid=ST_CENTROID(location)
-// end::st_centroid-airports[]
+| STATS centroid=ST_CENTROID_AGG(location)
+// end::st_centroid_agg-airports[]
 ;
 
-// tag::st_centroid-airports-result[]
+// tag::st_centroid_agg-airports-result[]
 centroid:geo_point
 POINT(-0.030548143003023033 24.37553649504829)
-// end::st_centroid-airports-result[]
+// end::st_centroid_agg-airports-result[]
 ;
 
 centroidFromAirportsNested
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
-| STATS centroid=ST_CENTROID(TO_GEOPOINT(location))
+| STATS centroid=ST_CENTROID_AGG(TO_GEOPOINT(location))
 ;
 
 centroid:geo_point
@@ -175,10 +175,10 @@ POINT (-0.03054810272375508 24.37553651570554)
 ;
 
 centroidFromAirportsCount
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:geo_point                             | count:long
@@ -186,10 +186,10 @@ POINT(-0.030548143003023033 24.37553649504829) | 891
 ;
 
 centroidFromAirportsCountGrouped
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
-| STATS centroid=ST_CENTROID(location), count=COUNT() BY scalerank
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT() BY scalerank
 | SORT scalerank DESC
 ;
 
@@ -205,11 +205,11 @@ POINT(1.2588642098541771 24.379140841774642)  | 63         | 2
 ;
 
 centroidFromAirportsFiltered
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
 | WHERE scalerank == 9
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:geo_point                         | count:long
@@ -217,11 +217,11 @@ POINT(83.27726172452623 28.99289782286029) | 33
 ;
 
 centroidFromAirportsCountGroupedCentroid
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
-| STATS centroid=ST_CENTROID(location), count=COUNT() BY scalerank
-| STATS centroid=ST_CENTROID(centroid), count=SUM(count)
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT() BY scalerank
+| STATS centroid=ST_CENTROID_AGG(centroid), count=SUM(count)
 ;
 
 centroid:geo_point                           | count:long
@@ -229,10 +229,10 @@ POINT (7.572387259169772 26.836561792945492) | 891
 ;
 
 centroidFromAirportsCountCityLocations
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
-| STATS centroid=ST_CENTROID(city_location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(city_location), count=COUNT()
 ;
 
 centroid:geo_point                            | count:long
@@ -240,10 +240,10 @@ POINT (1.3965610809060276 24.127649406297987) | 891
 ;
 
 centroidFromAirportsCountGroupedCountry
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
-| STATS centroid=ST_CENTROID(city_location), count=COUNT() BY country
+| STATS centroid=ST_CENTROID_AGG(city_location), count=COUNT() BY country
 | SORT count DESC, country ASC
 | WHERE count >= 10
 ;
@@ -269,11 +269,11 @@ POINT (70.7946499697864 30.69746997440234)     | 10         | Pakistan
 ;
 
 centroidFromAirportsFilteredCountry
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
 | WHERE country == "United States"
-| STATS centroid=ST_CENTROID(city_location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(city_location), count=COUNT()
 ;
 
 centroid:geo_point                          | count:long
@@ -281,11 +281,11 @@ POINT (-97.3333946136801 38.07953176370194) | 129
 ;
 
 centroidFromAirportsCountGroupedCountryCentroid
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
-| STATS centroid=ST_CENTROID(city_location), count=COUNT() BY country
-| STATS centroid=ST_CENTROID(centroid), count=SUM(count)
+| STATS centroid=ST_CENTROID_AGG(city_location), count=COUNT() BY country
+| STATS centroid=ST_CENTROID_AGG(centroid), count=SUM(count)
 ;
 
 centroid:geo_point                            | count:long
@@ -293,10 +293,10 @@ POINT (17.55538044598613 18.185558743854063)  | 891
 ;
 
 centroidFromAirportsCountryCount
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
-| STATS airports=ST_CENTROID(location), cities=ST_CENTROID(city_location), count=COUNT()
+| STATS airports=ST_CENTROID_AGG(location), cities=ST_CENTROID_AGG(city_location), count=COUNT()
 ;
 
 airports:geo_point                             | cities:geo_point                              | count:long
@@ -304,13 +304,13 @@ POINT(-0.030548143003023033 24.37553649504829) | POINT (1.3965610809060276 24.12
 ;
 
 centroidFromAirportsFilteredAndSorted
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
 | WHERE scalerank == 9
 | SORT abbrev
 | WHERE length(name) > 12
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:geo_point                          | count:long
@@ -318,11 +318,11 @@ POINT(78.73736493755132 26.761841227998957) | 12
 ;
 
 centroidFromAirportsAfterMvExpand
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
 | MV_EXPAND type
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:geo_point                          | count:long
@@ -330,11 +330,11 @@ POINT(2.121611400672094 24.559172889205755) | 933
 ;
 
 centroidFromAirportsGroupedAfterMvExpand
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
 | MV_EXPAND type
-| STATS centroid=ST_CENTROID(location), count=COUNT() BY scalerank
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT() BY scalerank
 | SORT scalerank DESC
 ;
 
@@ -350,12 +350,12 @@ POINT(1.2588642098541771 24.379140841774642)  | 63         | 2
 ;
 
 centroidFromAirportsGroupedAfterMvExpandFiltered
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
 | WHERE scalerank == 9
 | MV_EXPAND type
-| STATS centroid=ST_CENTROID(location), count=COUNT() BY scalerank
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT() BY scalerank
 ;
 
 centroid:geo_point                            | count:long | scalerank:i
@@ -363,12 +363,12 @@ POINT(83.16847535921261 28.79002037679311)    | 40         | 9
 ;
 
 centroidFromAirportsAfterMvExpandFiltered
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
 | WHERE scalerank == 9
 | MV_EXPAND type
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:geo_point                            | count:long
@@ -376,11 +376,11 @@ POINT(83.16847535921261 28.79002037679311)    | 40
 ;
 
 centroidFromAirportsAfterKeywordPredicateCountryUK
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports
 | WHERE country == "United Kingdom"
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:geo_point                              | count:long
@@ -392,7 +392,7 @@ required_feature: esql.st_intersects
 
 FROM airports
 | WHERE ST_INTERSECTS(location, TO_GEOSHAPE("POLYGON((1.2305 60.8449, -1.582 61.6899, -10.7227 58.4017, -7.1191 55.3291, -7.9102 54.2139, -5.4492 54.0078, -5.2734 52.3756, -7.8223 49.6676, -5.0977 49.2678, 0.9668 50.5134, 2.5488 52.1065, 2.6367 54.0078, -0.9668 56.4625, 1.2305 60.8449))"))
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:geo_point                              | count:long
@@ -404,7 +404,7 @@ required_feature: esql.st_contains_within
 
 FROM airports
 | WHERE ST_CONTAINS(TO_GEOSHAPE("POLYGON((1.2305 60.8449, -1.582 61.6899, -10.7227 58.4017, -7.1191 55.3291, -7.9102 54.2139, -5.4492 54.0078, -5.2734 52.3756, -7.8223 49.6676, -5.0977 49.2678, 0.9668 50.5134, 2.5488 52.1065, 2.6367 54.0078, -0.9668 56.4625, 1.2305 60.8449))"), location)
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:geo_point                              | count:long
@@ -416,7 +416,7 @@ required_feature: esql.st_contains_within
 
 FROM airports
 | WHERE ST_WITHIN(location, TO_GEOSHAPE("POLYGON((1.2305 60.8449, -1.582 61.6899, -10.7227 58.4017, -7.1191 55.3291, -7.9102 54.2139, -5.4492 54.0078, -5.2734 52.3756, -7.8223 49.6676, -5.0977 49.2678, 0.9668 50.5134, 2.5488 52.1065, 2.6367 54.0078, -0.9668 56.4625, 1.2305 60.8449))"))
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:geo_point                              | count:long
@@ -428,7 +428,7 @@ required_feature: esql.st_intersects
 
 FROM airports
 | WHERE country == "United Kingdom"
-| STATS centroid = ST_CENTROID(location), count=COUNT()
+| STATS centroid = ST_CENTROID_AGG(location), count=COUNT()
 | EVAL centroid_in_uk = ST_INTERSECTS(centroid, TO_GEOSHAPE("POLYGON((1.2305 60.8449, -1.582 61.6899, -10.7227 58.4017, -7.1191 55.3291, -7.9102 54.2139, -5.4492 54.0078, -5.2734 52.3756, -7.8223 49.6676, -5.0977 49.2678, 0.9668 50.5134, 2.5488 52.1065, 2.6367 54.0078, -0.9668 56.4625, 1.2305 60.8449))"))
 | EVAL centroid_in_iceland = ST_INTERSECTS(centroid, TO_GEOSHAPE("POLYGON ((-25.4883 65.5312, -23.4668 66.7746, -18.4131 67.4749, -13.0957 66.2669, -12.3926 64.4159, -20.1270 62.7346, -24.7852 63.3718, -25.4883 65.5312))"))
 | EVAL centroid_within_uk = ST_WITHIN(centroid, TO_GEOSHAPE("POLYGON((1.2305 60.8449, -1.582 61.6899, -10.7227 58.4017, -7.1191 55.3291, -7.9102 54.2139, -5.4492 54.0078, -5.2734 52.3756, -7.8223 49.6676, -5.0977 49.2678, 0.9668 50.5134, 2.5488 52.1065, 2.6367 54.0078, -0.9668 56.4625, 1.2305 60.8449))"))
@@ -450,7 +450,7 @@ FROM airports
 | EVAL in_iceland = ST_INTERSECTS(location, TO_GEOSHAPE("POLYGON ((-25.4883 65.5312, -23.4668 66.7746, -18.4131 67.4749, -13.0957 66.2669, -12.3926 64.4159, -20.1270 62.7346, -24.7852 63.3718, -25.4883 65.5312))"))
 | EVAL within_uk = ST_WITHIN(location, TO_GEOSHAPE("POLYGON((1.2305 60.8449, -1.582 61.6899, -10.7227 58.4017, -7.1191 55.3291, -7.9102 54.2139, -5.4492 54.0078, -5.2734 52.3756, -7.8223 49.6676, -5.0977 49.2678, 0.9668 50.5134, 2.5488 52.1065, 2.6367 54.0078, -0.9668 56.4625, 1.2305 60.8449))"))
 | EVAL within_iceland = ST_WITHIN(location, TO_GEOSHAPE("POLYGON ((-25.4883 65.5312, -23.4668 66.7746, -18.4131 67.4749, -13.0957 66.2669, -12.3926 64.4159, -20.1270 62.7346, -24.7852 63.3718, -25.4883 65.5312))"))
-| STATS centroid = ST_CENTROID(location), count=COUNT() BY in_uk, in_iceland, within_uk, within_iceland
+| STATS centroid = ST_CENTROID_AGG(location), count=COUNT() BY in_uk, in_iceland, within_uk, within_iceland
 | SORT count ASC
 ;
 
@@ -465,7 +465,7 @@ required_feature: esql.st_intersects
 
 FROM airports
 | WHERE ST_INTERSECTS(location, TO_GEOSHAPE("POLYGON((42 14, 43 14, 43 15, 42 15, 42 14))"))
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:geo_point                            | count:long
@@ -477,7 +477,7 @@ required_feature: esql.st_intersects
 
 FROM airports
 | WHERE scalerank == 9 AND ST_INTERSECTS(location, TO_GEOSHAPE("POLYGON((42 14, 43 14, 43 15, 42 15, 42 14))")) AND country == "Yemen"
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:geo_point                            | count:long
@@ -598,7 +598,7 @@ required_feature: esql.st_intersects
 
 FROM airports_mp
 | WHERE ST_INTERSECTS(location, city_location)
-| STATS location=ST_CENTROID(location), city_location=ST_CENTROID(city_location), count=COUNT()
+| STATS location=ST_CENTROID_AGG(location), city_location=ST_CENTROID_AGG(city_location), count=COUNT()
 ;
 
 location:geo_point  | city_location:geo_point  |  count:long
@@ -683,7 +683,7 @@ required_feature: esql.st_disjoint
 
 FROM airports_mp
 | WHERE ST_DISJOINT(location, city_location)
-| STATS location=ST_CENTROID(location), city_location=ST_CENTROID(city_location), count=COUNT()
+| STATS location=ST_CENTROID_AGG(location), city_location=ST_CENTROID_AGG(city_location), count=COUNT()
 ;
 
 location:geo_point                         | city_location:geo_point                      |  count:long
@@ -776,7 +776,7 @@ required_feature: esql.st_contains_within
 
 FROM airports_mp
 | WHERE ST_CONTAINS(location, city_location)
-| STATS location=ST_CENTROID(location), city_location=ST_CENTROID(city_location), count=COUNT()
+| STATS location=ST_CENTROID_AGG(location), city_location=ST_CENTROID_AGG(city_location), count=COUNT()
 ;
 
 location:geo_point  | city_location:geo_point  |  count:long
@@ -863,7 +863,7 @@ required_feature: esql.st_contains_within
 
 FROM airports_mp
 | WHERE ST_WITHIN(location, city_location)
-| STATS location=ST_CENTROID(location), city_location=ST_CENTROID(city_location), count=COUNT()
+| STATS location=ST_CENTROID_AGG(location), city_location=ST_CENTROID_AGG(city_location), count=COUNT()
 ;
 
 location:geo_point  | city_location:geo_point  |  count:long
@@ -963,46 +963,46 @@ wkt:keyword                                           |pt:cartesian_point
 ;
 
 centroidCartesianFromStringNested
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 row wkt = "POINT(4297.10986328125 -1475.530029296875)"
-| STATS c = ST_CENTROID(TO_CARTESIANPOINT(wkt));
+| STATS c = ST_CENTROID_AGG(TO_CARTESIANPOINT(wkt));
 
 c:cartesian_point
 POINT(4297.10986328125 -1475.530029296875)
 ;
 
 centroidFromCartesianString1
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 ROW wkt = ["POINT(4297.10986328125 -1475.530029296875)"]
 | MV_EXPAND wkt
 | EVAL pt = TO_CARTESIANPOINT(wkt)
-| STATS c = ST_CENTROID(pt);
+| STATS c = ST_CENTROID_AGG(pt);
 
 c:cartesian_point
 POINT(4297.10986328125 -1475.530029296875)
 ;
 
 centroidFromCartesianString2
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 ROW wkt = ["POINT(4297.10986328125 -1475.530029296875)", "POINT(7580.93017578125 2272.77001953125)"]
 | MV_EXPAND wkt
 | EVAL pt = TO_CARTESIANPOINT(wkt)
-| STATS c = ST_CENTROID(pt);
+| STATS c = ST_CENTROID_AGG(pt);
 
 c:cartesian_point
 POINT(5939.02001953125 398.6199951171875)
 ;
 
 centroidFromCartesianString3
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 ROW wkt = ["POINT(4297.10986328125 -1475.530029296875)", "POINT(7580.93017578125 2272.77001953125)", "POINT(-30.548143003023033 2437.553649504829)"]
 | MV_EXPAND wkt
 | EVAL pt = TO_CARTESIANPOINT(wkt)
-| STATS c = ST_CENTROID(pt);
+| STATS c = ST_CENTROID_AGG(pt);
 
 c:cartesian_point
 POINT(3949.163965353159 1078.2645465797348)
@@ -1039,30 +1039,30 @@ ZAH            | POINT (6779435.866395892 3436280.545331025)   | Zahedan Int'l
 # Tests for ST_CENTROID on CARTESIAN_POINT type
 
 cartesianCentroidFromAirports
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports_web
-| STATS centroid=ST_CENTROID(location);
+| STATS centroid=ST_CENTROID_AGG(location);
 
 centroid:cartesian_point
 POINT(-266681.67563861894 3053301.5120195406)
 ;
 
 cartesianCentroidFromAirportsNested
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports_web
-| STATS centroid=ST_CENTROID(TO_CARTESIANPOINT(location));
+| STATS centroid=ST_CENTROID_AGG(TO_CARTESIANPOINT(location));
 
 centroid:cartesian_point
 POINT (-266681.66530554957 3053301.506061676)
 ;
 
 cartesianCentroidFromAirportsCount
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports_web
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:cartesian_point                      | count:long
@@ -1070,10 +1070,10 @@ POINT(-266681.67563861894 3053301.5120195406) | 849
 ;
 
 cartesianCentroidFromAirportsCountGrouped
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports_web
-| STATS centroid=ST_CENTROID(location), count=COUNT() BY scalerank
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT() BY scalerank
 | SORT scalerank DESC
 ;
 
@@ -1089,11 +1089,11 @@ POINT(140136.12878224207 3081220.7881944445)  | 63         | 2
 ;
 
 cartesianCentroidFromAirportsFiltered
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports_web
 | WHERE scalerank == 9
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:cartesian_point                    | count:long
@@ -1101,13 +1101,13 @@ POINT(9289013.153846154 3615537.0533353365) | 26
 ;
 
 cartesianCentroidFromAirportsFilteredAndSorted
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports_web
 | WHERE scalerank == 9
 | SORT abbrev
 | WHERE length(name) > 12
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:cartesian_point            | count:long
@@ -1115,11 +1115,11 @@ POINT(9003597.4375 3429344.0078125) | 8
 ;
 
 cartesianCentroidFromAirportsCountGroupedCentroid
-required_feature: esql.st_centroid
+required_feature: esql.st_centroid_agg
 
 FROM airports_web
-| STATS centroid=ST_CENTROID(location), count=COUNT() BY scalerank
-| STATS centroid=ST_CENTROID(centroid), count=SUM(count)
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT() BY scalerank
+| STATS centroid=ST_CENTROID_AGG(centroid), count=SUM(count)
 ;
 
 centroid:cartesian_point                    | count:long
@@ -1134,7 +1134,7 @@ required_feature: esql.st_intersects
 
 FROM airports_web
 | WHERE ST_INTERSECTS(location, TO_CARTESIANSHAPE("POLYGON((4700000 1600000, 4800000 1600000, 4800000 1700000, 4700000 1700000, 4700000 1600000))"))
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:cartesian_point     | count:long
@@ -1233,7 +1233,7 @@ required_feature: esql.st_intersects
 
 FROM airports_web
 | WHERE ST_INTERSECTS(location, TO_CARTESIANSHAPE("POINT(4783520.559160681 1661010.0197476079)"))
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:cartesian_point    | count:long
@@ -1245,7 +1245,7 @@ required_feature: esql.st_intersects
 
 FROM airports_web
 | WHERE ST_INTERSECTS(location, TO_CARTESIANPOINT("POINT(4783520.559160681 1661010.0197476079)"))
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:cartesian_point    | count:long
@@ -1402,7 +1402,7 @@ required_feature: esql.st_contains_within
 
 FROM airports_web
 | WHERE ST_CONTAINS(TO_CARTESIANSHAPE("POLYGON((4700000 1600000, 4800000 1600000, 4800000 1700000, 4700000 1700000, 4700000 1600000))"), location)
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:cartesian_point     | count:long
@@ -1439,7 +1439,7 @@ required_feature: esql.st_contains_within
 
 FROM airports_web
 | WHERE ST_CONTAINS(location, TO_CARTESIANSHAPE("POLYGON((4700000 1600000, 4800000 1600000, 4800000 1700000, 4700000 1700000, 4700000 1600000))"))
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:cartesian_point     | count:long
@@ -1528,7 +1528,7 @@ required_feature: esql.st_intersects
 
 FROM airports_web
 | WHERE ST_CONTAINS(location, TO_CARTESIANSHAPE("POINT(4783520.559160681 1661010.0197476079)"))
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:cartesian_point    | count:long
@@ -1540,7 +1540,7 @@ required_feature: esql.st_intersects
 
 FROM airports_web
 | WHERE ST_CONTAINS(location, TO_CARTESIANPOINT("POINT(4783520.559160681 1661010.0197476079)"))
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:cartesian_point    | count:long
@@ -1555,7 +1555,7 @@ required_feature: esql.st_contains_within
 
 FROM airports_web
 | WHERE ST_WITHIN(location, TO_CARTESIANSHAPE("POLYGON((4700000 1600000, 4800000 1600000, 4800000 1700000, 4700000 1700000, 4700000 1600000))"))
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:cartesian_point     | count:long
@@ -1654,7 +1654,7 @@ required_feature: esql.st_intersects
 
 FROM airports_web
 | WHERE ST_WITHIN(location, TO_CARTESIANSHAPE("POINT(4783520.559160681 1661010.0197476079)"))
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:cartesian_point    | count:long
@@ -1666,7 +1666,7 @@ required_feature: esql.st_intersects
 
 FROM airports_web
 | WHERE ST_WITHIN(location, TO_CARTESIANPOINT("POINT(4783520.559160681 1661010.0197476079)"))
-| STATS centroid=ST_CENTROID(location), count=COUNT()
+| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
 ;
 
 centroid:cartesian_point    | count:long

+ 1 - 1
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java

@@ -189,7 +189,7 @@ public final class EsqlFunctionRegistry extends FunctionRegistry {
                 def(Now.class, Now::new, "now") },
             // spatial
             new FunctionDefinition[] {
-                def(SpatialCentroid.class, SpatialCentroid::new, "st_centroid"),
+                def(SpatialCentroid.class, SpatialCentroid::new, "st_centroid_agg"),
                 def(SpatialContains.class, SpatialContains::new, "st_contains"),
                 def(SpatialDisjoint.class, SpatialDisjoint::new, "st_disjoint"),
                 def(SpatialIntersects.class, SpatialIntersects::new, "st_intersects"),

+ 2 - 2
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlFeatures.java

@@ -68,7 +68,7 @@ public class EsqlFeatures implements FeatureSpecification {
     /**
      * Support for spatial aggregation {@code ST_CENTROID}. Done in #104269.
      */
-    private static final NodeFeature ST_CENTROID = new NodeFeature("esql.st_centroid");
+    private static final NodeFeature ST_CENTROID_AGG = new NodeFeature("esql.st_centroid_agg");
 
     /**
      * Support for spatial aggregation {@code ST_INTERSECTS}. Done in #104907.
@@ -111,7 +111,7 @@ public class EsqlFeatures implements FeatureSpecification {
             FROM_OPTIONS,
             SPATIAL_POINTS_FROM_SOURCE,
             SPATIAL_SHAPES,
-            ST_CENTROID,
+            ST_CENTROID_AGG,
             ST_INTERSECTS,
             ST_CONTAINS_WITHIN,
             ST_DISJOINT

+ 1 - 1
x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java

@@ -3077,7 +3077,7 @@ public class LogicalPlanOptimizerTests extends ESTestCase {
     public void testSpatialTypesAndStatsUseDocValues() {
         var plan = planAirports("""
             from test
-            | stats centroid = st_centroid(location)
+            | stats centroid = st_centroid_agg(location)
             """);
 
         var limit = as(plan, Limit.class);

+ 19 - 19
x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/PhysicalPlanOptimizerTests.java

@@ -2286,7 +2286,7 @@ public class PhysicalPlanOptimizerTests extends ESTestCase {
     public void testSpatialTypesAndStatsUseDocValues() {
         var plan = this.physicalPlan("""
             from airports
-            | stats centroid = st_centroid(location)
+            | stats centroid = st_centroid_agg(location)
             """, airports);
 
         var limit = as(plan, LimitExec.class);
@@ -2343,7 +2343,7 @@ public class PhysicalPlanOptimizerTests extends ESTestCase {
     public void testSpatialTypesAndStatsUseDocValuesNested() {
         var plan = this.physicalPlan("""
             from airports
-            | stats centroid = st_centroid(to_geopoint(location))
+            | stats centroid = st_centroid_agg(to_geopoint(location))
             """, airports);
 
         var limit = as(plan, LimitExec.class);
@@ -2404,7 +2404,7 @@ public class PhysicalPlanOptimizerTests extends ESTestCase {
     public void testSpatialTypesAndStatsUseDocValuesNestedLiteral() {
         var plan = this.physicalPlan("""
             row wkt = "POINT(42.97109629958868 14.7552534006536)"
-            | stats centroid = st_centroid(to_geopoint(wkt))
+            | stats centroid = st_centroid_agg(to_geopoint(wkt))
             """, airports);
 
         var limit = as(plan, LimitExec.class);
@@ -2458,7 +2458,7 @@ public class PhysicalPlanOptimizerTests extends ESTestCase {
     public void testSpatialTypesAndStatsUseDocValuesMultiAggregations() {
         var plan = this.physicalPlan("""
             from airports
-            | stats centroid = st_centroid(location), count = COUNT()
+            | stats centroid = st_centroid_agg(location), count = COUNT()
             """, airports);
 
         var limit = as(plan, LimitExec.class);
@@ -2524,7 +2524,7 @@ public class PhysicalPlanOptimizerTests extends ESTestCase {
     public void testSpatialTypesAndStatsUseDocValuesMultiSpatialAggregations() {
         var plan = this.physicalPlan("""
             FROM airports
-            | STATS airports=ST_CENTROID(location), cities=ST_CENTROID(city_location), count=COUNT()
+            | STATS airports=ST_CENTROID_AGG(location), cities=ST_CENTROID_AGG(city_location), count=COUNT()
             """, airports);
 
         var limit = as(plan, LimitExec.class);
@@ -2590,7 +2590,7 @@ public class PhysicalPlanOptimizerTests extends ESTestCase {
         var plan = this.physicalPlan("""
             FROM airports
             | WHERE scalerank == 9
-            | STATS centroid=ST_CENTROID(location), count=COUNT()
+            | STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
             """, airports);
 
         var limit = as(plan, LimitExec.class);
@@ -2657,7 +2657,7 @@ public class PhysicalPlanOptimizerTests extends ESTestCase {
     public void testSpatialTypesAndStatsUseDocValuesMultiAggregationsGrouped() {
         var plan = this.physicalPlan("""
             FROM airports
-            | STATS centroid=ST_CENTROID(location), count=COUNT() BY scalerank
+            | STATS centroid=ST_CENTROID_AGG(location), count=COUNT() BY scalerank
             """, airports);
 
         var limit = as(plan, LimitExec.class);
@@ -2727,8 +2727,8 @@ public class PhysicalPlanOptimizerTests extends ESTestCase {
     public void testSpatialTypesAndStatsUseDocValuesMultiAggregationsGroupedAggregated() {
         var plan = this.physicalPlan("""
             FROM airports
-            | STATS centroid=ST_CENTROID(location), count=COUNT() BY scalerank
-            | STATS centroid=ST_CENTROID(centroid), count=SUM(count)
+            | STATS centroid=ST_CENTROID_AGG(location), count=COUNT() BY scalerank
+            | STATS centroid=ST_CENTROID_AGG(centroid), count=SUM(count)
             """, airports);
 
         var limit = as(plan, LimitExec.class);
@@ -2821,7 +2821,7 @@ public class PhysicalPlanOptimizerTests extends ESTestCase {
         var plan = physicalPlan("""
             from airports
             | enrich city_boundaries ON city_location WITH airport, region, city_boundary
-            | stats centroid = st_centroid(city_location)
+            | stats centroid = st_centroid_agg(city_location)
             """, airports);
 
         var limit = as(plan, LimitExec.class);
@@ -3049,7 +3049,7 @@ public class PhysicalPlanOptimizerTests extends ESTestCase {
             new TestSpatialRelation(ShapeRelation.CONTAINS, airportsWeb, true, true),
             new TestSpatialRelation(ShapeRelation.CONTAINS, airportsWeb, false, true) };
         for (TestSpatialRelation test : tests) {
-            var centroidExpr = "centroid=ST_CENTROID(location), count=COUNT()";
+            var centroidExpr = "centroid=ST_CENTROID_AGG(location), count=COUNT()";
             var plan = this.physicalPlan(
                 "FROM " + test.index.index.name() + " | WHERE " + test.predicate() + " | STATS " + centroidExpr,
                 test.index
@@ -3152,11 +3152,11 @@ public class PhysicalPlanOptimizerTests extends ESTestCase {
         for (String query : new String[] { """
             FROM airports
             | WHERE ST_INTERSECTS(location, TO_GEOSHAPE("POLYGON((42 14, 43 14, 43 15, 42 15, 42 14))"))
-            | STATS centroid=ST_CENTROID(location), count=COUNT()
+            | STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
             """, """
             FROM airports
             | WHERE ST_INTERSECTS(TO_GEOSHAPE("POLYGON((42 14, 43 14, 43 15, 42 15, 42 14))"), location)
-            | STATS centroid=ST_CENTROID(location), count=COUNT()
+            | STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
             """ }) {
 
             var plan = this.physicalPlan(query, airports);
@@ -3253,13 +3253,13 @@ public class PhysicalPlanOptimizerTests extends ESTestCase {
             | WHERE scalerank == 9
               AND ST_INTERSECTS(location, TO_GEOSHAPE("POLYGON((42 14, 43 14, 43 15, 42 15, 42 14))"))
               AND type == "mid"
-            | STATS centroid=ST_CENTROID(location), count=COUNT()
+            | STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
             """, """
             FROM airports
             | WHERE scalerank == 9
               AND ST_INTERSECTS(TO_GEOSHAPE("POLYGON((42 14, 43 14, 43 15, 42 15, 42 14))"), location)
               AND type == "mid"
-            | STATS centroid=ST_CENTROID(location), count=COUNT()
+            | STATS centroid=ST_CENTROID_AGG(location), count=COUNT()
             """ }) {
 
             var plan = this.physicalPlan(query, airports);
@@ -3340,7 +3340,7 @@ public class PhysicalPlanOptimizerTests extends ESTestCase {
         String query = """
             FROM airports
             | WHERE ST_INTERSECTS(location, city_location)
-            | STATS location=ST_CENTROID(location), city_location=ST_CENTROID(city_location), count=COUNT()
+            | STATS location=ST_CENTROID_AGG(location), city_location=ST_CENTROID_AGG(city_location), count=COUNT()
             """;
 
         var plan = this.physicalPlan(query, airports);
@@ -3383,11 +3383,11 @@ public class PhysicalPlanOptimizerTests extends ESTestCase {
         for (String query : new String[] { """
             FROM airports
             | WHERE ST_INTERSECTS(location, city_location)
-            | STATS location=ST_CENTROID(location), count=COUNT()
+            | STATS location=ST_CENTROID_AGG(location), count=COUNT()
             """, """
             FROM airports
             | WHERE ST_INTERSECTS(location, city_location)
-            | STATS city_location=ST_CENTROID(city_location), count=COUNT()
+            | STATS city_location=ST_CENTROID_AGG(city_location), count=COUNT()
             """ }) {
 
             var plan = this.physicalPlan(query, airports);
@@ -3430,7 +3430,7 @@ public class PhysicalPlanOptimizerTests extends ESTestCase {
             FROM airports
             | WHERE ST_INTERSECTS(location, TO_GEOSHAPE("POLYGON((42 14, 43 14, 43 15, 42 15, 42 14))"))
                 AND ST_INTERSECTS(city_location, TO_GEOSHAPE("POLYGON((42 14, 43 14, 43 15, 42 15, 42 14))"))
-            | STATS location=ST_CENTROID(location), city_location=ST_CENTROID(city_location), count=COUNT()
+            | STATS location=ST_CENTROID_AGG(location), city_location=ST_CENTROID_AGG(city_location), count=COUNT()
             """;
 
         var plan = this.physicalPlan(query, airports);