Package com.databricks.jdbc.api.impl
Class DatabricksSession
- java.lang.Object
-
- com.databricks.jdbc.api.impl.DatabricksSession
-
- All Implemented Interfaces:
IDatabricksSession
public class DatabricksSession extends Object implements IDatabricksSession
Implementation ofIDatabricksSession, which maintains an underlying session in SQL Gateway.
-
-
Constructor Summary
Constructors Constructor Description DatabricksSession(IDatabricksConnectionContext connectionContext)Creates an instance of Databricks session for given connection contextDatabricksSession(IDatabricksConnectionContext connectionContext, IDatabricksClient testDatabricksClient)Constructor method to be used for mocking in a test case.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the session.voidforceClose()StringgetCatalog()Returns default catalog associated with the sessionMap<String,String>getClientInfoProperties()Returns the client info propertiesCompressionCodecgetCompressionCodec()Returns the compression algorithm used on results dataIDatabricksComputeResourcegetComputeResource()Get the warehouse associated with the session.StringgetConfigValue(String name)IDatabricksConnectionContextgetConnectionContext()Returns the associated connection context for the sessionStringgetCurrentCatalog()Gets the current catalog from the databaseIDatabricksClientgetDatabricksClient()Returns the client for connecting to Databricks serverIDatabricksMetadataClientgetDatabricksMetadataClient()Returns the metadata clientStringgetSchema()Returns default schema associated with the sessionMap<String,String>getSessionConfigs()Returns the session configsStringgetSessionId()Get the unique session-Id associated with the session.ImmutableSessionInfogetSessionInfo()booleanisOpen()Checks if session is open and valid.voidopen()Opens a new session.voidsetCatalog(String catalog)Sets the default catalogvoidsetClientInfoProperty(String name, String value)Sets the client info propertyvoidsetEmptyMetadataClient()voidsetSchema(String schema)Sets the default schemavoidsetSessionConfig(String name, String value)Sets the session configStringtoString()Extracts session to a string
-
-
-
Constructor Detail
-
DatabricksSession
public DatabricksSession(IDatabricksConnectionContext connectionContext) throws DatabricksSQLException
Creates an instance of Databricks session for given connection context- Parameters:
connectionContext- underlying connection context- Throws:
DatabricksSQLException
-
DatabricksSession
public DatabricksSession(IDatabricksConnectionContext connectionContext, IDatabricksClient testDatabricksClient)
Constructor method to be used for mocking in a test case.
-
-
Method Detail
-
getSessionId
@Nullable public String getSessionId()
Description copied from interface:IDatabricksSessionGet the unique session-Id associated with the session.- Specified by:
getSessionIdin interfaceIDatabricksSession- Returns:
- session-Id
-
getSessionInfo
@Nullable public ImmutableSessionInfo getSessionInfo()
- Specified by:
getSessionInfoin interfaceIDatabricksSession
-
getComputeResource
public IDatabricksComputeResource getComputeResource()
Description copied from interface:IDatabricksSessionGet the warehouse associated with the session.- Specified by:
getComputeResourcein interfaceIDatabricksSession- Returns:
- warehouse-Id
-
getCompressionCodec
public CompressionCodec getCompressionCodec()
Description copied from interface:IDatabricksSessionReturns the compression algorithm used on results data- Specified by:
getCompressionCodecin interfaceIDatabricksSession
-
isOpen
public boolean isOpen()
Description copied from interface:IDatabricksSessionChecks if session is open and valid.- Specified by:
isOpenin interfaceIDatabricksSession- Returns:
- true if session is open
-
open
public void open() throws DatabricksSQLExceptionDescription copied from interface:IDatabricksSessionOpens a new session.- Specified by:
openin interfaceIDatabricksSession- Throws:
DatabricksSQLException
-
close
public void close() throws DatabricksSQLExceptionDescription copied from interface:IDatabricksSessionCloses the session.- Specified by:
closein interfaceIDatabricksSession- Throws:
DatabricksSQLException
-
getDatabricksClient
public IDatabricksClient getDatabricksClient()
Description copied from interface:IDatabricksSessionReturns the client for connecting to Databricks server- Specified by:
getDatabricksClientin interfaceIDatabricksSession
-
getDatabricksMetadataClient
public IDatabricksMetadataClient getDatabricksMetadataClient()
Description copied from interface:IDatabricksSessionReturns the metadata client- Specified by:
getDatabricksMetadataClientin interfaceIDatabricksSession
-
getCatalog
public String getCatalog()
Description copied from interface:IDatabricksSessionReturns default catalog associated with the session- Specified by:
getCatalogin interfaceIDatabricksSession
-
setCatalog
public void setCatalog(String catalog)
Description copied from interface:IDatabricksSessionSets the default catalog- Specified by:
setCatalogin interfaceIDatabricksSession
-
getSchema
public String getSchema()
Description copied from interface:IDatabricksSessionReturns default schema associated with the session- Specified by:
getSchemain interfaceIDatabricksSession
-
setSchema
public void setSchema(String schema)
Description copied from interface:IDatabricksSessionSets the default schema- Specified by:
setSchemain interfaceIDatabricksSession
-
toString
public String toString()
Description copied from interface:IDatabricksSessionExtracts session to a string- Specified by:
toStringin interfaceIDatabricksSession- Overrides:
toStringin classObject
-
getSessionConfigs
public Map<String,String> getSessionConfigs()
Description copied from interface:IDatabricksSessionReturns the session configs- Specified by:
getSessionConfigsin interfaceIDatabricksSession
-
setSessionConfig
public void setSessionConfig(String name, String value)
Description copied from interface:IDatabricksSessionSets the session config- Specified by:
setSessionConfigin interfaceIDatabricksSession
-
getClientInfoProperties
public Map<String,String> getClientInfoProperties()
Description copied from interface:IDatabricksSessionReturns the client info properties- Specified by:
getClientInfoPropertiesin interfaceIDatabricksSession
-
getConfigValue
public String getConfigValue(String name)
- Specified by:
getConfigValuein interfaceIDatabricksSession
-
setClientInfoProperty
public void setClientInfoProperty(String name, String value)
Description copied from interface:IDatabricksSessionSets the client info property- Specified by:
setClientInfoPropertyin interfaceIDatabricksSession
-
getConnectionContext
public IDatabricksConnectionContext getConnectionContext()
Description copied from interface:IDatabricksSessionReturns the associated connection context for the session- Specified by:
getConnectionContextin interfaceIDatabricksSession
-
getCurrentCatalog
public String getCurrentCatalog() throws DatabricksSQLException
Description copied from interface:IDatabricksSessionGets the current catalog from the database- Specified by:
getCurrentCatalogin interfaceIDatabricksSession- Throws:
DatabricksSQLException
-
setEmptyMetadataClient
public void setEmptyMetadataClient()
- Specified by:
setEmptyMetadataClientin interfaceIDatabricksSession
-
forceClose
public void forceClose()
- Specified by:
forceClosein interfaceIDatabricksSession
-
-