Class DruidPlanner
java.lang.Object
org.apache.druid.sql.calcite.planner.DruidPlanner
- All Implemented Interfaces:
Closeable,AutoCloseable
Druid SQL planner. Wraps the underlying Calcite planner with Druid-specific
actions around resource validation and conversion of the Calcite logical
plan into a Druid native query.
The planner is designed to use once: it makes one trip through its lifecycle defined as:
start --> validate [--> prepare] --> plan
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classprotected classstatic enum -
Method Summary
Modifier and TypeMethodDescriptionauthorize(Function<Set<ResourceAction>, AuthorizationResult> authorizer, Set<ResourceAction> extraActions) Authorizes the statement.voidclose()plan()Plan an SQL query for execution, returning aPlannerResultwhich can be used to actually execute the query.prepare()Prepare a SQL query for execution, including some initial parsing and validation and any dynamic parameter type resolution, to support prepared statements via JDBC.static DruidExceptionvoidvalidate()Validates a SQL query and populatesPlannerContext.getResourceActions().
-
Method Details
-
validate
public void validate()Validates a SQL query and populatesPlannerContext.getResourceActions(). -
prepare
Prepare a SQL query for execution, including some initial parsing and validation and any dynamic parameter type resolution, to support prepared statements via JDBC.Prepare reuses the validation done in
validate()which must be called first.A query can be prepared on a data source without having permissions on that data source. This odd state of affairs is necessary because
DruidViewMacroprepares a view while having no information about the user of that view. -
authorize
public DruidPlanner.AuthResult authorize(Function<Set<ResourceAction>, AuthorizationResult> authorizer, Set<ResourceAction> extraActions) Authorizes the statement. Done within the planner to enforce the authorization step within the planner's state machine.- Parameters:
authorizer- a function producesAuthorizationResultbased on resource actions.extraActions- set of additional resource actions beyond those inferred from the query itself. Specifically, the set of context keys to authorize.- Returns:
- the return value from the authorizer
-
plan
Plan an SQL query for execution, returning aPlannerResultwhich can be used to actually execute the query.Ideally, the query can be planned into a native Druid query, but will fall-back to bindable convention if this is not possible.
Planning reuses the validation done in
validate()which must be called first. -
getPlannerContext
-
prepareResult
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
translateException
-