Skip to main content
GET
/
jobs
/
{job_id}
Get a job
curl --request GET \
  --url https://api-dev.narrative.io/jobs/{job_id} \
  --header 'Authorization: Bearer <token>'
{
  "job_id": "2a5b9ad7-dc8f-47bb-8e62-843a38f8054c",
  "request_source": {
    "type": "api_user",
    "company_id": 1,
    "user_id": 407
  },
  "state": "completed",
  "type": "materialize-view",
  "input": {
    "nql": "CREATE MATERIALIZED VIEW \"test_stats\" AS SELECT \"value\" FROM \"company_data\".\"10674\"",
    "dataset_id": 10736,
    "stats_enabled": true,
    "compiled_select": "SELECT\n  `ds_10674`.`value`\nFROM\n  narrative.datasets.ds_10674 `ds_10674`"
  },
  "executor": "job-executor-98e1f48e-bf54-4f11-bbd1-73c445120266",
  "idempotency_key": "10736:29329c64e7b8a4eda86aaabe04872b832ab456b5543d0c259c812525391f158c:669a5f8e4f373c2f907700decde47511aac6470f5698e2b856fb07f09160e5f2",
  "result": {
    "dataset_id": 10736,
    "snapshot_id": 1724919539450264600,
    "recalculation_id": "abf9a2ec-426b-4751-bd16-fcb435061925"
  },
  "created_at": "2023-10-31T11:19:13.400498",
  "updated_at": "2023-10-31T11:25:08.327209",
  "ended_at": "2023-10-31T11:25:08.327194"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

job_id
string<uuid>
required

Unique identifier for a job.

Response

OK

job_id
string<uuid>
required

Unique identifier for the job.

request_source
object
required
Example:
{
"type": "api_user",
"company_id": 1,
"user_id": 1248
}
state
enum<string>
default:pending
required
Available options:
failed,
cancelled,
completed,
pending,
running
type
string
required

The type associated with the job. Jobs can have a type of nql-forecast or materialize-view.

input
object
required
Example:
{
"nql": "CREATE MATERIALIZED VIEW \"sampleNQL\" as WITH OrderedData AS (\n SELECT\n \"mobile_id_unique_identifier\".\"value\" AS mobile_id,\n \"timestamp_object\".\"day\",\n \"timestamp_object\".\"hour\",\n \"geographic_location\".\"latitude\",\n \"geographic_location\".\"longitude\",\n \"event_timestamp\",\n LAG(\"event_timestamp\", 1) OVER (PARTITION BY \"mobile_id_unique_identifier\".\"value\", \"geographic_location\".\"latitude\", \"geographic_location\".\"longitude\" ORDER BY \"event_timestamp\") AS prev_timestamp\n FROM\n \"company_data\".\"6402\"\n WHERE\n \"mobile_id_unique_identifier\".\"value\" IS NOT NULL \n), \nContinuousPresence AS (\n SELECT\n mobile_id,\n \"day\",\n \"hour\",\n latitude,\n longitude,\n event_timestamp,\n prev_timestamp,\n CASE\n WHEN extract(minute FROM event_timestamp) - extract(minute FROM prev_timestamp) BETWEEN 40 AND 120 THEN 1\n ELSE 0\n END AS is_continuous\n FROM\n OrderedData\n)\nSELECT\n mobile_id,\n \"day\",\n \"hour\",\n latitude,\n longitude\nFROM\n ContinuousPresence\nWHERE\n is_continuous = 1\nGROUP BY\n mobile_id,\n \"day\",\n \"hour\",\n latitude,\n longitude\n",
"dataset_id": 6404,
"stats_enabled": true,
"compiled_sql": "SELECT\n `t`.`mobile_id`,\n `t`.`day`,\n `t`.`hour`,\n `t`.`latitude`,\n `t`.`longitude`\nFROM\n (SELECT\n `ds_6402`.`mobile_id_unique_identifier`['value'] `mobile_id`,\n `ds_6402`.`timestamp_object`['day'] `day`,\n `ds_6402`.`timestamp_object`['hour'] `hour`,\n `ds_6402`.`geographic_location`['latitude'] `latitude`,\n `ds_6402`.`geographic_location`['longitude'] `longitude`,\n CASE\n WHEN EXTRACT(MINUTE FROM `ds_6402`.`event_timestamp`) - EXTRACT(MINUTE FROM LAG(`ds_6402`.`event_timestamp`, 1) OVER (\n PARTITION BY `ds_6402`.`mobile_id_unique_identifier`.`value`, `ds_6402`.`geographic_location`.`latitude`, `ds_6402`.`geographic_location`.`longitude`\n ORDER BY `ds_6402`.`event_timestamp` NULLS LAST)) >= 40 AND EXTRACT(MINUTE FROM `ds_6402`.`event_timestamp`) - EXTRACT(MINUTE FROM LAG(`ds_6402`.`event_timestamp`, 1) OVER (\n PARTITION BY `ds_6402`.`mobile_id_unique_identifier`.`value`, `ds_6402`.`geographic_location`.`latitude`, `ds_6402`.`geographic_location`.`longitude`\n ORDER BY `ds_6402`.`event_timestamp` NULLS LAST)) <= 120\n THEN 1\n ELSE 0\n END `is_continuous`\n FROM\n narrative.datasets.ds_6402 `ds_6402`) `t`\nWHERE\n `t`.`is_continuous` = 1\nGROUP BY\n `t`.`mobile_id`,\n `t`.`day`,\n `t`.`hour`,\n `t`.`latitude`,\n `t`.`longitude`"
}
executor
string
required

The internal job executor tied to the job.

failures
object[]
required

causes of job failure

idempotency_key
string
required

The unique ID associated with the job.

result
object
required

The output of a materialized view.

Example:
{
"dataset_id": 6404,
"snapshot_id": 739881302291276700,
"recalculation_id": "abf9a2ec-426b-4751-bd16-fcb435061925"
}
created_at
string<date-time>
required

The timestamp representing when the job was created.

updated_at
string<date-time>
required

The timestamp representing when the job was updated.

ended_at
string<date-time>
required

The timestamp representing when the job finished.

execution_cluster
enum<string>

The type of the execution cluster to run the job on.

  • dedicated runs job on a dedicated cluster.
  • shared runs job on a shared cluster.
Available options:
dedicated,
shared