From 9fc11a555fad3c636edff71b5a1b84d0cdc5e1c0 Mon Sep 17 00:00:00 2001 From: Andras Palinkas Date: Thu, 18 Feb 2021 17:46:48 -0500 Subject: [PATCH] Tests that code is dead within the SqlTranslatorHandler --- .../elasticsearch/xpack/sql/planner/SqlTranslatorHandler.java | 4 ++++ .../elasticsearch/xpack/sql/planner/QueryTranslatorTests.java | 1 + 2 files changed, 5 insertions(+) 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() {