Skip to main content
If you know SQL, you already know most of NQL. This page explains what’s the same, what’s different, and what NQL adds for data collaboration scenarios.

What stays the same

NQL uses standard SQL syntax for core query operations. If you’ve written SQL queries before, these patterns work exactly as you’d expect:

SELECT statements

Aggregations and grouping

Joins

Subqueries and CTEs

INSERT, UPDATE, and DELETE

NQL supports the standard DML statements. INSERT accepts both VALUES and SELECT forms; UPDATE and DELETE take an optional WHERE clause:
See INSERT, UPDATE, and DELETE for full references.

Standard functions

Most SQL functions work as expected:
  • String: UPPER, LOWER, CONCAT, SUBSTRING, TRIM
  • Numeric: ABS, ROUND, FLOOR, CEIL
  • Date: CURRENT_DATE, DATE_TRUNC, EXTRACT
  • Aggregate: COUNT, SUM, AVG, MIN, MAX

What’s different

Table references use dataset IDs or names

In traditional SQL, you reference tables by name. In NQL, you reference datasets within the company_data schema by either their numeric ID or their dataset name:
Numeric IDs must be quoted because they’re numeric. Dataset names don’t need quoting unless the name is a reserved keyword or contains special characters. The company_data schema contains your datasets.
Queries built with Data Studio’s Query Builder render the FROM clause using dataset names by default, so the NQL editor view shows readable references like company_data.my_users. Numeric IDs are still valid everywhere, and Narrative I/O uses them internally where a stable identifier is required — for example, the NQL persisted with an access rule is always ID-qualified, since dataset names can be reused after a dataset is archived.

Special data sources

NQL provides access to shared resources that don’t exist in traditional databases:

Price filtering

Every dataset includes a _price_cpm_usd column representing the cost per 1,000 rows. This doesn’t exist in traditional databases:

What NQL adds

Budget controls

NQL includes budget clauses to control data spending—a concept that doesn’t exist in traditional SQL:

Materialized views with options

NQL’s CREATE MATERIALIZED VIEW includes scheduling, partitioning, and metadata options beyond what most databases offer:

QUALIFY clause

While some databases support QUALIFY, it’s not part of standard SQL. NQL includes it for filtering on window function results:
Without QUALIFY, you’d need a subquery:

DELTA tables

Query only changed records since the last execution—useful for incremental processing:
This capability requires the platform to track changes, which isn’t standard SQL functionality.

Rosetta Stone integration

Access identity resolution through special columns:

Narrative-specific functions

Functions designed for data collaboration scenarios:

SQL features not supported

Some SQL features aren’t available in NQL:

Dialect differences

NQL is transpiled to different database engines (Snowflake, Spark). The transpiler handles dialect differences, but awareness helps when debugging:

Date functions

NULL handling

NQL follows standard SQL NULL semantics, but the underlying engine may have subtle differences. The transpiler normalizes most cases.

Migration tips

Coming from PostgreSQL/MySQL

  1. Reference datasets through the company_data schema, by name or ID: userscompany_data.users or company_data."123"
  2. Add budget clauses to materialized views
  3. Consider _price_cpm_usd filtering for cost control

Coming from Snowflake/BigQuery

  1. Dataset references live under the company_data schema and can use the dataset name or numeric ID
  2. Most functions work the same
  3. QUALIFY is fully supported
  4. Window functions work as expected

Coming from Spark SQL

  1. Similar syntax for complex types (arrays, structs, maps)
  2. UNNEST and LATERAL joins work as expected
  3. UDFs are replaced with Narrative-specific functions

NQL Design Philosophy

Why Narrative created a purpose-built query language

NQL Syntax Reference

Complete query structure and grammar

Write Your First Query

Hands-on tutorial to get started

Functions Reference

All available functions