Scripts
Use the Scripts API to manage scripts, retrieve the contents of scripts for use in a scheduler, retrieve and update privileges on scripts, and migrate scripts between different environments.
Scripts Object{
"total": 3,
"data": [
{
"id": "74cfddfd-cb0b-4b2f-b555-cb8b827fec1e",
"name": "newScript",
"content": "SELECT * FROM sampledb",
"context": [
"@dremio",
"scriptsFolder"
],
"owner": "8be516f3-04c4-4d19-824d-5a70b3c4442e",
"createdAt": "2024-05-24T17:42:00.304Z",
"createdBy": "a97c694f-1e55-4f34-91aa-97f99fee802e",
"modifiedAt": "2024-05-24T17:42:00.304Z",
"modifiedBy": "a97c694f-1e55-4f34-91aa-97f99fee802e"
},
{
"id": "37dab994-3f1f-4de7-b2e7-49cb5ff0b395",
"name": "tmp_testing_04-15-24",
"content": "-- create table accounting_storage.\"tmp.dremio.com\".test1(id INT);\n-- refresh dataset test1\nalter table test1 REFRESH METADATA;",
"context": [
"accounting_storage",
"tmp.dremio.com"
],
"owner": "ba92bf87-174d-422e-becb-d526757c8099",
"createdAt": "2024-04-15T10:38:31.433Z",
"createdBy": "ba92bf87-174d-422e-becb-d526757c8099",
"modifiedAt": "2024-04-15T11:03:27.542Z",
"modifiedBy": "ba92bf87-174d-422e-becb-d526757c8099"
},
{
"id": "02fef13e-cedd-46ac-b5bf-abcdcd092146",
"name": "pop10000_A",
"content": "SELECT * FROM Samples.\"samples.dremio.com\".\"zips.json\" WHERE pop > 10000 AND STARTS_WITH(city, 'A');\n\nCREATE OR REPLACE VIEW myView AS\nSELECT city, state, pop FROM Samples.\"samples.dremio.com\".\"zips.json\"\nWHERE pop > 10000;\n\nCREATE OR REPLACE VIEW myView2 AS\nSELECT * FROM myView\nWHERE STARTS_WITH(city, 'A');\n\nALTER TABLE myView2 \nCREATE RAW REFLECTION myReflection \nUSING DISPLAY(city, state, pop);\n\nSELECT * FROM myView2;\n\nCREATE OR REPLACE FUNCTION isMA(state VARCHAR)\n RETURNS BOOLEAN\n RETURN SELECT state = 'MA';\n\nALTER TABLE myView ADD ROW ACCESS POLICY isMA(\"state\");\n\nSELECT * FROM myView2;\n\n// Refresh the reflection\n\nSELECT * FROM myView2;",
"context": [
"@dev"
],
"owner": "7a92baf7-646a-4bc5-b0f4-eaf18d0a9921",
"createdAt": "2024-05-16T18:08:06.363Z",
"createdBy": "7a92baf7-646a-4bc5-b0f4-eaf18d0a9921",
"modifiedAt": "2024-05-16T18:31:22.593Z",
"modifiedBy": "7a92baf7-646a-4bc5-b0f4-eaf18d0a9921"
}
]
}
Scripts Attributes
total Integer
Total number of scripts in the organization.
Example: 3
data Array of Object
List of the scripts in the organization, with an individual object representing each script.
Attributes of Objects in the data
Array
id String (UUID)
Unique identifier of the script. Generated by Dremio and immutable.
Example: 74cfddfd-cb0b-4b2f-b555-cb8b827fec1e
name String
User-provided name of the script.
Example: newScript
content String
The script's SQL.
Example: SELECT * FROM sampledb
context Array of String
Path where the SQL query specified in the content attribute runs. If no context is specified for the script, the value is an empty array.
Example: ["@dremio","scriptsFolder"]
owner String
Unique identifier for the user who owns the script.
Example: 8be516f3-04c4-4d19-824d-5a70b3c4442e
createdAt String
Date and time that the script was created. In UTC format.
Example: 2024-05-24T17:42:00.304Z
createdBy String
The unique identifier for the user who created the script.
Example: a97c694f-1e55-4f34-91aa-97f99fee802e
modifiedAt String
Date and time that the script was last modified. In UTC format.
Example: 2024-05-24T17:42:00.304Z
modifiedBy String
The unique identifier for the user who last modified the script.
Example: a97c694f-1e55-4f34-91aa-97f99fee802e
Creating a Script
Create a script.
Method and URLPOST /api/v3/scripts
Parameters
name Body String
Name to use for the script.
Example: newScript
content Body String
The SQL for the script.
Example: SELECT * FROM sampledb
context Body Array of String Optional
Path where the SQL query specified in the content attribute should run.
Example: ["@dremio","scriptsFolder"]
owner Body String