curl --request POST \
--url https://api-dev.narrative.io/datasets/{dataset_id}/refresh-materialized-view \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "full",
"execution_cluster": {
"type": "dedicated"
}
}
'import requests
url = "https://api-dev.narrative.io/datasets/{dataset_id}/refresh-materialized-view"
payload = {
"type": "full",
"execution_cluster": { "type": "dedicated" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({type: 'full', execution_cluster: {type: 'dedicated'}})
};
fetch('https://api-dev.narrative.io/datasets/{dataset_id}/refresh-materialized-view', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-dev.narrative.io/datasets/{dataset_id}/refresh-materialized-view",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'type' => 'full',
'execution_cluster' => [
'type' => 'dedicated'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-dev.narrative.io/datasets/{dataset_id}/refresh-materialized-view"
payload := strings.NewReader("{\n \"type\": \"full\",\n \"execution_cluster\": {\n \"type\": \"dedicated\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-dev.narrative.io/datasets/{dataset_id}/refresh-materialized-view")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"full\",\n \"execution_cluster\": {\n \"type\": \"dedicated\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/datasets/{dataset_id}/refresh-materialized-view")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"full\",\n \"execution_cluster\": {\n \"type\": \"dedicated\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"company_id": 345,
"created_at": "2023-11-07T05:31:56Z",
"failures": [
{
"message": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"value": {}
}
],
"idempotency_key": "<string>",
"request_source": {
"type": "api_user",
"company_id": 1,
"user_id": 1248
},
"state": "pending",
"updated_at": "2023-11-07T05:31:56Z",
"input": {
"compiled_select": "<string>",
"create_as_view": false,
"dataset": {
"id": 18923,
"company_id": 382,
"created_at": "2021-06-24T00:54:40.029056Z",
"data_plane": {
"type": "owned",
"id": "c0bed5c2-8af8-4f7a-9787-1ffc3def339b",
"company_id": 382,
"created_at": "2021-06-01T00:00:00Z",
"description": "The company's Snowflake account",
"display_name": "Snowflake (us-west-2)",
"external_id": "snowflake-prod",
"platform": {
"type": "platform_snowflake",
"account_locator": "ab12345",
"account_name": "acme",
"organization_name": "acmeorg",
"region": {
"type": "region_aws",
"id": "us-west-2"
}
},
"status": "active",
"tags": [],
"updated_at": "2021-06-01T00:00:00Z",
"collaborators": {
"participants": {
"type": "all"
},
"manage_compute_pools": {
"type": "all"
}
},
"compute_pools": []
},
"is_narrative_managed": true,
"retention_policy": {
"policies": [
{
"type": {
"kind": "snapshot_ttl",
"snapshot_retention_policy": {
"type": "retain_everything"
}
},
"enabled": true
}
]
},
"description": "Mobile identifiers tied to birth information provided as part of app registration.",
"name": "declared_age",
"display_name": "Declared Age",
"schema": {
"file_config": {
"type": "flat",
"delimiter": ",",
"escape": "\"",
"header": true,
"quote": "\""
},
"type": "object",
"properties": {
"idValue": {
"display_name": "id value",
"order": 0,
"approximate_cardinality": 100000,
"description": "ID values",
"type": "string"
},
"idType": {
"display_name": "id type",
"order": 1,
"approximate_cardinality": 1,
"type": "string",
"enum": [
"md5_email",
"sha256_email"
]
},
"eventTimestamp": {
"display_name": "event timestamp",
"order": 2,
"description": "When the observation was collected",
"type": "timestamptz",
"validations": [
"eventTimestamp < current_timestamp()"
]
},
"countryCode": {
"display_name": "country code",
"order": 3,
"approximate_cardinality": 6,
"description": "The country of residence of the individual",
"type": "string"
},
"age": {
"display_name": "age",
"order": 4,
"approximate_cardinality": 90,
"description": "How old this individual is in years",
"type": "long"
},
"birthInfo": {
"display_name": "birth info",
"order": 5,
"description": "The year this individual was born",
"type": "double"
}
},
"required": [
"idValue",
"idType",
"eventTimestamp",
"countryCode",
"age"
],
"primary": "/age"
},
"status": "active",
"tags": [
"age",
"demo",
"demographic",
"demographics"
],
"updated_at": "2021-06-24T00:54:40.029056Z",
"write_mode": "append",
"subscription_id": "123e4567-e89b-12d3-a456-426614174000",
"last_snapshot_created_at": "2023-06-09T16:51:34.215Z",
"stats": {
"est_total_dataset_stored_files": 10,
"est_total_dataset_stored_records": 500059,
"est_total_dataset_stored_bytes": 4206454,
"active_dataset_stored_files": 10,
"active_dataset_stored_records": 500059,
"active_dataset_stored_bytes": 4206454,
"last_snapshot_added_files": 2,
"last_snapshot_added_records": 499999,
"last_snapshot_deleted_records": 0,
"last_snapshot_added_bytes": 4193500,
"last_snapshot_deleted_files": 0,
"last_snapshot_added_delete_files": 0,
"last_snapshot_removed_delete_files": 0,
"last_snapshot_removed_bytes": 0
}
},
"nql": "<string>"
},
"completed_at": "2023-11-07T05:31:56Z",
"result": {
"type": "success",
"nql_type": "create_materialized_view",
"dataset_id": 123,
"snapshot_id": 123
}
}{
"error": "Unauthorized",
"error_description": "You are not authorized to use this endpoint."
}Run a materialized view refresh now
curl --request POST \
--url https://api-dev.narrative.io/datasets/{dataset_id}/refresh-materialized-view \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "full",
"execution_cluster": {
"type": "dedicated"
}
}
'import requests
url = "https://api-dev.narrative.io/datasets/{dataset_id}/refresh-materialized-view"
payload = {
"type": "full",
"execution_cluster": { "type": "dedicated" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({type: 'full', execution_cluster: {type: 'dedicated'}})
};
fetch('https://api-dev.narrative.io/datasets/{dataset_id}/refresh-materialized-view', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-dev.narrative.io/datasets/{dataset_id}/refresh-materialized-view",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'type' => 'full',
'execution_cluster' => [
'type' => 'dedicated'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-dev.narrative.io/datasets/{dataset_id}/refresh-materialized-view"
payload := strings.NewReader("{\n \"type\": \"full\",\n \"execution_cluster\": {\n \"type\": \"dedicated\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-dev.narrative.io/datasets/{dataset_id}/refresh-materialized-view")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"full\",\n \"execution_cluster\": {\n \"type\": \"dedicated\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/datasets/{dataset_id}/refresh-materialized-view")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"full\",\n \"execution_cluster\": {\n \"type\": \"dedicated\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"company_id": 345,
"created_at": "2023-11-07T05:31:56Z",
"failures": [
{
"message": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"value": {}
}
],
"idempotency_key": "<string>",
"request_source": {
"type": "api_user",
"company_id": 1,
"user_id": 1248
},
"state": "pending",
"updated_at": "2023-11-07T05:31:56Z",
"input": {
"compiled_select": "<string>",
"create_as_view": false,
"dataset": {
"id": 18923,
"company_id": 382,
"created_at": "2021-06-24T00:54:40.029056Z",
"data_plane": {
"type": "owned",
"id": "c0bed5c2-8af8-4f7a-9787-1ffc3def339b",
"company_id": 382,
"created_at": "2021-06-01T00:00:00Z",
"description": "The company's Snowflake account",
"display_name": "Snowflake (us-west-2)",
"external_id": "snowflake-prod",
"platform": {
"type": "platform_snowflake",
"account_locator": "ab12345",
"account_name": "acme",
"organization_name": "acmeorg",
"region": {
"type": "region_aws",
"id": "us-west-2"
}
},
"status": "active",
"tags": [],
"updated_at": "2021-06-01T00:00:00Z",
"collaborators": {
"participants": {
"type": "all"
},
"manage_compute_pools": {
"type": "all"
}
},
"compute_pools": []
},
"is_narrative_managed": true,
"retention_policy": {
"policies": [
{
"type": {
"kind": "snapshot_ttl",
"snapshot_retention_policy": {
"type": "retain_everything"
}
},
"enabled": true
}
]
},
"description": "Mobile identifiers tied to birth information provided as part of app registration.",
"name": "declared_age",
"display_name": "Declared Age",
"schema": {
"file_config": {
"type": "flat",
"delimiter": ",",
"escape": "\"",
"header": true,
"quote": "\""
},
"type": "object",
"properties": {
"idValue": {
"display_name": "id value",
"order": 0,
"approximate_cardinality": 100000,
"description": "ID values",
"type": "string"
},
"idType": {
"display_name": "id type",
"order": 1,
"approximate_cardinality": 1,
"type": "string",
"enum": [
"md5_email",
"sha256_email"
]
},
"eventTimestamp": {
"display_name": "event timestamp",
"order": 2,
"description": "When the observation was collected",
"type": "timestamptz",
"validations": [
"eventTimestamp < current_timestamp()"
]
},
"countryCode": {
"display_name": "country code",
"order": 3,
"approximate_cardinality": 6,
"description": "The country of residence of the individual",
"type": "string"
},
"age": {
"display_name": "age",
"order": 4,
"approximate_cardinality": 90,
"description": "How old this individual is in years",
"type": "long"
},
"birthInfo": {
"display_name": "birth info",
"order": 5,
"description": "The year this individual was born",
"type": "double"
}
},
"required": [
"idValue",
"idType",
"eventTimestamp",
"countryCode",
"age"
],
"primary": "/age"
},
"status": "active",
"tags": [
"age",
"demo",
"demographic",
"demographics"
],
"updated_at": "2021-06-24T00:54:40.029056Z",
"write_mode": "append",
"subscription_id": "123e4567-e89b-12d3-a456-426614174000",
"last_snapshot_created_at": "2023-06-09T16:51:34.215Z",
"stats": {
"est_total_dataset_stored_files": 10,
"est_total_dataset_stored_records": 500059,
"est_total_dataset_stored_bytes": 4206454,
"active_dataset_stored_files": 10,
"active_dataset_stored_records": 500059,
"active_dataset_stored_bytes": 4206454,
"last_snapshot_added_files": 2,
"last_snapshot_added_records": 499999,
"last_snapshot_deleted_records": 0,
"last_snapshot_added_bytes": 4193500,
"last_snapshot_deleted_files": 0,
"last_snapshot_added_delete_files": 0,
"last_snapshot_removed_delete_files": 0,
"last_snapshot_removed_bytes": 0
}
},
"nql": "<string>"
},
"completed_at": "2023-11-07T05:31:56Z",
"result": {
"type": "success",
"nql_type": "create_materialized_view",
"dataset_id": 123,
"snapshot_id": 123
}
}{
"error": "Unauthorized",
"error_description": "You are not authorized to use this endpoint."
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Unique identifier for a dataset.
Body
full will skip progress tracking and run the materialized view from scratch, incremental will use the progress tracking.
full, incremental Show child attributes
Show child attributes
The ID of the compute pool to use for this refresh. The compute pool must be active, belong to your company, and be associated with the target data plane. If not specified, falls back to the compute pool configured on the refresh schedule (if any).
Response
The refresh job. It has the same shape as the job POST /nql/run returns for a
CREATE MATERIALIZED VIEW statement.
A job that builds a materialized view.
Unique identifier for the job.
Company that ran the job.
345
The timestamp representing when the job was created.
causes of job failure
Show child attributes
Show child attributes
The unique ID associated with the job.
Who asked for the job. Discriminated by type: api_user for a job requested through the API on behalf
of a user, process for one enqueued by a Narrative process.
- Option 1
- Option 2
Show child attributes
Show child attributes
{
"type": "api_user",
"company_id": 1,
"user_id": 1248
}
Where a job is in its lifecycle.
pending— enqueued and waiting to be picked up.scheduled— claimed by an executor but not yet started.running— being executed.pending_cancellation— cancellation has been requested and the data plane has yet to stop the work.completed,cancelled,failed— terminal states.
pending, scheduled, running, pending_cancellation, completed, cancelled, failed The timestamp representing when the job was updated.
The dataset being created and the query that fills it.
Show child attributes
Show child attributes
When the job finished, or null while it is still pending or running.
The dataset and snapshot the job produced, or the failure that ended it. Null while the job is pending or running.
- Option 1
- Option 2
Show child attributes
Show child attributes
Was this page helpful?

