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:
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 thecompany_data schema by either their numeric ID or their dataset name:
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’sCREATE MATERIALIZED VIEW includes scheduling, partitioning, and metadata options beyond what most databases offer:
QUALIFY clause
While some databases supportQUALIFY, it’s not part of standard SQL. NQL includes it for filtering on window function results:
QUALIFY, you’d need a subquery:
DELTA tables
Query only changed records since the last execution—useful for incremental processing: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
- Reference datasets through the
company_dataschema, by name or ID:users→company_data.usersorcompany_data."123" - Add budget clauses to materialized views
- Consider
_price_cpm_usdfiltering for cost control
Coming from Snowflake/BigQuery
- Dataset references live under the
company_dataschema and can use the dataset name or numeric ID - Most functions work the same
QUALIFYis fully supported- Window functions work as expected
Coming from Spark SQL
- Similar syntax for complex types (arrays, structs, maps)
UNNESTandLATERALjoins work as expected- UDFs are replaced with Narrative-specific functions
Related content
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

