Skip to main content
POST
/
nql
/
validate
Validate an NQL query
curl --request POST \
  --url https://api-dev.narrative.io/nql/validate \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "nql": "CREATE MATERIALIZED VIEW \"dataset_name\" AS SELECT \"company_data\".\"1\".x AS xx, \"company_data\".\"1\".y AS yy, \"company_data\".\"1\".z AS zz, \"company_data\".\"1\".x + \"company_data\".\"1\".y + \"company_data\".\"1\".z AS xyz_sum FROM \"company_data\".\"1\""
}
'
{
"type": "create_materialized_view",
"nql": "CREATE MATERIALIZED VIEW \"dataset_name\" AS SELECT \"company_data\".\"1\".x AS xx, \"company_data\".\"1\".y AS yy, \"company_data\".\"1\".z AS zz, \"company_data\".\"1\".x + \"company_data\".\"1\".y + \"company_data\".\"1\".z AS xyz_sum FROM \"company_data\".\"1\"",
"name": "dataset_name",
"select": {
"type": "select",
"nql": "SELECT \"company_data\".\"1\".x AS xx, \"company_data\".\"1\".y AS yy, \"company_data\".\"1\".z AS zz, \"company_data\".\"1\".x + \"company_data\".\"1\".y + \"company_data\".\"1\".z AS xyz_sum FROM \"company_data\".\"1\"",
"columns": [
{
"as": "xx",
"nql": "\"company_data\".\"1\".x AS xx",
"type": "column",
"db": null,
"schema": "company_data",
"table": "1",
"column": "x",
"metadata": {
"column_type": "column"
}
},
{
"as": "yy",
"nql": "\"company_data\".\"1\".y AS yy",
"type": "column",
"db": null,
"schema": "company_data",
"table": "1",
"column": "y",
"metadata": {
"column_type": "column"
}
},
{
"as": "zz",
"nql": "\"company_data\".\"1\".z AS zz",
"type": "column",
"db": null,
"schema": "company_data",
"table": "1",
"column": "z",
"metadata": {
"column_type": "column"
}
},
{
"as": "xyz_sum",
"nql": "\"company_data\".\"1\".x + \"company_data\".\"1\".y + \"company_data\".\"1\".z AS xyz_sum",
"type": "binary_op",
"name": "+",
"left": {
"type": "binary_op",
"nql": "\"company_data\".\"1\".x + \"company_data\".\"1\".y",
"name": "+",
"left": {
"type": "column",
"nql": "\"company_data\".\"1\".x",
"db": null,
"schema": "company_data",
"table": "1",
"column": "x",
"metadata": {
"column_type": "column"
}
},
"right": {
"type": "column",
"nql": "\"company_data\".\"1\".y",
"db": null,
"schema": "company_data",
"table": "1",
"column": "y",
"metadata": {
"column_type": "column"
}
}
},
"right": {
"type": "column",
"nql": "\"company_data\".\"1\".z",
"db": null,
"schema": "company_data",
"table": "1",
"column": "z",
"metadata": {
"column_type": "column"
}
}
}
],
"from": {
"type": "table",
"nql": "\"company_data\".\"1\"",
"db": null,
"schema": "company_data",
"table": "1",
"metadata": {
"id": 1,
"name": "dataset_name_1",
"table_type": "dataset"
}
},
"group_by": [],
"having": null,
"is_distinct": false,
"limit": null,
"order_by": [],
"qualify": null,
"where": null,
"windows": [],
"with": []
}
}

Authorizations

Authorization
string
header
required

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

Body

application/json
nql
string
required

A NQL query.

data_plane_id
string<uuid>

A dataplane represent where you would run the query. Your query get compiled to the SQL dialect that your data engine understands. If you leave it blank, your query will target Narrative's dataplane on AWS using Apache Spark. We currently support Snowflake and we plan to support other dataplanes in the future. See https://next.narrative.io/products/narrative-anywhere for more details.

Response

OK

type
string
required
Allowed value: "agg_function"
nql
string
required
args
array
required
quantifier
enum<string>
Available options:
all,
distinct