2022.07

2022.07

  • Imply
  • Ingest
  • Query
  • Visualize
  • Administer
  • Deploy

›Native query components

Overview

  • Querying data
  • Datasources

    • Datasources
    • Joins
    • Lookups
    • Query execution

    Query configuration

    • Query caching
    • Using query caching
    • Query context
  • Enhanced IP support
  • Multi-value dimensions
  • Multitenancy
  • Troubleshooting

Druid SQL

  • Overview and syntax
  • SQL data types
  • Druid SQL Functions

    • All functions
    • Operators
    • Scalar functions
    • Aggregation functions
    • Multi-value string functions
  • SQL metadata tables
  • SQL query context
  • Async SQL download
  • SQL query translation
  • Druid SQL APIs

    • Druid SQL API
    • Async SQL download API
    • JDBC driver API

Native queries

  • Native queries
  • Native query types

    • Timeseries
    • TopN
    • GroupBy
    • Scan
    • Search
    • TimeBoundary
    • SegmentMetadata
    • DatasourceMetadata

    Native query components

    • Filters
    • Granularities
    • Dimensions
    • Aggregations
    • Post-aggregations
    • Expressions
    • Having filters (groupBy)
    • Sorting and limiting (groupBy)
    • Sorting (topN)
    • String comparators
    • Virtual columns
    • Spatial filters

Spatial filters

Apache Druid supports two query languages: Druid SQL and native queries. This document describes functionality that is only available in the native language.

Apache Druid supports filtering specially spatially indexed columns based on an origin and a bound.

Spatial indexing

In any of the data specs, there is the option of providing spatial dimensions. For example, for a JSON data spec, spatial dimensions can be specified as follows:

{
    "type": "hadoop",
    "dataSchema": {
        "dataSource": "DatasourceName",
        "parser": {
            "type": "string",
            "parseSpec": {
                "format": "json",
                "timestampSpec": {
                    "column": "timestamp",
                    "format": "auto"
                },
                "dimensionsSpec": {
                    "dimensions": [],
                    "spatialDimensions": [{
                        "dimName": "coordinates",
                        "dims": ["lat", "long"]
                    }]
                }
            }
        }
    }
}

Spatial filters

propertydescriptionrequired?
dimNameThe name of the spatial dimension. A spatial dimension may be constructed from multiple other dimensions or it may already exist as part of an event. If a spatial dimension already exists, it must be an array of coordinate values.yes
dimsA list of dimension names that comprise a spatial dimension.no

The grammar for a spatial filter is as follows:

"filter" : {
    "type": "spatial",
    "dimension": "spatialDim",
    "bound": {
        "type": "rectangular",
        "minCoords": [10.0, 20.0],
        "maxCoords": [30.0, 40.0]
    }
}

Bound types

rectangular

propertydescriptionrequired?
minCoordsList of minimum dimension coordinates for coordinates [x, y, z, …]yes
maxCoordsList of maximum dimension coordinates for coordinates [x, y, z, …]yes

radius

propertydescriptionrequired?
coordsOrigin coordinates in the form [x, y, z, …]yes
radiusThe float radius valueyes

polygon

propertydescriptionrequired?
abscissaHorizontal coordinate for corners of the polygonyes
ordinateVertical coordinate for corners of the polygonyes
Last updated on 10/3/2020
← Virtual columns
  • Spatial indexing
  • Spatial filters
    • Bound types
2022.07
Key links
Try ImplyApache Druid siteImply GitHub
Get help
Stack OverflowSupportContact us
Learn more
Apache Druid forumsBlog
Copyright © 2022 Imply Data, Inc