Class UserSession

java.lang.Object
org.apache.drill.exec.rpc.user.UserSession
All Implemented Interfaces:
AutoCloseable

public class UserSession extends Object implements AutoCloseable
  • Method Details

    • close

      public void close()
      On session close deletes all session temporary locations recursively and clears temporary locations list.
      Specified by:
      close in interface AutoCloseable
    • isSupportComplexTypes

      public boolean isSupportComplexTypes()
    • getOptions

      public SessionOptionManager getOptions()
    • getCredentials

      public UserBitShared.UserCredentials getCredentials()
    • replaceUserCredentials

      public void replaceUserCredentials(InboundImpersonationManager impersonationManager, UserBitShared.UserCredentials newCredentials)
      Replace current user credentials with the given user's credentials. Meant to be called only by a impersonation manager.
      Parameters:
      impersonationManager - impersonation manager making this call
      newCredentials - user credentials to change to
    • getTargetUserName

      public String getTargetUserName()
    • incrementQueryCount

      public void incrementQueryCount(UserSession.QueryCountIncrementer incrementer)
    • 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

      public String 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

      public void setSessionOption(String name, String value)
      Set the option of a session level. Note: Option's kind is automatically detected if such option exists.
      Parameters:
      name - option name
      value - option value
    • getSessionId

      public String 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 schema
      tableName - original table name
      config - drill config
      Returns:
      generated temporary table name
      Throws:
      IOException - if error during session temporary location creation
    • resolveTemporaryTableName

      public String resolveTemporaryTableName(String tableName)
      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

      public String getOriginalTableNameFromTemporaryTable(String tableName)
    • isTemporaryTable

      public boolean isTemporaryTable(AbstractSchema drillSchema, DrillConfig config, String tableName)
      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 schema
      config - drill config
      tableName - original table name
      Returns:
      true if temporary table exists in schema, false otherwise
    • removeTemporaryTable

      public void removeTemporaryTable(AbstractSchema schema, String tableName, DrillConfig config)
      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 schema
      tableName - original table name
      config - drill config