Skip to main content
Version: current [24.2.x]

SQL

Use the SQL API to submit SQL queries. The response contains the ID for the job associated with the SQL query. Use the job ID in Job API requests to get more information about the job, including results.

Submitting an SQL Query

Submit an SQL query and retrieve the associated job ID for use in Job API requests.

Method and URL
POST /api/v3/sql

Parameters

sql

body

String

SQL query to run.

Note: Double-quotation marks within a SQL statement need to be escaped.

Example SELECT * FROM Samples."samples.dremio.com"."SF weather 2018-2019.csv"


context

body

[String]

Optional

Path to the container where the query should run within Dremio, expressed as an array. The path consists of the source or space, followed by the folder and subfolders.

Example ["Samples", "samples.dremio.com"]


references

body

Object

Optional

References to the specific versions (branches, tags, and commits) in Nessie sources where you want to run the SQL query. If references are not specified for a Nessie source, the SQL query runs on the default branch. Available in Dremio version 24.1.2 and later.

Example { "nessieSource1": { "type": "BRANCH", "value": "testing" }, "nessieSource2": { "type": "TAG", "value": "Test commit" }, "nessieSource3": { "type": "COMMIT", "value": "7a5edb57e035f52beccfab632cea070514eb8b773f616aaeaf668e2f0be8f10d" } }

references Parameters

<Nessie source>

body

String

Optional

The name of the Nessie source where you want to run the SQL query. Available in Dremio version 24.1.2 and later.

Example nessieSource1

<Nessie source> Parameters

type

body

String

Optional

The type of Nessie source object where you want to run the SQL query. Available in Dremio version 24.1.2 and later.

Enum BRANCH, TAG, COMMIT

Example BRANCH


value

body

String

Optional

The branch or tag name or commit hash in the Nessie source on which you want to run the SQL query. Available in Dremio version 24.1.2 and later.

Example testing


Example Request Using Only the SQL Parameter
curl -X POST 'https://{hostname}/api/v3/sql' \
--header 'Authorization: Bearer <PersonalAccessToken>' \
--header 'Content-Type: application/json' \
--data-raw '{
"sql": "SELECT * FROM Samples.\"samples.dremio.com\".\"SF weather 2018-2019.csv\""
}'
Example Request Using Optional Parameters
curl -X POST 'https://{hostname}/api/v3/sql' \
--header 'Authorization: Bearer <PersonalAccessToken>' \
--header 'Content-Type: application/json' \
--data-raw '{
"sql": "SELECT * FROM \"SF weather 2018-2019.csv\"",
"context": [
"Samples",
"samples.dremio.com"
],
"references": {
"nessieSource1": {
"type": "BRANCH",
"value": "testing"
},
"nessieSource2": {
"type": "TAG",
"value": "Test commit"
},
"nessieSource3": {
"type": "COMMIT",
"value": "7a5edb57e035f52beccfab632cea070514eb8b773f616aaeaf668e2f0be8f10d"
}
}
}'
Example Response
{
"id": "2f067496-7cf0-a70e-0222-34d53a5dc800"
}

Response Status Codes

200

OK

400

Bad Request

401

Unauthorized

404

Not Found