Class GeoParquetFilterToSQL

Object
FilterToSQL
DuckDBFilterToSQL
GeoParquetFilterToSQL
All Implemented Interfaces:
ExpressionVisitor, FilterVisitor

public class GeoParquetFilterToSQL extends DuckDBFilterToSQL
Filter SQL encoder for GeoParquet queries.

This class extends DuckDBFilterToSQL with GeoParquet-specific optimizations for encoding OGC Filter objects into SQL queries. It handles translation of spatial filters, particularly optimizing bounding box (BBOX) queries to work efficiently with GeoParquet's metadata and structure.

Key features include:

  • Optimized BBOX filter translation that uses GeoParquet's bounding box information
  • Support for the standard set of spatial operations adapted to GeoParquet's spatial model

The implementation specifically targets the column structure and query patterns that perform well with GeoParquet datasets, considering both the GeoParquet specification and DuckDB's spatial capabilities.

  • Constructor Details

    • GeoParquetFilterToSQL

      public GeoParquetFilterToSQL()
  • Method Details

    • setDatasetMetadataSupplier

      public void setDatasetMetadataSupplier(Supplier<GeoparquetDatasetMetadata> supplier)
      Sets the supplier for GeoParquet dataset metadata.

      This supplier is used to access the dataset metadata during filter encoding. It is particularly important for optimizing spatial filters like BBOX by using the bounding box components defined in the metadata.

      Parameters:
      supplier - A supplier that provides access to the GeoParquet dataset metadata
    • toString

      public String toString()
      Returns a string representation of this filter encoder.
      Overrides:
      toString in class Object
      Returns:
      A string representation showing the current SQL output
    • visitBBOX

      protected Object visitBBOX(BBOX filter, Expression leftExp, Expression rightExpt, Object extraData)
      Converts a bounding box filter to optimized SQL using bbox components.

      This method optimizes bounding box queries by using the 'bbox' column components common in GeoParquet datasets. Instead of using expensive spatial functions, it uses simple comparisons on the xmin, xmax, ymin, ymax components, which can be much more efficient.

      The generated SQL follows the pattern: bbox.xmin <= maxX and bbox.xmax >= minX and bbox.ymin <= maxY and bbox.ymax >= minY which implements a proper spatial intersection test using only simple comparisons. The actual column names for the bbox components are resolved from the dataset metadata if available.

      Overrides:
      visitBBOX in class DuckDBFilterToSQL
      Parameters:
      filter - The BBOX filter to encode
      leftExp - The left expression (typically the geometry column)
      rightExpt - The right expression (typically the literal bounding box)
      extraData - Extra data that might be passed through
      Returns:
      The extraData parameter, potentially modified