@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 <<<query execute cube select id,name from dim_table where name != \"\"first\"\">>>,\n will be parsed as <<<cube select id,name from dim_table where name != \"first\">>>") 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 <select query-string-without-select>. If <async> is true, The query is launched in async manner and query handle is returned. It\'s by default false. <query name> can also be provided, though not required.") public String executeSelectQuery(@CliOption(key="",mandatory=true,help="<query-string-without-select>") String sql, @CliOption(key="async",mandatory=false,unspecifiedDefaultValue="false",specifiedDefaultValue="true",help="<async>") boolean async, @CliOption(key="name",mandatory=false,help="<query-name>") String queryName)
@CliCommand(value="cube select", help="Execute cube query <cube select query-string-without-cube-select>. If <async> is true, The query is launched in async manner and query handle is returned. It\'s by default false. <query name> can also be provided, though not required.") public String executeCubeSelectQuery(@CliOption(key="",mandatory=true,help="<query-string-without-cube-select>") String sql, @CliOption(key="async",mandatory=false,unspecifiedDefaultValue="false",specifiedDefaultValue="true",help="<async>") boolean async, @CliOption(key="name",mandatory=false,help="<query-name>") String queryName)
@CliCommand(value="query execute", help="Execute query <query-string>. If <async> is true, The query is launched in async manner and query handle is returned. It\'s by default false. <query name> can also be provided, though not required.") public String executeQuery(@CliOption(key={"","query"},mandatory=true,help="<query-string>") String sql, @CliOption(key="async",mandatory=false,unspecifiedDefaultValue="false",specifiedDefaultValue="true",help="<async>") boolean async, @CliOption(key="name",mandatory=false,help="<query-name>") String queryName)
sql
- the sqlasync
- the asynchqueryName
- the query name@CliCommand(value="query status", help="Fetch status of executed query having query handle <query_handle>. If not provided, takes last query handle interacted with.") public String getStatus(@CliOption(key={"","query_handle"},mandatory=false,help="<query_handle>") String qh)
qh
- the qh@CliCommand(value="query details", help="Get query details of query with handle <query_handle>.If not provided, takes last query handle interacted with.") public String getDetails(@CliOption(key={"","query_handle"},mandatory=false,help="<query_handle>") String qh)
qh
- the qh@CliCommand(value="query explain", help="Explain execution plan of query <query-string>. Can optionally save the plan to a file by providing <save_location>") public String explainQuery(@CliOption(key={"","query"},mandatory=true,help="<query-string>") String sql, @CliOption(key="save_location",mandatory=false,help="<save_location>") 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="<query-status>") String state, @CliOption(key="name",mandatory=false,help="<query-name>") String queryName, @CliOption(key="user",mandatory=false,help="<user-who-submitted-query>") String user, @CliOption(key="driver",mandatory=false,help="<driver-where-query-ran>") String driver, @CliOption(key="fromDate",mandatory=false,help="<submission-time-is-after>") String fromDate, @CliOption(key="toDate",mandatory=false,help="<submission-time-is-before>") 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 <query_handle>.If not provided, takes last query handle interacted with.") public String killQuery(@CliOption(key={"","query_handle"},mandatory=false,help="<query_handle>") String qh)
qh
- the qh@CliCommand(value="query results", help="get results of query with query handle <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 <save_location>.") public String getQueryResults(@CliOption(key={"","query_handle"},mandatory=false,help="<query_handle>") String qh, @CliOption(key="save_location",mandatory=false,help="<save_location>") File path, @CliOption(key="async",mandatory=false,unspecifiedDefaultValue="true",help="<async>") 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="<query-name>") String queryName, @CliOption(key="user",mandatory=false,help="<user-who-submitted-query>") String userName, @CliOption(key="fromDate",mandatory=false,help="<submission-time-is-after>") String fromDate, @CliOption(key="toDate",mandatory=false,help="<submission-time-is-before>") 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 <prepare_handle>") public String getPreparedStatus(@CliOption(key={"","prepare_handle"},mandatory=true,help="<prepare_handle>") String ph)
ph
- the ph@CliCommand(value="prepQuery destroy", help="Destroy prepared query with handle <prepare_handle>") public String destroyPreparedQuery(@CliOption(key={"","prepare_handle"},mandatory=true,help="<prepare_handle>") String ph)
ph
- the ph@CliCommand(value="prepQuery execute", help="Execute prepared query with handle <prepare_handle>. If <async> is supplied and is true, query is run in async manner and query handle is returned immediately. Optionally, <query-name> 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="<async>") boolean async, @CliOption(key="name",mandatory=false,help="<query-name>") String queryName)
phandle
- the phandleasync
- the asynchqueryName
- the query name@CliCommand(value="prepQuery prepare", help="Prepapre query <query-string> and return prepare handle. Can optionaly provide <query-name>") public String prepare(@CliOption(key={"","query"},mandatory=true,help="<query-string>") String sql, @CliOption(key="name",mandatory=false,help="<query-name>") String queryName) throws UnsupportedEncodingException, LensAPIException
sql
- the sqlqueryName
- the query nameUnsupportedEncodingException
- the unsupported encoding exceptionLensAPIException
@CliCommand(value="prepQuery explain", help="Explain and prepare query <query-string>. Can optionally provide <query-name>") public String explainAndPrepare(@CliOption(key={"","query"},mandatory=true,help="<query-string>") String sql, @CliOption(key="name",mandatory=false,help="<query-name>") String queryName) throws UnsupportedEncodingException, LensAPIException
sql
- the sqlqueryName
- the query nameUnsupportedEncodingException
- the unsupported encoding exceptionLensAPIException
Copyright © 2014–2018 Apache Software Foundation. All rights reserved.