Class PlannerContext
java.lang.Object
org.apache.druid.sql.calcite.planner.PlannerContext
Like
PlannerConfig, but that has static configuration and this class
contains dynamic, per-query configuration. Additional Druid-specific static
configuration resides in the PlannerToolbox class.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringKey to enable transfer of RACs over wire.static final Stringstatic final Stringstatic final StringUndocumented context key, used internally, to allow the web console to apply a limit without having to rewrite the SQL query.static final StringContext key forisPullUpLookup().static final StringContext key forisReverseLookup().static final Stringstatic final StringContext key forisUseBoundsAndSelectors().static final StringContext key forisUseExtractionFns().static final StringContext key forisUseGranularity().static final Stringstatic final booleanstatic final booleanstatic final booleanstatic final booleanstatic final boolean -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllToQueryContext(Map<String, Object> toAdd) Add additional query context parameters, overriding any existing values.voidaddLookupToLoad(String lookupName) Adds the given lookup name to the lookup loading spec.voidaddNativeQueryId(String queryId) Return an immutable set of context keys need to be authorization checked, this usually comes from user-provided query context, including SET parameters.static PlannerContextcreate(PlannerToolbox plannerToolbox, String sql, org.apache.calcite.sql.SqlNode sqlNode, SqlEngine engine, Set<String> authContextKeys, Map<String, Object> queryContext, PlannerHook hook) org.apache.calcite.DataContextcreateDataContext(org.apache.calcite.adapter.java.JavaTypeFactory typeFactory, List<org.apache.calcite.avatica.remote.TypedValue> parameters) <T> voiddispatchHook(DruidHook.HookKey<T> key, T object) booleanfeatureAvailable(EngineFeature feature) Checks if the currentSqlEnginesupports a particular feature.static JoinAlgorithmgetJoinAlgorithm(Map<String, Object> queryContext) Returns the join algorithm specified in a query context.static JoinAlgorithmgetJoinAlgorithm(QueryContext queryContext) Returns the join algorithm specified in a query context.com.fasterxml.jackson.databind.ObjectMapperorg.joda.time.DateTimeRetrieve a namedLookupExtractor.Lookup loading spec used if this context corresponds to an MSQ task.List<org.apache.calcite.avatica.remote.TypedValue>getSchemaResourceType(String schema, String resourceName) getSql()org.apache.calcite.sql.SqlNodeorg.joda.time.DateTimeZonebooleanWhether we should useAggregatePullUpLookupRuleto pull LOOKUP functions on injective lookups up above a GROUP BY.booleanWhether we should useReverseLookupRuleto reduce the LOOKUP function, and whether we should set the "optimize" flag onRegisteredLookupExtractionFn.booleanbooleanWhether we should useBoundDimFilterandSelectorDimFilter(true) orRangeFilter,EqualityFilter, andNullFilter(false).booleanWhether we should useExtractionFnin planning.booleanWhether we should use granularities other thanGranularities.ALLwhen planning queries.booleanWhether we should useInDimFilter(true) orTypedInFilter(false).parseExpression(String expr) Equivalent toExpressionParser.parse(String)ongetExpressionParser().Return the query context as an immutable object.Return the query context as a mutable map.voidsetAuthenticationResult(AuthenticationResult authenticationResult) voidvoidsetExplainAttributes(ExplainAttributes explainAttributes) voidsetJoinExpressionVirtualColumnRegistry(VirtualColumnRegistry joinExpressionVirtualColumnRegistry) voidsetParameters(List<org.apache.calcite.avatica.remote.TypedValue> parameters) voidsetPlanningError(String formatText, Object... arguments) Sets the planning error in the context that will be shown to the user if the SQL query cannot be translated to a native query.voidsetQueryMaker(QueryMaker queryMaker) voidsetResourceActions(Set<ResourceAction> resourceActions)
-
Field Details
-
CTX_SQL_CURRENT_TIMESTAMP
- See Also:
-
CTX_SQL_TIME_ZONE
- See Also:
-
CTX_SQL_JOIN_ALGORITHM
- See Also:
-
CTX_SQL_OUTER_LIMIT
Undocumented context key, used internally, to allow the web console to apply a limit without having to rewrite the SQL query.- See Also:
-
CTX_ENABLE_RAC_TRANSFER_OVER_WIRE
Key to enable transfer of RACs over wire.- See Also:
-
CTX_SQL_USE_BOUNDS_AND_SELECTORS
Context key forisUseBoundsAndSelectors().- See Also:
-
DEFAULT_SQL_USE_BOUNDS_AND_SELECTORS
public static final boolean DEFAULT_SQL_USE_BOUNDS_AND_SELECTORS- See Also:
-
CTX_SQL_USE_EXTRACTION_FNS
Context key forisUseExtractionFns().- See Also:
-
DEFAULT_SQL_USE_EXTRACTION_FNS
public static final boolean DEFAULT_SQL_USE_EXTRACTION_FNS- See Also:
-
CTX_SQL_PULL_UP_LOOKUP
Context key forisPullUpLookup().- See Also:
-
DEFAULT_SQL_PULL_UP_LOOKUP
public static final boolean DEFAULT_SQL_PULL_UP_LOOKUP- See Also:
-
CTX_SQL_REVERSE_LOOKUP
Context key forisReverseLookup().- See Also:
-
DEFAULT_SQL_REVERSE_LOOKUP
public static final boolean DEFAULT_SQL_REVERSE_LOOKUP- See Also:
-
CTX_SQL_USE_GRANULARITY
Context key forisUseGranularity().- See Also:
-
DEFAULT_SQL_USE_GRANULARITY
public static final boolean DEFAULT_SQL_USE_GRANULARITY- See Also:
-
DATA_CTX_AUTHENTICATION_RESULT
- See Also:
-
-
Method Details
-
create
public static PlannerContext create(PlannerToolbox plannerToolbox, String sql, org.apache.calcite.sql.SqlNode sqlNode, SqlEngine engine, Set<String> authContextKeys, Map<String, Object> queryContext, PlannerHook hook) -
getJoinAlgorithm
Returns the join algorithm specified in a query context. -
getJoinAlgorithm
Returns the join algorithm specified in a query context. -
getPlannerToolbox
-
getExprMacroTable
-
getExpressionParser
-
parseExpression
Equivalent toExpressionParser.parse(String)ongetExpressionParser(). -
getJsonMapper
public com.fasterxml.jackson.databind.ObjectMapper getJsonMapper() -
getPlannerConfig
-
getLocalNow
public org.joda.time.DateTime getLocalNow() -
getTimeZone
public org.joda.time.DateTimeZone getTimeZone() -
getJoinableFactoryWrapper
-
getSchemaResourceType
-
addLookupToLoad
Adds the given lookup name to the lookup loading spec. -
getLookupLoadingSpec
Lookup loading spec used if this context corresponds to an MSQ task. -
queryContextMap
Return the query context as a mutable map. Use this form when modifying the context during planning. -
authContextKeys
Return an immutable set of context keys need to be authorization checked, this usually comes from user-provided query context, including SET parameters. -
queryContext
Return the query context as an immutable object. Use this form when querying the context as it provides type-safe accessors. -
isStringifyArrays
public boolean isStringifyArrays() -
isUseBoundsAndSelectors
public boolean isUseBoundsAndSelectors()Whether we should useBoundDimFilterandSelectorDimFilter(true) orRangeFilter,EqualityFilter, andNullFilter(false). Can be overriden by the context parameterCTX_SQL_USE_BOUNDS_AND_SELECTORS. -
isUseExtractionFns
public boolean isUseExtractionFns()Whether we should useExtractionFnin planning. -
isUseLegacyInFilter
public boolean isUseLegacyInFilter()Whether we should useInDimFilter(true) orTypedInFilter(false). -
isPullUpLookup
public boolean isPullUpLookup()Whether we should useAggregatePullUpLookupRuleto pull LOOKUP functions on injective lookups up above a GROUP BY. -
isReverseLookup
public boolean isReverseLookup()Whether we should useReverseLookupRuleto reduce the LOOKUP function, and whether we should set the "optimize" flag onRegisteredLookupExtractionFn. -
isUseGranularity
public boolean isUseGranularity()Whether we should use granularities other thanGranularities.ALLwhen planning queries. This is provided mainly so it can be set to false when running SQL queries on non-time-ordered tables, which do not support any other granularities. -
getParameters
-
getAuthenticationResult
-
getJoinAlgorithm
-
getSql
-
getSqlNode
public org.apache.calcite.sql.SqlNode getSqlNode() -
getPlannerHook
-
getSqlQueryId
-
getNativeQueryIds
-
addNativeQueryId
-
getPlanningError
-
setPlanningError
Sets the planning error in the context that will be shown to the user if the SQL query cannot be translated to a native query. This error is often a hint and thus should be phrased as such. Also, the final plan can be very different from SQL that user has written. So again, the error should be phrased to indicate this gap clearly. -
createDataContext
public org.apache.calcite.DataContext createDataContext(org.apache.calcite.adapter.java.JavaTypeFactory typeFactory, List<org.apache.calcite.avatica.remote.TypedValue> parameters) -
getAuthorizationResult
-
setParameters
-
setAuthenticationResult
-
setAuthorizationResult
-
getResourceActions
-
setResourceActions
-
setQueryMaker
-
addAllToQueryContext
Add additional query context parameters, overriding any existing values. -
getEngine
-
featureAvailable
Checks if the currentSqlEnginesupports a particular feature.When executing a specific query, use this method instead of
SqlEngine.featureAvailable(EngineFeature)because it also verifies feature flags. -
getQueryMaker
-
getJoinExpressionVirtualColumnRegistry
-
setJoinExpressionVirtualColumnRegistry
public void setJoinExpressionVirtualColumnRegistry(VirtualColumnRegistry joinExpressionVirtualColumnRegistry) -
getExplainAttributes
-
setExplainAttributes
-
getLookup
Retrieve a namedLookupExtractor. -
dispatchHook
-