Class BinarySpatialGeometryFunction

All Implemented Interfaces:
NamedWriteable, Writeable, Resolvable, EvaluatorMapper
Direct Known Subclasses:
StDifference, StIntersection, StSymDifference, StUnion

public abstract class BinarySpatialGeometryFunction extends EsqlScalarFunction
Abstract base for spatial functions that combine two geometry arguments and return a new geometry (e.g. ST_UNION, ST_INTERSECTION, ST_DIFFERENCE, ST_SYMDIFFERENCE).

Unlike SpatialRelatesFunction, these functions are not predicates and cannot be pushed down to Lucene. They are expected to appear in EVAL commands and return geo_shape or cartesian_shape results.

Both arguments must be spatial and must share the same coordinate reference system (geo or cartesian). Either or both arguments may be point fields accessed via doc-values; in that case the function is marked using withDocValues(boolean, boolean) during local physical planning so that the correct evaluator variant is chosen.

  • Field Details

    • left

      protected final Expression left
    • leftDocValues

      protected final boolean leftDocValues
    • rightDocValues

      protected final boolean rightDocValues
  • Constructor Details

    • BinarySpatialGeometryFunction

      protected BinarySpatialGeometryFunction(Source source, Expression left, Expression right, boolean leftDocValues, boolean rightDocValues)
  • Method Details

    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Throws:
      IOException
    • left

      public Expression left()
    • right

      public Expression right()
    • leftDocValues

      public boolean leftDocValues()
    • rightDocValues

      public boolean rightDocValues()
    • withDocValues

      public abstract BinarySpatialGeometryFunction withDocValues(boolean foundLeft, boolean foundRight)
      Return a copy of this function with the specified doc-values flags set. Only point types support doc-values access; shape types are always read from source.
    • dataType

      public DataType dataType()
      Description copied from class: Expression
      The DataType returned by executing the tree rooted at this expression. If Expression.typeResolved() returns an error then the behavior of this method is undefined. It may return a valid type. Or it may throw an exception. Or it may return a totally nonsensical type.
      Specified by:
      dataType in class Expression
    • foldable

      public boolean foldable()
      Description copied from class: Expression
      Whether the expression can be evaluated statically, aka "folded", or not.
      Overrides:
      foldable in class Expression
    • fold

      public Object fold(FoldContext ctx)
      Description copied from class: Expression
      Evaluate this expression statically to a constant. It is an error to call this if Expression.foldable() returns false.
      Overrides:
      fold in class EsqlScalarFunction
    • jtsOperation

      protected abstract org.locationtech.jts.geom.Geometry jtsOperation(org.locationtech.jts.geom.Geometry leftGeom, org.locationtech.jts.geom.Geometry rightGeom)
      Apply the concrete JTS geometry operation (union, intersection, difference, or symDifference).
    • resolveType

      protected Expression.TypeResolution resolveType()
      Description copied from class: Expression
      The implementation of Expression.typeResolved(), which is just a caching wrapper around this method. See it's javadoc for what this method should return.

      Implementations will rarely interact with the Expression.TypeResolution class directly, instead usually calling the utility methods on TypeResolutions.

      Implementations should fail if Expression.childrenResolved() returns false.

      Overrides:
      resolveType in class Expression
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Function
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Function