Package org.apache.drill.exec.ops
Class QueryContext
java.lang.Object
org.apache.drill.exec.ops.QueryContext
- All Implemented Interfaces:
AutoCloseable
,OptimizerRulesContext
,UdfUtilities
,SchemaConfig.SchemaConfigInfoProvider
public class QueryContext
extends Object
implements AutoCloseable, OptimizerRulesContext, SchemaConfig.SchemaConfigInfoProvider
-
Nested Class Summary
-
Field Summary
Fields inherited from interface org.apache.drill.exec.ops.UdfUtilities
INJECTABLE_GETTER_METHODS
-
Constructor Summary
ConstructorDescriptionQueryContext
(UserSession session, DrillbitContext drillbitContext, UserBitShared.QueryId queryId) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the typeQueryContext.SqlStatementType
of the statement.void
close()
Method returns the allocatorgetConstantValueHolder
(String value, TypeProtos.MinorType type, org.apache.drill.shaded.guava.com.google.common.base.Function<DrillBuf, ValueHolder> holderInitializer) Works with value holders cache which holds constant value and its wrapper by type.Get the context information such as: - query start time - root fragment timezone - query userName - system userName - default schema name in current session at the time of query.The Drillbit context allows UDFs to view storage information and other pieces of information about the running system.Method returns the function registryFor UDFs to allocate general purpose intermediate buffers we provide the DrillBuf type as an injectable, which provides access to an off-heap buffer that can be tracked by Drill and re-allocated as needed.org.apache.calcite.schema.SchemaPlus
Return reference to default schema instance in a schema tree.A partition explorer allows UDFs to view the sub-partitions below a particular partition.Method returns the planner optionsGet the user name of the user who issued the query that is managed by this QueryContext.org.apache.calcite.schema.SchemaPlus
Get root schema with schema owner as the user who issued the query that is managed by this QueryContext.org.apache.calcite.schema.SchemaPlus
getRootSchema
(String userName) Return root schema with schema owner as the given user.org.apache.calcite.schema.SchemaPlus
getRootSchema
(SchemaConfig schemaConfig) Create and return aSchemaPlus
with given schemaConfig but some schemas (from storage plugins) could be initialized later.getTemporaryTableName
(String table) boolean
boolean
boolean
boolean
void
Re-creates drill operator table to refresh functions list from local function registry.void
void
skipWritingProfile
(boolean skipWriting) Skip writing profile
-
Constructor Details
-
Method Details
-
getPlannerSettings
Description copied from interface:OptimizerRulesContext
Method returns the planner options- Specified by:
getPlannerSettings
in interfaceOptimizerRulesContext
- Returns:
- PlannerSettings
-
getQueryUserCredentials
- Specified by:
getQueryUserCredentials
in interfaceSchemaConfig.SchemaConfigInfoProvider
-
getAllocator
Description copied from interface:OptimizerRulesContext
Method returns the allocator- Specified by:
getAllocator
in interfaceOptimizerRulesContext
- Returns:
- BufferAllocator
-
getSession
-
getQueryId
-
getNewDefaultSchema
public org.apache.calcite.schema.SchemaPlus getNewDefaultSchema()Return reference to default schema instance in a schema tree. EachSchemaPlus
instance can refer to its parent and its children. From the returned reference to default schema instance, clients can traverse the entire schema tree and know the default schema where to look up the tables first.- Returns:
- Reference to default schema instance in a schema tree.
-
getRootSchema
public org.apache.calcite.schema.SchemaPlus getRootSchema()Get root schema with schema owner as the user who issued the query that is managed by this QueryContext.- Returns:
- Root of the schema tree.
-
getRootSchema
Return root schema with schema owner as the given user.- Specified by:
getRootSchema
in interfaceSchemaConfig.SchemaConfigInfoProvider
- Parameters:
userName
- User who owns the schema tree.- Returns:
- Root of the schema tree.
-
getRootSchema
Create and return aSchemaPlus
with given schemaConfig but some schemas (from storage plugins) could be initialized later.- Parameters:
schemaConfig
-- Returns:
- A
SchemaPlus
with given schemaConfig.
-
getQueryUserName
Get the user name of the user who issued the query that is managed by this QueryContext.- Specified by:
getQueryUserName
in interfaceSchemaConfig.SchemaConfigInfoProvider
- Returns:
- The user name of the user who issued the query that is managed by this QueryContext.
-
getOptions
-
getExecutionControls
-
getCurrentEndpoint
-
getStorage
-
getLpPersistence
-
getActiveEndpoints
-
getOnlineEndpoints
-
getConfig
-
getProfileStoreContext
-
getFunctionRegistry
Description copied from interface:OptimizerRulesContext
Method returns the function registry- Specified by:
getFunctionRegistry
in interfaceOptimizerRulesContext
- Returns:
- FunctionImplementationRegistry
-
getViewExpansionContext
- Specified by:
getViewExpansionContext
in interfaceSchemaConfig.SchemaConfigInfoProvider
-
getOption
- Specified by:
getOption
in interfaceSchemaConfig.SchemaConfigInfoProvider
-
getTemporaryTableName
- Specified by:
getTemporaryTableName
in interfaceSchemaConfig.SchemaConfigInfoProvider
-
getTemporaryWorkspace
- Specified by:
getTemporaryWorkspace
in interfaceSchemaConfig.SchemaConfigInfoProvider
-
isImpersonationEnabled
public boolean isImpersonationEnabled() -
isUserAuthenticationEnabled
public boolean isUserAuthenticationEnabled() -
isRuntimeFilterEnabled
public boolean isRuntimeFilterEnabled() -
getDrillOperatorTable
-
reloadDrillOperatorTable
public void reloadDrillOperatorTable()Re-creates drill operator table to refresh functions list from local function registry. -
getQueryContextInfo
-
getRemoteFunctionRegistry
-
getContextInformation
Description copied from interface:UdfUtilities
Get the context information such as: - query start time - root fragment timezone - query userName - system userName - default schema name in current session at the time of query.- Specified by:
getContextInformation
in interfaceUdfUtilities
- Returns:
- - ContextInformation
-
getManagedBuffer
Description copied from interface:UdfUtilities
For UDFs to allocate general purpose intermediate buffers we provide the DrillBuf type as an injectable, which provides access to an off-heap buffer that can be tracked by Drill and re-allocated as needed.- Specified by:
getManagedBuffer
in interfaceUdfUtilities
- Returns:
- - a buffer managed by Drill, connected to the fragment allocator for memory management
-
getDrillbitContext
Description copied from interface:UdfUtilities
The Drillbit context allows UDFs to view storage information and other pieces of information about the running system. See the http_get implementation for details.- Specified by:
getDrillbitContext
in interfaceUdfUtilities
- Returns:
- - an object for accessing drillbit information such as storage configs.
-
getResultSetLoader
- Specified by:
getResultSetLoader
in interfaceUdfUtilities
-
getPartitionExplorer
Description copied from interface:UdfUtilities
A partition explorer allows UDFs to view the sub-partitions below a particular partition. This allows for the implementation of UDFs to query against the partition information, without having to read the actual data contained in the partition. This interface is designed for UDFs that take only constant inputs, as this interface will only be useful if we can evaluate the constant UDF at planning time. Any function defined to use this interface that is not evaluated at planning time by the constant folding rule will be querying the storage plugin for meta-data for each record processed. Be sure to check the query plans to see that this expression has already been evaluated during planning if you write UDFs against this interface. SeeDirectoryExplorers
for example usages of this interface.- Specified by:
getPartitionExplorer
in interfaceUdfUtilities
- Returns:
- - an object for exploring partitions of all available schemas
-
getConstantValueHolder
public ValueHolder getConstantValueHolder(String value, TypeProtos.MinorType type, org.apache.drill.shaded.guava.com.google.common.base.Function<DrillBuf, ValueHolder> holderInitializer) Description copied from interface:UdfUtilities
Works with value holders cache which holds constant value and its wrapper by type. If value is absent uses holderInitializer to create holder and adds it to cache.- Specified by:
getConstantValueHolder
in interfaceUdfUtilities
- Returns:
- - a wrapper object for an constant value.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
setSQLStatementType
- Parameters:
stmtType
- : Sets the typeQueryContext.SqlStatementType
of the statement e.g. CTAS, ANALYZE
-
clearSQLStatementType
public void clearSQLStatementType()Clears the typeQueryContext.SqlStatementType
of the statement. -
getSQLStatementType
- Returns:
- Get the type
QueryContext.SqlStatementType
of the statement e.g. CTAS, ANALYZE
-
skipWritingProfile
public void skipWritingProfile(boolean skipWriting) Skip writing profile- Parameters:
skipWriting
-
-
isSkipProfileWrite
public boolean isSkipProfileWrite()- Returns:
- Check if to skip writing
-
getMetastoreRegistry
-
getAliasRegistryProvider
-