Skip to content

Commit 625d918

Browse files
committed
Disable broken lucene pushdown
1 parent 252f539 commit 625d918

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/BinarySpatialFunction.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,19 @@ public TranslationAware.Translatable translatable(LucenePushdownPredicates pushd
297297
// The use of foldable here instead of SpatialEvaluatorFieldKey.isConstant is intentional to match the behavior of the
298298
// Lucene pushdown code in EsqlTranslationHandler::SpatialRelatesTranslator
299299
// We could enhance both places to support ReferenceAttributes that refer to constants, but that is a larger change
300-
return isPushableSpatialAttribute(left(), pushdownPredicates) && right().foldable()
301-
|| isPushableSpatialAttribute(right(), pushdownPredicates) && left().foldable()
300+
return isPushableSpatialAttribute(left(), pushdownPredicates) && isPushableLiteralAttribute(right())
301+
|| isPushableSpatialAttribute(right(), pushdownPredicates) && isPushableLiteralAttribute(left())
302302
? TranslationAware.Translatable.YES
303303
: TranslationAware.Translatable.NO;
304304

305305
}
306306

307307
private static boolean isPushableSpatialAttribute(Expression exp, LucenePushdownPredicates p) {
308-
return exp instanceof FieldAttribute fa
309-
&& DataType.isSpatialAndGrid(fa.dataType())
310-
&& fa.getExactInfo().hasExact()
311-
&& p.isIndexed(fa);
308+
return exp instanceof FieldAttribute fa && DataType.isSpatial(fa.dataType()) && fa.getExactInfo().hasExact() && p.isIndexed(fa);
309+
}
310+
311+
private static boolean isPushableLiteralAttribute(Expression exp) {
312+
// TODO: Support pushdown of geo-grid queries where the constant is a geo-grid-id literal
313+
return DataType.isSpatial(exp.dataType()) && exp.foldable();
312314
}
313315
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialRelatesFunction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ private Query translate(TranslatorHandler handler, Expression spatialExpression,
316316
String name = handler.nameOf(attribute);
317317

318318
try {
319+
// TODO: Support geo-grid query pushdown
319320
Geometry shape = SpatialRelatesUtils.makeGeometryFromLiteral(FoldContext.small() /* TODO remove me */, constantExpression);
320321
return new SpatialRelatesQuery(source(), name, queryRelation(), shape, attribute.dataType());
321322
} catch (IllegalArgumentException e) {

0 commit comments

Comments
 (0)