Skip to main content

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 /v0/projects/{project-id}/sql

Parameters

project-id Path   String (UUID)

Unique identifier of the project for which you want to submit a SQL query.

Example: 02a36975-73bc-47de-9fg5-ff73060380f6


sql Body   String

SQL query to run. 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   Array of String   Optional

Path to the container where the query should run within Dremio, expressed as an array. The path consists of the source, 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 Arctic 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.

Example: {"myCatalog": {"type": "BRANCH","value": "testing"},"anotherCatalog": {"type": "TAG","value": "Test commit"},"thirdCatalog": {"type": "COMMIT","value": "7a5edb57e035f52beccfab632cea070514eb8b773f616aaeaf668e2f0be8f10d"}}}

Parameters of the references Object

<Arctic source> Body   Object   Optional

The name of the Arctic source where you want to run the SQL query.

Example: myCatalog


Parameters of the <Arctic source> Object

type Body   String   Optional

The type of Arctic source object where you want to run the SQL query.

Enum: BRANCH, TAG, COMMIT

Example: BRANCH


value Body   String   Optional

The branch or tag name or commit hash in the Arctic source on which you want to run the SQL query.

Example: testing

Example Request Using Only the SQL Parameter
curl -X POST 'https://api.dremio.cloud/v0/projects/02a36975-73bc-47de-9fg5-ff73060380f6/sql' \
--header 'Authorization: Bearer <personal access token>' \
--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://api.dremio.cloud/v0/projects/02a36975-73bc-47de-9fg5-ff73060380f6/sql' \
--header 'Authorization: Bearer <personal access token>' \
--header 'Content-Type: application/json' \
--data-raw '{
"sql": "SELECT * FROM \"SF weather 2018-2019.csv\"",
"context": [
"Samples",
"samples.dremio.com"
],
"references": {
"myCatalog": {
"type": "BRANCH",
"value": "testing"
},
"anotherCatalog": {
"type": "TAG",
"value": "Test commit"
},
"thirdCatalog": {
"type": "COMMIT",
"value": "7a5edb57e035f52beccfab632cea070514eb8b773f616aaeaf668e2f0be8f10d"
}
}
}'
Example Response
{
"id":"ab45c784-3593-5d12-0e42-0fgb5hij4k00"
}

Response Status Codes

200   OK

400   Bad Request

401   Unauthorized

404   Not Found

500   Internal Server Error