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\"\nas (\n select \"company_data\".\"1\".s, \"company_data\".\"1\"._rosetta_stone.unique_id\n from \"company_data\".\"1\"\n)"
}
'{
"type": "create_materialized_view",
"nql": "CREATE MATERIALIZED VIEW \"dataset_name\" AS SELECT \"1\".s, \"1\"._rosetta_stone.unique_id FROM \"company_data\".\"1\" AS 1",
"name": "dataset_name",
"select": {
"type": "select",
"nql": "SELECT \"1\".s, \"1\"._rosetta_stone.unique_id FROM \"company_data\".\"1\" AS 1",
"columns": [
{
"type": "column",
"nql": "\"1\".s",
"db": null,
"schema": "company_data",
"table": "1",
"column": "s",
"metadata": {
"column_type": "column"
}
},
{
"type": "column",
"nql": "\"1\"._rosetta_stone.unique_id",
"db": null,
"schema": "company_data",
"table": "1",
"column": "_rosetta_stone.unique_id",
"metadata": {
"column_type": "attribute",
"id": 1,
"name": "unique_id"
}
}
],
"from": {
"as": "1",
"nql": "\"company_data\".\"1\" AS 1",
"type": "table",
"db": null,
"schema": "company_data",
"table": "1",
"metadata": {
"table_type": "dataset",
"id": 1,
"name": "dataset_name_1"
}
},
"group_by": [],
"having": null,
"is_distinct": false,
"limit": null,
"order_by": [],
"qualify": null,
"where": null,
"windows": [],
"with": []
}
}Validate an NQL statement
Parse and validate an NQL statement without running it. The statement is parsed with the SQL dialect of
the given data plane and checked against the datasets and access rules the token’s company can see. A
valid statement returns its AST (see the Ast schema). An invalid one returns an RFC 7807
problem whose title and detail say what is wrong, with the status code /v1/nql/execute
returns for the same problem.
Requires a token with read access to subscriptions. POST /nql/parse does the same check for any
token, or for no token at all.
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\"\nas (\n select \"company_data\".\"1\".s, \"company_data\".\"1\"._rosetta_stone.unique_id\n from \"company_data\".\"1\"\n)"
}
'{
"type": "create_materialized_view",
"nql": "CREATE MATERIALIZED VIEW \"dataset_name\" AS SELECT \"1\".s, \"1\"._rosetta_stone.unique_id FROM \"company_data\".\"1\" AS 1",
"name": "dataset_name",
"select": {
"type": "select",
"nql": "SELECT \"1\".s, \"1\"._rosetta_stone.unique_id FROM \"company_data\".\"1\" AS 1",
"columns": [
{
"type": "column",
"nql": "\"1\".s",
"db": null,
"schema": "company_data",
"table": "1",
"column": "s",
"metadata": {
"column_type": "column"
}
},
{
"type": "column",
"nql": "\"1\"._rosetta_stone.unique_id",
"db": null,
"schema": "company_data",
"table": "1",
"column": "_rosetta_stone.unique_id",
"metadata": {
"column_type": "attribute",
"id": 1,
"name": "unique_id"
}
}
],
"from": {
"as": "1",
"nql": "\"company_data\".\"1\" AS 1",
"type": "table",
"db": null,
"schema": "company_data",
"table": "1",
"metadata": {
"table_type": "dataset",
"id": 1,
"name": "dataset_name_1"
}
},
"group_by": [],
"having": null,
"is_distinct": false,
"limit": null,
"order_by": [],
"qualify": null,
"where": null,
"windows": [],
"with": []
}
}Authorizations
Body
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
The statement is valid. The body is its AST, or an empty object for a MERGE statement, which has
no AST representation.
The parsed statement as an AST. A MERGE statement has no AST representation and returns an empty
object instead, as does a statement whose AST could not be serialized.

