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
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
In traditional SQL, you reference tables by name. In NQL, you reference datasets by their numeric ID within a schema:company_data schema contains your datasets.
Special data sources
NQL provides access to shared resources that don’t exist in traditional databases:| Source | Purpose |
|---|---|
narrative.rosetta_stone | Identity resolution across datasets |
provider_slug."access_rule" | Data shared via access rules |
Price filtering
Every dataset includes a_price_cpm_usd column representing the cost per 1,000 rows. This doesn’t exist in traditional databases:
EXPLAIN forecasts instead of plans
In traditional SQL,EXPLAIN shows the query execution plan. In NQL, EXPLAIN forecasts data availability and cost:
EXPLAIN to preview what data matches your criteria before purchasing.
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:| Feature | Status | Alternative |
|---|---|---|
CREATE TABLE | Not supported | Use CREATE MATERIALIZED VIEW |
INSERT/UPDATE/DELETE | Not supported | Views are the output mechanism |
CREATE INDEX | Not supported | Partitioning provides similar benefits |
| Stored procedures | Not supported | — |
| Transactions | Not supported | Each query is atomic |
UNION | Limited support | Some restrictions apply |
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
- Replace table names with dataset IDs:
users→company_data."123" - Add budget clauses to materialized views
- Use
EXPLAINto forecast rather than plan - Consider
_price_cpm_usdfiltering for cost control
Coming from Snowflake/BigQuery
- Dataset references use numeric IDs instead of table names
- 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

