Class SpatialShapeBoundsExtraction


This rule is responsible for marking spatial shape fields whose extent can be extracted from the binary representation encoded by GeometryDocValueWriter. This is a very specific optimization that is only used in the context of ST_EXTENT_AGG aggregations. Normally spatial fields are extracted from source values because this maintains original precision, but is very slow. Simply extracting the spatial bounds from the binary encoding loses both precision and geometry topological information for shapes. For this reason we only consider extract the extent under very specific conditions:
  • The spatial data is of type GEO_SHAPE or CARTESIAN_SHAPE.
  • The spatial data is consumed directly by an ST_EXTENT_AGG.
  • The spatial data is not consumed by any other operation. While is this is stricter than necessary, it is a good enough approximation for now. For example, an aggregation like count shouldn't stop this optimization, not a check like isNotNull.