shadeDB Engine SNL v1.0.0

Structured Native Language (SNL)

Structured Native Language (SNL) is the native query language of shadeDB. It was designed specifically for the shadeDB engine, providing a deterministic, structured, and lightweight syntax for interacting with database partitions. Rather than adopting a general-purpose relational query language, SNL is tightly integrated with the engine's internal architecture, allowing queries to map directly onto shadeDB's execution pipeline.

Every SNL query is composed of explicit execution stages separated by semicolons (;). Each statement has a clearly defined purpose, eliminating ambiguous execution paths and allowing the engine to process queries in a predictable top-down order.

Design Goals

SNL was created around a simple philosophy: make the query language match the database engine rather than forcing the engine to adapt to a general-purpose language.

Because SNL is purpose-built for shadeDB, its syntax reflects the engine's native execution model. Operations such as fetching, updating, recycling related records, freezing data, and projecting fields are expressed directly as engine instructions rather than being translated through multiple abstraction layers.

Why SNL?

  • Engine-Native Design
    SNL was designed alongside shadeDB itself, allowing the query language and execution engine to evolve together.
  • Deterministic Execution
    Queries execute in the order they are written. The engine does not rewrite queries or perform hidden execution plan transformations.
  • Explicit Syntax
    Every operation is declared directly using dedicated clauses and execution modes, making query behaviour predictable and easy to reason about.
  • Relationship Traversal
    Features such as RECYCLE, TARGET(), and RETRIEVE() allow related partitions to be traversed without requiring multiple client-side requests.
  • Minimal Query Grammar
    A compact grammar reduces parser complexity while keeping queries readable and consistent across every supported operation.
Native Query Language

shadeDB does not execute SQL. All interaction with database partitions is performed using SNL, either directly or through official client libraries which generate SNL queries internally.

Core Principles

Principle Description
Deterministic Queries execute in the order they are written without hidden rewrites.
Explicit Every operation is represented by a dedicated keyword or clause.
Strongly Typed Values use explicit type wrappers such as int(), float(), bool(), and str().
Composable Multiple clauses can be combined to build complex queries while remaining easy to read.
Engine Aware The language mirrors shadeDB's internal execution pipeline instead of abstracting it away.

Query Philosophy

SNL follows an explicit execution model. Each clause contributes a specific step to the query pipeline, and the engine processes those steps sequentially from top to bottom. There are no implicit joins, hidden mutations, or automatic query restructuring.

This approach makes query behaviour predictable, simplifies debugging, and allows developers to understand exactly how their queries are executed.

Query Lifecycle

  1. 1. Receive Query
    The engine receives the SNL request from an official client or API endpoint.
  2. 2. Parse & Validate
    The parser validates the query grammar, clauses, delimiters, and type wrappers.
  3. 3. Authorize
    The caller's permissions are verified before any partition is accessed.
  4. 4. Execute
    The requested operation is performed using the supplied clauses and execution modes.
  5. 5. Shape Response
    Projection, filtering, ordering, and pagination clauses are applied before constructing the final response.
  6. 6. Return Result
    The engine returns a standardized response containing the operation status, the query result (or error identifier), and the database execution latency.
Note: SNL is not intended to be a general-purpose query language. It is the native language of shadeDB and is designed to expose the engine's capabilities through a deterministic, structured, and strongly typed syntax.