Package org.apache.drill.exec.client
Class DrillClient
java.lang.Object
org.apache.drill.exec.client.DrillClient
- All Implemented Interfaces:
Closeable,AutoCloseable,ConnectionThrottle
Thin wrapper around a UserClient that handles connect/close and transforms
String into ByteBuf.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDrillClient(boolean isDirect) DrillClient(String fileName) DrillClient(DrillConfig config) DrillClient(DrillConfig config, boolean isDirect) DrillClient(DrillConfig config, ClusterCoordinator coordinator) DrillClient(DrillConfig config, ClusterCoordinator coordinator, boolean isDirect) DrillClient(DrillConfig config, ClusterCoordinator coordinator, BufferAllocator allocator) DrillClient(DrillConfig config, ClusterCoordinator coordinator, BufferAllocator allocator, boolean isDirect) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this client's connection to the servervoidconnect()Connects the client to a Drillbit servervoidconnect(String connect, Properties props) Start's a connection from client to servervoidconnect(Properties props) Start's a connection from client to serverbooleanprotected static io.netty.channel.EventLoopGroupcreateEventLoop(int size, String prefix) createPreparedStatement(String query) Create a prepared statement for given thequery.executePreparedStatement(UserProtos.PreparedStatementHandle preparedStatementHandle) Execute the given prepared statement and return the results.voidexecutePreparedStatement(UserProtos.PreparedStatementHandle preparedStatementHandle, UserResultsListener resultsListener) Execute the given prepared statement.getCatalogs(UserProtos.LikeFilter catalogNameFilter) Get the list of catalogs inINFORMATION_SCHEMA.CATALOGStable satisfying the given filters.getColumns(UserProtos.LikeFilter catalogNameFilter, UserProtos.LikeFilter schemaNameFilter, UserProtos.LikeFilter tableNameFilter, UserProtos.LikeFilter columnNameFilter) Get the list of columns inINFORMATION_SCHEMA.COLUMNStable satisfying the given filters.getSchemas(UserProtos.LikeFilter catalogNameFilter, UserProtos.LikeFilter schemaNameFilter) Get the list of schemas inINFORMATION_SCHEMA.SCHEMATAtable satisfying the given filters.Deprecated.Get server meta information Get meta information about the server like the the available functions or the identifier quoting string used by the current sessionReturn the server name.Return the server version.Returns the list of methods supported by the server based on its advertised information.getTables(UserProtos.LikeFilter catalogNameFilter, UserProtos.LikeFilter schemaNameFilter, UserProtos.LikeFilter tableNameFilter, List<String> tableTypeFilter) Get the list of tables inINFORMATION_SCHEMA.TABLEStable satisfying the given filters.booleanhasPing(long timeoutSec) Verify connection with request-answer.planQuery(UserBitShared.QueryType type, String query, boolean isSplitPlan) API to just plan a query without executionbooleanresumeQuery(UserBitShared.QueryId queryId) runQuery(UserBitShared.QueryType type, String plan) Submits a string based query plan for execution and returns the result batches.voidrunQuery(UserBitShared.QueryType type, String plan, UserResultsListener resultsListener) Submits a Logical plan for direct execution (bypasses parsing)voidrunQuery(UserBitShared.QueryType type, List<BitControl.PlanFragment> planFragments, UserResultsListener resultsListener) Run query based on list of fragments that were supposedly produced during query planning phase.voidsetAutoRead(boolean enableAutoRead) voidsetClientName(String name) Sets the client name.voidsetSupportComplexTypes(boolean supportComplexTypes) Sets whether the application is willing to accept complex types (Map, Arrays) in the returned result set.
-
Field Details
-
DEFAULT_CLIENT_NAME
- See Also:
-
-
Constructor Details
-
DrillClient
- Throws:
OutOfMemoryException
-
DrillClient
- Throws:
OutOfMemoryException
-
DrillClient
- Throws:
OutOfMemoryException
-
DrillClient
- Throws:
OutOfMemoryException
-
DrillClient
- Throws:
OutOfMemoryException
-
DrillClient
- Throws:
OutOfMemoryException
-
DrillClient
public DrillClient(DrillConfig config, ClusterCoordinator coordinator, boolean isDirect) throws OutOfMemoryException - Throws:
OutOfMemoryException
-
DrillClient
public DrillClient(DrillConfig config, ClusterCoordinator coordinator, BufferAllocator allocator) throws OutOfMemoryException - Throws:
OutOfMemoryException
-
DrillClient
public DrillClient(DrillConfig config, ClusterCoordinator coordinator, BufferAllocator allocator, boolean isDirect)
-
-
Method Details
-
getConfig
-
setAutoRead
public void setAutoRead(boolean enableAutoRead) - Specified by:
setAutoReadin interfaceConnectionThrottle
-
setClientName
Sets the client name. If not set, default isDrillClient#DEFAULT_CLIENT_NAME.- Parameters:
name- the client name- Throws:
IllegalStateException- if called after a connection has been established.NullPointerException- if client name is null
-
setSupportComplexTypes
public void setSupportComplexTypes(boolean supportComplexTypes) Sets whether the application is willing to accept complex types (Map, Arrays) in the returned result set. Default istrue. If set tofalse, the complex types are returned as JSON encoded VARCHAR type.- Throws:
IllegalStateException- if called after a connection has been established.
-
connect
Connects the client to a Drillbit server- Throws:
RpcException
-
connect
Start's a connection from client to server- Parameters:
props- - not nullPropertiesfilled with connection url parameters- Throws:
RpcException
-
connect
Start's a connection from client to server- Parameters:
connect- - Zookeeper connection string provided at connection URLprops- - not nullPropertiesfilled with connection url parameters- Throws:
RpcException
-
createEventLoop
-
reconnect
public boolean reconnect() -
getAllocator
-
close
public void close()Closes this client's connection to the server- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getServerInfos
Deprecated.useDrillClient#getServerVersion()Return the server infos. Only available after connecting The result might be null if the server doesn't provide the informations.- Returns:
- the server informations, or null if not connected or if the server doesn't provide the information
-
getServerName
Return the server name. Only available after connecting The result might be null if the server doesn't provide the name information.- Returns:
- the server name, or null if not connected or if the server doesn't provide the name
-
getServerVersion
Return the server version. Only available after connecting The result might be null if the server doesn't provide the version information.- Returns:
- the server version, or null if not connected or if the server doesn't provide the version
-
getServerMeta
Get server meta information Get meta information about the server like the the available functions or the identifier quoting string used by the current session- Returns:
- a future to the server meta response
-
getSupportedMethods
Returns the list of methods supported by the server based on its advertised information.- Returns:
- an immutable set of capabilities
-
getCatalogs
public DrillRpcFuture<UserProtos.GetCatalogsResp> getCatalogs(UserProtos.LikeFilter catalogNameFilter) Get the list of catalogs inINFORMATION_SCHEMA.CATALOGStable satisfying the given filters.- Parameters:
catalogNameFilter- Filter oncatalog name. Pass null to apply no filter.- Returns:
- The list of catalogs in
INFORMATION_SCHEMA.CATALOGStable satisfying the given filters.
-
getSchemas
public DrillRpcFuture<UserProtos.GetSchemasResp> getSchemas(UserProtos.LikeFilter catalogNameFilter, UserProtos.LikeFilter schemaNameFilter) Get the list of schemas inINFORMATION_SCHEMA.SCHEMATAtable satisfying the given filters.- Parameters:
catalogNameFilter- Filter oncatalog name. Pass null to apply no filter.schemaNameFilter- Filter onschema name. Pass null to apply no filter.- Returns:
- The list of schemas in
INFORMATION_SCHEMA.SCHEMATAtable satisfying the given filters.
-
getTables
public DrillRpcFuture<UserProtos.GetTablesResp> getTables(UserProtos.LikeFilter catalogNameFilter, UserProtos.LikeFilter schemaNameFilter, UserProtos.LikeFilter tableNameFilter, List<String> tableTypeFilter) Get the list of tables inINFORMATION_SCHEMA.TABLEStable satisfying the given filters.- Parameters:
catalogNameFilter- Filter oncatalog name. Pass null to apply no filter.schemaNameFilter- Filter onschema name. Pass null to apply no filter.tableNameFilter- Filter intable name. Pass null to apply no filter.tableTypeFilter- Filter intable type. Pass null to apply no filter- Returns:
- The list of tables in
INFORMATION_SCHEMA.TABLEStable satisfying the given filters.
-
getColumns
public DrillRpcFuture<UserProtos.GetColumnsResp> getColumns(UserProtos.LikeFilter catalogNameFilter, UserProtos.LikeFilter schemaNameFilter, UserProtos.LikeFilter tableNameFilter, UserProtos.LikeFilter columnNameFilter) Get the list of columns inINFORMATION_SCHEMA.COLUMNStable satisfying the given filters.- Parameters:
catalogNameFilter- Filter oncatalog name. Pass null to apply no filter.schemaNameFilter- Filter onschema name. Pass null to apply no filter.tableNameFilter- Filter intable name. Pass null to apply no filter.columnNameFilter- Filter incolumn name. Pass null to apply no filter.- Returns:
- The list of columns in
INFORMATION_SCHEMA.COLUMNStable satisfying the given filters.
-
createPreparedStatement
Create a prepared statement for given thequery.- Parameters:
query-- Returns:
- The prepared statement for given the
query.
-
executePreparedStatement
public void executePreparedStatement(UserProtos.PreparedStatementHandle preparedStatementHandle, UserResultsListener resultsListener) Execute the given prepared statement.- Parameters:
preparedStatementHandle- Prepared statement handle returned in response tocreatePreparedStatement(String).resultsListener-UserResultsListenerinstance for listening for query results.
-
executePreparedStatement
public List<QueryDataBatch> executePreparedStatement(UserProtos.PreparedStatementHandle preparedStatementHandle) throws RpcException Execute the given prepared statement and return the results.- Parameters:
preparedStatementHandle- Prepared statement handle returned in response tocreatePreparedStatement(String).- Returns:
- List of
QueryDataBatchs. It is responsibility of the caller to release query data batches. - Throws:
RpcException
-
connectionIsActive
public boolean connectionIsActive()- Returns:
- true if client has connection and it is connected, false otherwise
-
hasPing
Verify connection with request-answer.- Parameters:
timeoutSec- time in seconds to wait answer receiving. If 0 then won't wait.- Returns:
- true if
PONGreceived until timeout, false otherwise - Throws:
DrillRuntimeException
-
DrillClient#getServerVersion()