Package org.apache.druid.sql.calcite.run
Interface SqlEngine
- All Known Implementing Classes:
NativeSqlEngine,ViewSqlEngine
public interface SqlEngine
Engine for running SQL queries.
-
Method Summary
Modifier and TypeMethodDescriptionbuildQueryMakerForInsert(IngestDestination destination, org.apache.calcite.rel.RelRoot relRoot, PlannerContext plannerContext) Create aQueryMakerfor an INSERT ...buildQueryMakerForSelect(org.apache.calcite.rel.RelRoot relRoot, PlannerContext plannerContext) Create aQueryMakerfor a SELECT query.default voidcancelQuery(PlannerContext plannerContext, QueryScheduler queryScheduler) Cancels a currently running query given thePlannerContextfor the query.booleanfeatureAvailable(EngineFeature feature) Whether a feature applies to this engine or not.default GetQueriesResponsegetQueries(boolean selfOnly, boolean includeComplete, AuthenticationResult authenticationResult, AuthorizationResult stateReadAuthorization) Returns a list ofQueryInfocontaining the currently running queries using this engine.default GetQueryReportResponsegetQueryReport(String sqlQueryId, boolean selfOnly, AuthenticationResult authenticationResult, AuthorizationResult stateReadAuthorization) Retrieves the report for a query, if available.Returns aSqlStatementFactorywhich uses this engine to create statements.default voidinitContextMap(Map<String, Object> contextMap) Enables the engine to make changes to the Context.name()Name of this engine.org.apache.calcite.rel.type.RelDataTyperesultTypeForInsert(org.apache.calcite.rel.type.RelDataTypeFactory typeFactory, org.apache.calcite.rel.type.RelDataType validatedRowType, Map<String, Object> queryContext) SQL row type that would be emitted by theQueryMakerfrombuildQueryMakerForInsert(org.apache.druid.sql.destination.IngestDestination, org.apache.calcite.rel.RelRoot, org.apache.druid.sql.calcite.planner.PlannerContext).org.apache.calcite.rel.type.RelDataTyperesultTypeForSelect(org.apache.calcite.rel.type.RelDataTypeFactory typeFactory, org.apache.calcite.rel.type.RelDataType validatedRowType, Map<String, Object> queryContext) SQL row type that would be emitted by theQueryMakerfrombuildQueryMakerForSelect(org.apache.calcite.rel.RelRoot, org.apache.druid.sql.calcite.planner.PlannerContext).voidvalidateContext(Map<String, Object> queryContext) Validates a provided query context.
-
Method Details
-
name
String name()Name of this engine. Appears in user-visible messages. -
featureAvailable
Whether a feature applies to this engine or not. Most callers should usePlannerContext.featureAvailable(EngineFeature)instead, which also checks feature flags in context parameters. -
validateContext
Validates a provided query context. Returns quietly if the context is OK; throwsValidationExceptionif the context has a problem. -
resultTypeForSelect
org.apache.calcite.rel.type.RelDataType resultTypeForSelect(org.apache.calcite.rel.type.RelDataTypeFactory typeFactory, org.apache.calcite.rel.type.RelDataType validatedRowType, Map<String, Object> queryContext) SQL row type that would be emitted by theQueryMakerfrombuildQueryMakerForSelect(org.apache.calcite.rel.RelRoot, org.apache.druid.sql.calcite.planner.PlannerContext). Called for SELECT. Not called for EXPLAIN, which is handled by the planner itself.- Parameters:
typeFactory- type factoryvalidatedRowType- row type from Calcite's validatorqueryContext- query context, in case that affects the result type
-
resultTypeForInsert
org.apache.calcite.rel.type.RelDataType resultTypeForInsert(org.apache.calcite.rel.type.RelDataTypeFactory typeFactory, org.apache.calcite.rel.type.RelDataType validatedRowType, Map<String, Object> queryContext) SQL row type that would be emitted by theQueryMakerfrombuildQueryMakerForInsert(org.apache.druid.sql.destination.IngestDestination, org.apache.calcite.rel.RelRoot, org.apache.druid.sql.calcite.planner.PlannerContext). Called for INSERT and REPLACE. Not called for EXPLAIN, which is handled by the planner itself.- Parameters:
typeFactory- type factoryvalidatedRowType- row type from Calcite's validatorqueryContext- query context, in case that affects the result type
-
buildQueryMakerForSelect
QueryMaker buildQueryMakerForSelect(org.apache.calcite.rel.RelRoot relRoot, PlannerContext plannerContext) throws org.apache.calcite.tools.ValidationException Create aQueryMakerfor a SELECT query.- Parameters:
relRoot- planned and validated relplannerContext- context for this query- Returns:
- an executor for the provided query
- Throws:
org.apache.calcite.tools.ValidationException- if this engine cannot build an executor for the provided query
-
buildQueryMakerForInsert
QueryMaker buildQueryMakerForInsert(IngestDestination destination, org.apache.calcite.rel.RelRoot relRoot, PlannerContext plannerContext) throws org.apache.calcite.tools.ValidationException Create aQueryMakerfor an INSERT ... SELECT query.- Parameters:
destination- destination for the INSERT portion of the queryrelRoot- planned and validated rel for the SELECT portion of the queryplannerContext- context for this query- Returns:
- an executor for the provided query
- Throws:
org.apache.calcite.tools.ValidationException- if this engine cannot build an executor for the provided query
-
initContextMap
Enables the engine to make changes to the Context. -
getSqlStatementFactory
SqlStatementFactory getSqlStatementFactory()Returns aSqlStatementFactorywhich uses this engine to create statements. -
getQueries
default GetQueriesResponse getQueries(boolean selfOnly, boolean includeComplete, AuthenticationResult authenticationResult, AuthorizationResult stateReadAuthorization) Returns a list ofQueryInfocontaining the currently running queries using this engine. Returns an empty list if the operation is not supported.- Parameters:
selfOnly- whether to only include queries running on this server. If false, this server should contact all other servers to build a full list of all running queries.includeComplete- whether to include completed queries in the response. The number of completed queries returned is determined by engine-specific retention settings.authenticationResult- implementations should use this for filtering the list of visible queriesstateReadAuthorization- authorization for the STATE READ resource. If this is authorized, implementations should allow all queries to be visible
-
getQueryReport
@Nullable default GetQueryReportResponse getQueryReport(String sqlQueryId, boolean selfOnly, AuthenticationResult authenticationResult, AuthorizationResult stateReadAuthorization) Retrieves the report for a query, if available.- Parameters:
sqlQueryId- SQL query ID to retrieve the report forselfOnly- whether to only include queries running on this server. If false, this server should contact all other servers to find this query, if necessary.authenticationResult- implementations should use this to determine if a query should be visible to a userstateReadAuthorization- authorization for the STATE READ resource. If this is authorized, implementations should allow all queries to be visible
-
cancelQuery
Cancels a currently running query given thePlannerContextfor the query.
-