Package org.apache.drill.exec.rpc.user
Class UserSession
java.lang.Object
org.apache.drill.exec.rpc.user.UserSession
- All Implemented Interfaces:
AutoCloseable
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static interface
Implementations of this interface are allowed to increment queryCount. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
On session close deletes all session temporary locations recursively and clears temporary locations list.org.apache.calcite.schema.SchemaPlus
getDefaultSchema
(org.apache.calcite.schema.SchemaPlus rootSchema) Get default schema from current default schema path and given schema tree.getOriginalTableNameFromTemporaryTable
(String tableName) int
void
incrementQueryCount
(UserSession.QueryCountIncrementer incrementer) boolean
boolean
isTemporaryTable
(AbstractSchema drillSchema, DrillConfig config, String tableName) Checks if passed table is temporary, table name is case-insensitive.registerTemporaryTable
(AbstractSchema schema, String tableName, DrillConfig config) Creates and adds session temporary location if absent using schema configuration.void
removeTemporaryTable
(AbstractSchema schema, String tableName, DrillConfig config) Removes temporary table name from the list of session temporary tables.void
replaceUserCredentials
(InboundImpersonationManager impersonationManager, UserBitShared.UserCredentials newCredentials) Replace current user credentials with the given user's credentials.resolveTemporaryTableName
(String tableName) Returns generated temporary table name from the list of session temporary tables, null otherwise.void
setDefaultSchemaPath
(String newDefaultSchemaPath, org.apache.calcite.schema.SchemaPlus currentDefaultSchema) Update the schema path for the session.void
setSessionOption
(String name, String value) Set the option of a session level.
-
Method Details
-
close
public void close()On session close deletes all session temporary locations recursively and clears temporary locations list.- Specified by:
close
in interfaceAutoCloseable
-
isSupportComplexTypes
public boolean isSupportComplexTypes() -
getOptions
-
getCredentials
-
getTargetUserName
-
incrementQueryCount
-
getQueryCount
public int getQueryCount() -
setDefaultSchemaPath
public void setDefaultSchemaPath(String newDefaultSchemaPath, org.apache.calcite.schema.SchemaPlus currentDefaultSchema) throws org.apache.calcite.tools.ValidationException Update the schema path for the session.- Parameters:
newDefaultSchemaPath
- New default schema path to set. It could be relative to the current default schema or absolute schema.currentDefaultSchema
- Current default schema.- Throws:
org.apache.calcite.tools.ValidationException
- If the given default schema path is invalid in current schema tree.
-
getDefaultSchemaPath
- Returns:
- Get current default schema path.
-
getDefaultSchema
public org.apache.calcite.schema.SchemaPlus getDefaultSchema(org.apache.calcite.schema.SchemaPlus rootSchema) Get default schema from current default schema path and given schema tree.- Parameters:
rootSchema
- root schema- Returns:
- A
SchemaPlus
object.
-
setSessionOption
Set the option of a session level. Note: Option's kind is automatically detected if such option exists.- Parameters:
name
- option namevalue
- option value
-
getSessionId
- Returns:
- unique session identifier
-
registerTemporaryTable
public String registerTemporaryTable(AbstractSchema schema, String tableName, DrillConfig config) throws IOException Creates and adds session temporary location if absent using schema configuration. Before any actions, checks if passed table schema is valid default temporary workspace. Generates temporary table name and stores it's original name as key and generated name as value in session temporary tables cache. Original temporary name is converted to lower case to achieve case-insensitivity. If original table name already exists, new name is not regenerated and is reused. This can happen if default temporary workspace was changed (file system or location) or orphan temporary table name has remained (name was registered but table creation did not succeed).- Parameters:
schema
- table schematableName
- original table nameconfig
- drill config- Returns:
- generated temporary table name
- Throws:
IOException
- if error during session temporary location creation
-
resolveTemporaryTableName
Returns generated temporary table name from the list of session temporary tables, null otherwise. Original temporary name is converted to lower case to achieve case-insensitivity.- Parameters:
tableName
- original table name- Returns:
- generated temporary table name
-
getOriginalTableNameFromTemporaryTable
-
isTemporaryTable
Checks if passed table is temporary, table name is case-insensitive. Before looking for table checks if passed schema is temporary and returns false if not since temporary tables are allowed to be created in temporary workspace only. If passed workspace is temporary, looks for temporary table. First checks if table name is among temporary tables, if not returns false. If temporary table named was resolved, checks that temporary table exists on disk, to ensure that temporary table actually exists and resolved table name is not orphan (for example, in result of unsuccessful temporary table creation).- Parameters:
drillSchema
- table schemaconfig
- drill configtableName
- original table name- Returns:
- true if temporary table exists in schema, false otherwise
-
removeTemporaryTable
Removes temporary table name from the list of session temporary tables. Original temporary name is converted to lower case to achieve case-insensitivity. Before temporary table drop, checks if passed table schema is valid default temporary workspace.- Parameters:
schema
- table schematableName
- original table nameconfig
- drill config
-