diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/SqlTranslatorHandler.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/SqlTranslatorHandler.java index 277e9da2bc06c..0a29187774dee 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/SqlTranslatorHandler.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/SqlTranslatorHandler.java @@ -37,6 +37,10 @@ public Query asQuery(Expression e) { @Override public Query wrapFunctionQuery(ScalarFunction sf, Expression field, Supplier querySupplier) { if (field instanceof StDistance && querySupplier.get() instanceof GeoDistanceQuery) { + if (true) { + throw new RuntimeException("If this code is not dead, QueryTranslatorTests.testTranslateStDistanceToQuery should " + + "trigger this Exception"); + } return ExpressionTranslator.wrapIfNested(querySupplier.get(), ((StDistance) field).left()); } if (field instanceof FieldAttribute) { diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/planner/QueryTranslatorTests.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/planner/QueryTranslatorTests.java index fd0d46cf67d24..83c1875b33408 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/planner/QueryTranslatorTests.java +++ b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/planner/QueryTranslatorTests.java @@ -1334,6 +1334,7 @@ public void testTranslateStDistanceToQuery() { assertEquals(20.0, gq.lat(), 0.00001); assertEquals(10.0, gq.lon(), 0.00001); assertEquals(25.0, gq.distance(), 0.00001); + optimizeAndPlan(p); } public void testTranslateStXY() {