@Component @UserDocumentation(title="Commands for Query Management", description="This section provides commands for query life cycle - submit, check status,\n fetch results, kill or list all the queries. Also provides commands for\n prepare a query, destroy a prepared query and list all prepared queries.\n\n Please note that, character <<<\">>> is used as delimiter by the Spring Shell\n framework, which is used to build lens cli. So queries which require <<<\">>>,\n should be prefixed with another double quote. For example\n <<>>,\n will be parsed as << >>") public class LensQueryCommands extends BaseLensCommand
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_QUERY_HANDLE_DESCRIPTION |
DATE_FMT, DATE_PARSER
Constructor and Description |
---|
LensQueryCommands() |
Modifier and Type | Method and Description |
---|---|
String |
destroyPreparedQuery(String ph)
Destroy prepared query.
|
String |
executeCubeSelectQuery(String sql,
boolean async,
String queryName) |
String |
executePreparedQuery(String phandle,
boolean async,
String queryName)
Execute prepared query.
|
String |
executeQuery(String sql,
boolean async,
String queryName)
Execute query.
|
String |
executeSelectQuery(String sql,
boolean async,
String queryName) |
String |
explainAndPrepare(String sql,
String queryName)
Explain and prepare.
|
String |
explainQuery(String sql,
File path)
Explain query.
|
String |
getAllPreparedQueries(String queryName,
String userName,
String fromDate,
String toDate)
Gets the all prepared queries.
|
String |
getAllQueries(String state,
String queryName,
String user,
String driver,
String fromDate,
String toDate)
Gets the all queries.
|
String |
getDetails(String qh)
Gets the query details.
|
String |
getPreparedStatus(String ph)
Gets the prepared status.
|
String |
getQueryResults(String qh,
File path,
boolean async)
Gets the query results.
|
String |
getStatus(String qh)
Gets the status.
|
String |
killQuery(String qh)
Kill query.
|
String |
prepare(String sql,
String queryName)
Prepare.
|
afterReturningInvocation, afterThrowingInvocation, beforeInvocation, formatDate, formatJson, getClient, getClientWrapper, getOrDefaultQueryHandleString, getValidPath, removePrefixBeforeURI, setClient
public static final String DEFAULT_QUERY_HANDLE_DESCRIPTION
@CliCommand(value="select", help="Execute query
@CliCommand(value="cube select", help="Execute cube query. If is true, The query is launched in async manner and query handle is returned. It\'s by default false. can also be provided, though not required.") public String executeCubeSelectQuery(@CliOption(key="",mandatory=true,help=" ") String sql, @CliOption(key="async",mandatory=false,unspecifiedDefaultValue="false",specifiedDefaultValue="true",help=" ") boolean async, @CliOption(key="name",mandatory=false,help=" ") String queryName)
@CliCommand(value="query execute", help="Execute query. If is true, The query is launched in async manner and query handle is returned. It\'s by default false. can also be provided, though not required.") public String executeQuery(@CliOption(key={"","query"},mandatory=true,help=" ") String sql, @CliOption(key="async",mandatory=false,unspecifiedDefaultValue="false",specifiedDefaultValue="true",help=" ") boolean async, @CliOption(key="name",mandatory=false,help=" ") String queryName)
sql
- the sqlasync
- the asynchqueryName
- the query name@CliCommand(value="query status", help="Fetch status of executed query having query handle. If not provided, takes last query handle interacted with.") public String getStatus(@CliOption(key={"","query_handle"},mandatory=false,help=" ") String qh)
qh
- the qh@CliCommand(value="query details", help="Get query details of query with handle.If not provided, takes last query handle interacted with.") public String getDetails(@CliOption(key={"","query_handle"},mandatory=false,help=" ") String qh)
qh
- the qh@CliCommand(value="query explain", help="Explain execution plan of query. Can optionally save the plan to a file by providing ") public String explainQuery(@CliOption(key={"","query"},mandatory=true,help=" ") String sql, @CliOption(key="save_location",mandatory=false,help=" ") File path) throws IOException, LensAPIException
sql
- the sqlLensAPIException
UnsupportedEncodingException
- the unsupported encoding exceptionIOException
@CliCommand(value="query list", help="Get all queries. Various filter options can be provided(optionally), as can be seen from the command syntax") public String getAllQueries(@CliOption(key="state",mandatory=false,help="") String state, @CliOption(key="name",mandatory=false,help=" ") String queryName, @CliOption(key="user",mandatory=false,help=" ") String user, @CliOption(key="driver",mandatory=false,help=" ") String driver, @CliOption(key="fromDate",mandatory=false,help=" ") String fromDate, @CliOption(key="toDate",mandatory=false,help=" ") String toDate)
state
- the statequeryName
- the query nameuser
- the userdriver
- the driver namefromDate
- the from datetoDate
- the to date@CliCommand(value="query kill", help="Kill query with handle.If not provided, takes last query handle interacted with.") public String killQuery(@CliOption(key={"","query_handle"},mandatory=false,help=" ") String qh)
qh
- the qh@CliCommand(value="query results", help="get results of query with query handle. If not provided, takes last query handle interacted with.If async is false then wait till the query execution is completed, it\'s by default true. Can optionally save the results to a file by providing .") public String getQueryResults(@CliOption(key={"","query_handle"},mandatory=false,help=" ") String qh, @CliOption(key="save_location",mandatory=false,help=" ") File path, @CliOption(key="async",mandatory=false,unspecifiedDefaultValue="true",help=" ") boolean async)
qh
- the qh@CliCommand(value="prepQuery list", help="Get all prepared queries. Various filters can be provided(optionally) as can be seen from command syntax") public String getAllPreparedQueries(@CliOption(key="name",mandatory=false,help="") String queryName, @CliOption(key="user",mandatory=false,help=" ") String userName, @CliOption(key="fromDate",mandatory=false,help=" ") String fromDate, @CliOption(key="toDate",mandatory=false,help=" ") String toDate)
userName
- the user namequeryName
- the query namefromDate
- the from datetoDate
- the to date@CliCommand(value="prepQuery details", help="Get prepared query with handle") public String getPreparedStatus(@CliOption(key={"","prepare_handle"},mandatory=true,help=" ") String ph)
ph
- the ph@CliCommand(value="prepQuery destroy", help="Destroy prepared query with handle") public String destroyPreparedQuery(@CliOption(key={"","prepare_handle"},mandatory=true,help=" ") String ph)
ph
- the ph@CliCommand(value="prepQuery execute", help="Execute prepared query with handle. If is supplied and is true, query is run in async manner and query handle is returned immediately. Optionally, can be provided, though not required.") public String executePreparedQuery(@CliOption(key={"","prepare_handle"},mandatory=true,help="Prepare handle to execute") String phandle, @CliOption(key="async",mandatory=false,unspecifiedDefaultValue="false",specifiedDefaultValue="true",help=" ") boolean async, @CliOption(key="name",mandatory=false,help=" ") String queryName)
phandle
- the phandleasync
- the asynchqueryName
- the query name@CliCommand(value="prepQuery prepare", help="Prepapre queryand return prepare handle. Can optionaly provide ") public String prepare(@CliOption(key={"","query"},mandatory=true,help=" ") String sql, @CliOption(key="name",mandatory=false,help=" ") String queryName) throws UnsupportedEncodingException, LensAPIException
sql
- the sqlqueryName
- the query nameUnsupportedEncodingException
- the unsupported encoding exceptionLensAPIException
@CliCommand(value="prepQuery explain", help="Explain and prepare query. Can optionally provide ") public String explainAndPrepare(@CliOption(key={"","query"},mandatory=true,help=" ") String sql, @CliOption(key="name",mandatory=false,help=" ") String queryName) throws UnsupportedEncodingException, LensAPIException
sql
- the sqlqueryName
- the query nameUnsupportedEncodingException
- the unsupported encoding exceptionLensAPIException
Copyright © 2014–2016 Apache Software Foundation. All rights reserved.