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": []
}
}The validate endpoint in the NQL API allows users to verify the syntax and structure of their NQL queries before executing them. This ensures that the queries are correctly formatted and will not cause errors when passing through the /run endpoint. The primary goal of using the validate endpoint is to receive a 200 OK status code, which indicates that the query is valid.
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": []
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
A NQL query.
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.