Skip to content

Access database via Druid Rest SQL queries

Sending a query:

The database can also be accessed with Druid Rest SQL queries.

To do so, first of all, using a POST method, send your query to the Router. Curl can be used to send SQL queries from the command-line:

curl  -X POST -H "Content-Type: application/json" -u <Your Workgroup ID>:<Your Workgroup KEY> https://<Your Mining Platform URL>/druid/v2/sql/ --data-raw '{"query": "SELECT * FROM <ds.name> "}'

The query must be specified after "query", in --data-raw.

Alternatively, SQL queries can also be sent as follows:

 cat query.json
{"query": "SELECT * FROM <ds.name> "}
curl  -X POST -H "Content-Type: application/json" -u <Your Workgroup ID>:<Your Workgroup KEY> https://<Your Mining Platform URL>/druid/v2/sql/ --data-raw @query.json

Responses:

The result format of the query can be specified with "resultFormat":

{
  "query": "SELECT * FROM <ds.name>",
  "resultFormat": "array"
}