-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: delete / cancel query #11708
Merged
Merged
docs: delete / cancel query #11708
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a01e289
draft delete query
techdocsmith 336fe0e
Update docs/querying/sql.md
techdocsmith b8a43d1
Update docs/querying/sql.md
techdocsmith 212fbed
Update docs/querying/sql.md
techdocsmith 1b53481
address comments
techdocsmith a7c0094
Update docs/querying/sql.md
techdocsmith ee41c11
Update docs/querying/sql.md
techdocsmith 390b00a
Update sql.md
techdocsmith bd03875
Update sql.md
techdocsmith 6a83d7b
Update sql.md
techdocsmith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -849,7 +849,6 @@ include: | |
|
||
- [Inline datasources](datasource.md#inline). | ||
- [Spatial filters](../development/geo.md). | ||
- [Query cancellation](querying.md#query-cancellation). | ||
- [Multi-value dimensions](#multi-value-strings) are only partially implemented in Druid SQL. There are known | ||
inconsistencies between their behavior in SQL queries and in native queries due to how they are currently treated by | ||
the SQL planner. | ||
|
@@ -860,8 +859,15 @@ the SQL planner. | |
|
||
### HTTP POST | ||
|
||
You can make Druid SQL queries using HTTP via POST to the endpoint `/druid/v2/sql/`. The request should | ||
be a JSON object with a "query" field, like `{"query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar'"}`. | ||
To use the SQL API to make Druid SQL queries, POST your query to the following endpoint on either the Router or Broker: | ||
``` | ||
POST https://ROUTER:8082/druid/v2/sql/`. | ||
``` | ||
|
||
Submit your query as the value of a "query" field in the JSON object within the request payload. For example: | ||
```json | ||
{"query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar'"} | ||
``` | ||
|
||
##### Request | ||
|
||
|
@@ -879,7 +885,7 @@ You can use _curl_ to send SQL queries from the command-line: | |
$ cat query.json | ||
{"query":"SELECT COUNT(*) AS TheCount FROM data_source"} | ||
|
||
$ curl -XPOST -H'Content-Type: application/json' http://BROKER:8082/druid/v2/sql/ -d @query.json | ||
$ curl -XPOST -H'Content-Type: application/json' http://ROUTER:8082/druid/v2/sql/ -d @query.json | ||
[{"TheCount":24433}] | ||
``` | ||
|
||
|
@@ -956,6 +962,37 @@ trailer they all include: one blank line at the end of the result set. If you de | |
through a JSON parsing error or through a missing trailing newline, you should assume the response was not fully | ||
delivered due to an error. | ||
|
||
### HTTP DELETE | ||
You can use the HTTP `DELETE` method to cancel a SQL query on either the Router or the Broker. When you cancel a query, Druid handles the cancellation in a best-effort manner. It marks the query canceled immediately and aborts the query execution as soon as possible. However, your query may run for a short time after your cancellation request. | ||
|
||
Druid SQL's HTTP DELETE method uses the following syntax: | ||
``` | ||
DELETE https://ROUTER:8082/druid/v2/sql/{sqlQueryId} | ||
``` | ||
|
||
The DELETE method requires the `sqlQueryId` path parameter. To predict the query id you must set it in the query context. Druid does not enforce unique `sqlQeryId` in the query context. If you issue a cancel request for a `sqlQeryId` active in more than one query context, Druid cancels all requests that use the query id. | ||
techdocsmith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
For example if you issue the following query: | ||
```bash | ||
curl --request POST 'https://ROUTER:8082/druid/v2/sql' \ | ||
--header 'Content-Type: application/json' \ | ||
--data-raw '{"query" : "SELECT sleep(CASE WHEN sum_added > 0 THEN 1 ELSE 0 END) FROM wikiticker WHERE sum_added > 0 LIMIT 15", | ||
"context" : {"sqlQueryId" : "myQuery01"}}' | ||
``` | ||
You can cancel the query using the query id `myQuery01` as follows: | ||
```bash | ||
curl --request DELETE 'https://ROUTER:8082/druid/v2/sql/myQuery01' \ | ||
``` | ||
|
||
Cancellation requests require READ permission on all resources used in the sql query. | ||
|
||
Druid returns an HTTP 202 response for successful deletion requests. | ||
|
||
Druid returns an HTTP 404 response in the following cases: | ||
- Authorization fails. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry @techdocsmith, now it return 403. Can you update the doc one last time? |
||
- The query id is incorrect. | ||
techdocsmith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- The query completes before your cancellation request is processed. | ||
|
||
### JDBC | ||
|
||
You can make Druid SQL queries using the [Avatica JDBC driver](https://calcite.apache.org/avatica/downloads/). We recommend using Avatica JDBC driver version 1.17.0 or later. Note that as of the time of this writing, Avatica 1.17.0, the latest version, does not support passing connection string parameters from the URL to Druid, so you must pass them using a `Properties` object. Once you've downloaded the Avatica client jar, add it to your classpath and use the connect string `jdbc:avatica:remote:url=http://BROKER:8082/druid/v2/sql/avatica/`. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Router uses the port 8888 by default while broker uses 8082.