6767import static org .hamcrest .Matchers .equalTo ;
6868import static org .hamcrest .Matchers .instanceOf ;
6969import static org .hamcrest .Matchers .matchesRegex ;
70+ import static org .hamcrest .Matchers .startsWith ;
7071
7172//@TestLogging(value = "org.elasticsearch.xpack.esql:TRACE,org.elasticsearch.compute:TRACE", reason = "debug")
7273public class VerifierTests extends ESTestCase {
@@ -1058,9 +1059,6 @@ public void testSpatialSort() {
10581059 "1:136: cannot sort on cartesian_shape" ,
10591060 error (prefix + "| EVAL shape = TO_CARTESIANSHAPE(wkt) | limit 5 | sort shape" )
10601061 );
1061- assertEquals ("1:143: cannot sort on geohash" , error (prefix + "| EVAL grid = ST_GEOHASH(TO_GEOPOINT(wkt),1) | limit 5 | sort grid" ));
1062- assertEquals ("1:143: cannot sort on geotile" , error (prefix + "| EVAL grid = ST_GEOTILE(TO_GEOPOINT(wkt),1) | limit 5 | sort grid" ));
1063- assertEquals ("1:142: cannot sort on geohex" , error (prefix + "| EVAL grid = ST_GEOHEX(TO_GEOPOINT(wkt),1) | limit 5 | sort grid" ));
10641062 var airports = AnalyzerTestUtils .analyzer (loadMapping ("mapping-airports.json" , "airports" ));
10651063 var airportsWeb = AnalyzerTestUtils .analyzer (loadMapping ("mapping-airports_web.json" , "airports_web" ));
10661064 var countriesBbox = AnalyzerTestUtils .analyzer (loadMapping ("mapping-countries_bbox.json" , "countries_bbox" ));
@@ -1069,15 +1067,21 @@ public void testSpatialSort() {
10691067 assertEquals ("1:36: cannot sort on cartesian_point" , error ("FROM airports_web | LIMIT 5 | sort location" , airportsWeb ));
10701068 assertEquals ("1:38: cannot sort on geo_shape" , error ("FROM countries_bbox | LIMIT 5 | sort shape" , countriesBbox ));
10711069 assertEquals ("1:42: cannot sort on cartesian_shape" , error ("FROM countries_bbox_web | LIMIT 5 | sort shape" , countriesBboxWeb ));
1072- assertEquals (
1073- "1:67: cannot sort on geohash" ,
1074- error ("FROM airports | LIMIT 5 | EVAL g = ST_GEOHASH(location, 1) | sort g" , airports )
1075- );
1076- assertEquals (
1077- "1:67: cannot sort on geotile" ,
1078- error ("FROM airports | LIMIT 5 | EVAL g = ST_GEOTILE(location, 1) | sort g" , airports )
1079- );
1080- assertEquals ("1:66: cannot sort on geohex" , error ("FROM airports | LIMIT 5 | EVAL g = ST_GEOHEX(location, 1) | sort g" , airports ));
1070+ for (String grid : new String [] { "geohash" , "geotile" , "geohex" }) {
1071+ String gridFunc = "ST_" + grid .toUpperCase (Locale .ROOT );
1072+ String error = Build .current ().isSnapshot ()
1073+ ? "1:" + (136 + grid .length ()) + ": cannot sort on " + grid
1074+ : "1:95: Unknown function [" + gridFunc + "]" ;
1075+ assertThat (grid , error (prefix + "| EVAL grid = " + gridFunc + "(TO_GEOPOINT(wkt),1) | limit 5 | sort grid" ), startsWith (error ));
1076+ error = Build .current ().isSnapshot ()
1077+ ? "1:" + (63 + grid .length ()) + ": cannot sort on " + grid
1078+ : "1:39: Unknown function [" + gridFunc + "]" ;
1079+ assertThat (
1080+ grid ,
1081+ error ("FROM airports | LIMIT 5 | EVAL grid = " + gridFunc + "(location, 1) | sort grid" , airports ),
1082+ startsWith (error )
1083+ );
1084+ }
10811085 }
10821086
10831087 public void testSourceSorting () {
0 commit comments