Submit an SQL Query

This API submits an SQL query.


POST /api/v3/sql

Request Input

  "sql": String,
  "context": [String] [optional]
Parameter Description
sql Represents the SQL query you want to run.
context (Optional) Path for the query to run in.

Response Output

Returns a Jobs ID for the query. Monitoring of the job status and fetching results needs to be completed using the Jobs endpoint.

  "id": String

Example: Query the dataset and receive a Job ID

Querying a dataset (with SQL) and returning the query status and results is a two-part process that involves both the SQL API and the Job API.

  1. You submit your SQL query with the SQL API and receive a Job ID for the query.
  2. You then submit the Job ID with the Job API to get the query status and/or results.

In this example, a weapons_laws dataset was created in the SFIncidents space from the provided SF_Incidents2016.json Sample. Only Weapons Laws incidents are in the dataset.

For this example, the following equivalent Dremio UI query on the weapons_laws dataset is used:

SELECT * FROM weapons_laws WHERE PdDistrict = 'CENTRAL' LIMIT 3

Postman was used to generate samples.

HTTP request

POST localhost:9047/apiv3/sql

Body Raw Input:

	"sql": "SELECT * FROM SFIncidents.weapons_laws WHERE PdDistrict = 'CENTRAL' LIMIT 3"


curl -X POST \
  http://localhost:9047/api/v3/sql \
  -H 'Authorization: _dremioicmqi0aoro8o0el8rj0jfjh6n0' \
  -H 'Content-Type: application/json' \
  -d '{
	"sql": "SELECT * FROM SFIncidents.weapons_laws WHERE PdDistrict = '\''CENTRAL'\'' LIMIT 3"


import requests

url = "http://localhost:9047/api/v3/sql"

payload = "{\n\t\"sql\": \"SELECT * FROM SFIncidents.weapons_laws WHERE PdDistrict = 'CENTRAL' LIMIT 3\"\n}"
headers = {
    'Authorization': "_dremioicmqi0aoro8o0el8rj0jfjh6n0",
    'Content-Type': "application/json"

response = requests.request("POST", url, data=payload, headers=headers)



The request example, returns a Job ID. This ID is used with JOB API to retrieve the query status and results.

    "id": "23a4bf43-52aa-5d29-c473-0083c44fe700"

Example: Using the Job API

The following requests use the Job API and the returned Job ID, 23a4bf43-52aa-5d29-c473-0083c44fe700, to retrieve the query status and results. See the Job API GET /job/{id} for detailed request inputs and response outputs.

HTTP request for status

GET localhost:9047/api/v3/job/23a4bf43-52aa-5d29-c473-0083c44fe700

HTTP request for results

GET localhost:9047/api/v3/job/23a4bf43-52aa-5d29-c473-0083c44fe700/results