- Home
- Resources
- QueryServiceResource
queryapi resource
This provides api for all things query.
GET /queryapi
API to know if Query service is up and running
Response Body
media type |
data type |
description |
text/plain |
(custom)
|
Simple text saying it up |
GET /queryapi/queries
Get all the queries in the query server; can be filtered with state and queryName. This will by default only return
queries submitted by the user that has started the session. To get queries of all users, set the searchAllUsers
parameter to false.
Request Parameters
name |
type |
description |
driver |
query |
Get queries submitted on a specific driver. |
fromDate |
query |
from date to search queries in a time range, the range is inclusive(submitTime >= fromDate)
from date can be a long value indicating timestamp, or it can be in a format acceptable in
time_range_in function. Notably: yyyy[-MM[-dd[-HH-[mm...]]]], or now based relative format |
queryName |
query |
If any queryName is passed, all the queries containing the queryName will be returned, otherwise
all the queries will be returned |
sessionid |
query |
The sessionid in which queryName is working |
state |
query |
If any state is passed, all the queries in that state will be returned, otherwise all queries will
be returned. Possible states are {link QueryStatus.Status#values()}. Multiple states can be
passed as comma separated string |
toDate |
query |
to date to search queries in a time range, the range is inclusive(toDate > submitTime)
possible formats it can take is same as fromDate |
user |
query |
Returns queries submitted by this user. If set to "all", returns queries of all users. By default,
returns queries of the current user. |
Response Body
media type |
data type |
description |
application/json |
array of QueryHandle
(JSON) |
List of QueryHandle objects |
application/json |
array of QueryHandle
(JSON) |
application/xml |
list of queryHandle
(XML) |
text/plain |
(custom)
|
POST /queryapi/queries
Submit the query for explain or execute or execute with a timeout.
Request Parameters
name |
type |
description |
default |
constraints |
conf |
formdata |
The configuration for the query |
|
|
operation |
formdata |
The operation on the query. Supported operations are values:
org.apache.lens.api.query.SubmitOp#ESTIMATE,
org.apache.lens.api.query.SubmitOp#EXPLAIN,
org.apache.lens.api.query.SubmitOp#EXECUTE and
org.apache.lens.api.query.SubmitOp#EXECUTE_WITH_TIMEOUT |
|
|
query |
formdata |
The query to run |
|
|
queryName |
formdata |
human readable query name set by user (optional parameter) |
|
|
sessionid |
formdata |
The session in which user is submitting the query. Any configuration set in the session will
be picked up. |
|
|
timeoutmillis |
formdata |
The timeout for the query. If the query does not finish within the specified
timeout, it is automatically cancelled unless user specified otherwise
by setting configuration lens.query.cancel.on.timeout = false.
Note: The timeout parameter is honored only in case of operation |
30000 |
long |
Response Body
media type |
data type |
description |
application/json |
LensAPIResult
(JSON) |
LensAPIResult with DATA as QueryHandle in case of
org.apache.lens.api.query.SubmitOp#EXECUTE operation.
QueryPlan in case of org.apache.lens.api.query.SubmitOp#EXPLAIN operation.
QueryHandleWithResultSet in case org.apache.lens.api.query.SubmitOp#EXECUTE_WITH_TIMEOUT
operation. org.apache.lens.api.result.QueryCostTO in case of
org.apache.lens.api.query.SubmitOp#ESTIMATE operation. |
application/json |
LensAPIResult
(JSON) |
application/xml |
lensAPIResult
(XML) |
text/plain |
(custom)
|
DELETE /queryapi/queries
Cancel all the queries in query server; can be filtered with state and user.
Request Parameters
name |
type |
description |
default |
driver |
query |
Get queries submitted on a specific driver. |
|
fromDate |
query |
the from date, inclusive(submitTime>=fromDate) |
|
queryName |
query |
Cancel queries matching the query name |
|
sessionid |
query |
The session in which cancel is issued |
|
state |
query |
If any state is passed, all the queries in that state will be cancelled, otherwise all queries
will be cancelled. Possible states are
org.apache.lens.api.query.QueryStatus.Status#values()
The queries in org.apache.lens.api.query.QueryStatus.Status#FAILED,
org.apache.lens.api.query.QueryStatus.Status#CLOSED,
org.apache.lens.api.query.QueryStatus.Status#SUCCESSFUL cannot be cancelled |
|
toDate |
query |
the to date, inclusive(toDate>=submitTime) |
|
user |
query |
If any user is passed, all the queries submitted by the user will be cancelled, otherwise all the
queries will be cancelled |
|
Response Body
media type |
data type |
description |
application/json |
APIResult
(JSON) |
APIResult with state org.apache.lens.api.APIResult.Status#SUCCEEDED in case of successful
cancellation. APIResult with state org.apache.lens.api.APIResult.Status#FAILED
in case of cancellation failure. APIResult with state
org.apache.lens.api.APIResult.Status#PARTIAL in case of partial cancellation. |
application/json |
APIResult
(JSON) |
application/xml |
APIResult
(XML) |
text/plain |
(custom)
|
GET /queryapi/preparedqueries
Get all prepared queries in the query server; can be filtered with user.
Request Parameters
name |
type |
description |
default |
fromDate |
query |
start time for filtering prepared queries by preparation time |
|
queryName |
query |
returns queries matching the query name |
|
sessionid |
query |
The sessionid in which user is working |
|
toDate |
query |
end time for filtering prepared queries by preparation time |
|
user |
query |
returns queries of the user. If set to "all", returns queries of all users. By default returns the
queries of the current user. |
|
POST /queryapi/preparedqueries
Prepare a query or 'explain and prepare' the query.
Request Parameters
name |
type |
description |
default |
conf |
formdata |
The configuration for preparing the query |
|
operation |
formdata |
The operation on the query. Supported operations are
org.apache.lens.api.query.SubmitOp#EXPLAIN_AND_PREPARE or
org.apache.lens.api.query.SubmitOp#PREPARE |
|
query |
formdata |
The query to prepare |
|
queryName |
formdata |
human readable query name set by user (optional parameter) |
|
sessionid |
formdata |
The session in which user is preparing the query. Any configuration set in the session will be
picked up. |
|
Response Body
media type |
data type |
description |
application/json |
LensAPIResult
(JSON) |
QueryPrepareHandle incase of {link org.apache.lens.api.query.SubmitOp#PREPARE} operation.
QueryPlan incase of org.apache.lens.api.query.SubmitOp#EXPLAIN_AND_PREPARE
and the query plan will contain the prepare handle as well. |
application/json |
LensAPIResult
(JSON) |
application/xml |
lensAPIResult
(XML) |
text/plain |
(custom)
|
DELETE /queryapi/preparedqueries
Destroy all the prepared queries; Can be filtered with user.
Request Parameters
name |
type |
description |
default |
fromDate |
query |
the from date |
|
queryName |
query |
destroys queries matching the query name |
|
sessionid |
query |
The session in which cancel is issued |
|
toDate |
query |
the to date |
|
user |
query |
destroys queries of the user. If set to "all", destroys queries of all users. By default destroys
the queries of the current user. |
|
Response Body
media type |
data type |
description |
application/json |
APIResult
(JSON) |
APIResult with state org.apache.lens.api.APIResult.Status#SUCCEEDED in case of successful
destroy. APIResult with state org.apache.lens.api.APIResult.Status#FAILED in case of destroy
failure. APIResult with state org.apache.lens.api.APIResult.Status#PARTIAL in case of
partial destroy. |
application/json |
APIResult
(JSON) |
application/xml |
APIResult
(XML) |
text/plain |
(custom)
|
GET /queryapi/preparedqueries/{prepareHandle}
Get a prepared query specified by handle.
Request Parameters
name |
type |
description |
prepareHandle |
path |
The prepare handle |
sessionid |
query |
The user session handle |
DELETE /queryapi/preparedqueries/{prepareHandle}
Destroy the prepared query specified by handle.
Request Parameters
name |
type |
description |
prepareHandle |
path |
The prepare handle |
sessionid |
query |
The user session handle |
Response Body
media type |
data type |
description |
application/json |
APIResult
(JSON) |
APIResult with state org.apache.lens.api.APIResult.Status#SUCCEEDED in case of successful
destroy. APIResult with state org.apache.lens.api.APIResult.Status#FAILED in case of
destroy failure. |
application/json |
APIResult
(JSON) |
application/xml |
APIResult
(XML) |
text/plain |
(custom)
|
GET /queryapi/queries/{queryHandle}
Get lens query and its current status.
Request Parameters
name |
type |
description |
queryHandle |
path |
The query handle |
sessionid |
query |
The user session handle |
Response Body
media type |
data type |
description |
application/json |
LensQuery
(JSON) |
LensQuery |
application/json |
LensQuery
(JSON) |
application/xml |
lensQuery
(XML) |
text/plain |
(custom)
|
DELETE /queryapi/queries/{queryHandle}
Cancel the query specified by the handle.
Request Parameters
name |
type |
description |
queryHandle |
path |
The query handle |
sessionid |
query |
The user session handle |
Response Body
media type |
data type |
description |
application/json |
APIResult
(JSON) |
APIResult with state org.apache.lens.api.APIResult.Status#SUCCEEDED in case of successful
cancellation. APIResult with state org.apache.lens.api.APIResult.Status#FAILED in case of
cancellation failure. |
application/json |
APIResult
(JSON) |
application/xml |
APIResult
(XML) |
text/plain |
(custom)
|
PUT /queryapi/queries/{queryHandle}
Modify query configuration if it is not running yet.
Request Parameters
name |
type |
description |
conf |
formdata |
The new configuration, will be on top of old one |
sessionid |
formdata |
The user session handle |
queryHandle |
path |
The query handle |
Response Body
media type |
data type |
description |
application/json |
APIResult
(JSON) |
APIResult with state org.apache.lens.api.APIResult.Status#SUCCEEDED in case of successful
update. APIResult with state org.apache.lens.api.APIResult.Status#FAILED in case of udpate failure. |
application/json |
APIResult
(JSON) |
application/xml |
APIResult
(XML) |
text/plain |
(custom)
|
PUT /queryapi/preparedqueries/{prepareHandle}
Modify prepared query's configuration. This would be picked up for subsequent runs of the prepared queries. The
query wont be re-prepared with new configuration.
Request Parameters
name |
type |
description |
conf |
formdata |
The new configuration, will be on top of old one |
sessionid |
formdata |
The user session handle |
prepareHandle |
path |
The prepare handle |
Response Body
media type |
data type |
description |
application/json |
APIResult
(JSON) |
APIResult with state org.apache.lens.api.APIResult.Status#SUCCEEDED in case of successful
update. APIResult with state org.apache.lens.api.APIResult.Status#FAILED in case of udpate failure. |
application/json |
APIResult
(JSON) |
application/xml |
APIResult
(XML) |
text/plain |
(custom)
|
POST /queryapi/preparedqueries/{prepareHandle}
Submit prepared query for execution.
Request Parameters
name |
type |
description |
default |
constraints |
conf |
formdata |
The configuration for the execution of query |
|
|
operation |
formdata |
The operation on the query. Supported operations are
org.apache.lens.api.query.SubmitOp#EXECUTE and |
EXECUTE |
|
queryName |
formdata |
human readable query name set by user (optional parameter) |
|
|
sessionid |
formdata |
The session in which user is submitting the query. Any configuration set in the session will
be picked up. |
|
|
timeoutmillis |
formdata |
The timeout for the query, honored only in case of
org.apache.lens.api.query.SubmitOp#EXECUTE_WITH_TIMEOUT operation |
30000 |
long |
prepareHandle |
path |
The Query to run |
|
|
Response Body
media type |
data type |
description |
application/json |
QuerySubmitResult
(JSON) |
QueryHandle in case of {link org.apache.lens.api.query.SubmitOp#EXECUTE} operation.
QueryHandleWithResultSet in case {@link org.apache.lens.api.query.SubmitOp#EXECUTE_WITH_TIMEOUT
} operation. |
application/json |
QuerySubmitResult
(JSON) |
application/xml |
querySubmitResult
(XML) |
text/plain |
(custom)
|
GET /queryapi/queries/{queryHandle}/resultset
Fetch the result set.
Request Parameters
name |
type |
description |
constraints |
queryHandle |
path |
The query handle |
|
fetchsize |
query |
fetch size |
int |
fromindex |
query |
start index of the result |
long |
sessionid |
query |
The user session handle |
|
Response Body
media type |
data type |
description |
application/json |
QueryResult
(JSON) |
QueryResult |
application/json |
QueryResult
(JSON) |
application/xml |
queryResult
(XML) |
text/plain |
(custom)
|
GET /queryapi/queries/{queryHandle}/httpresultset
Get the http endpoint for result set.
Request Parameters
name |
type |
description |
queryHandle |
path |
The query handle |
sessionid |
query |
The user session handle |
Response Body
media type |
data type |
description |
application/octet-stream |
(custom)
|
Response with result as octet stream |
DELETE /queryapi/queries/{queryHandle}/resultset
Close the result set once fetching is done.
Request Parameters
name |
type |
description |
queryHandle |
path |
The query handle |
sessionid |
query |
The user session handle |
Response Body
media type |
data type |
description |
application/json |
APIResult
(JSON) |
APIResult with state org.apache.lens.api.APIResult.Status#SUCCEEDED in case of successful
close. APIResult with state org.apache.lens.api.APIResult.Status#FAILED in case of close failure. |
application/json |
APIResult
(JSON) |
application/xml |
APIResult
(XML) |
text/plain |
(custom)
|