3.0 KiB
id | title | sidebar_label |
---|---|---|
sql | Druid SQL overview | Druid SQL overview |
Apache Druid supports two query languages: Druid SQL and native queries. This document describes the SQL language.
You can query data in Druid datasources using Druid SQL. Druid uses Apache Calcite to parse and plan SQL queries. Druid translates SQL statements into its native JSON-based query language. Other than the slight overhead of translating SQL on the Broker, there isn't an additional performance penalty to using Druid SQL compared to native queries.
Druid SQL planning occurs on the Broker. Set Broker runtime properties to configure the query plan and JDBC querying.
See Defining SQL permissions for information on permissions needed to make SQL queries.
Unsupported features
Druid does not support all SQL features. In particular, the following features are not supported.
- JOIN between native datasources (table, lookup, subquery) and system tables.
- JOIN conditions that are not an equality between expressions from the left- and right-hand sides.
- JOIN conditions containing a constant value inside the condition.
- JOIN conditions on a column which contains a multi-value dimension.
- OVER clauses, and analytic functions such as
LAG
andLEAD
. - ORDER BY for a non-aggregating query, except for
ORDER BY __time
orORDER BY __time DESC
, which are supported. This restriction only applies to non-aggregating queries; you can ORDER BY any column in an aggregating query. - DDL and DML.
- Using Druid-specific functions like
TIME_PARSE
andAPPROX_QUANTILE_DS
on system tables.
Additionally, some Druid native query features are not supported by the SQL language. Some unsupported Druid features include:
- Inline datasources.
- Spatial filters.
- Multi-value dimensions are only partially implemented in Druid SQL. There are known inconsistencies between their behavior in SQL queries and in native queries due to how they are currently treated by the SQL planner.