Query languages

SynergyDB accepts many query languages besides SQL. This section describes each language engine in the code: what it parses, which clauses and operators it accepts, how a statement ends up on the shared storage engine, what it does not support, and which tests cover it. The wire framing of each protocol is in Volume III and in the operator-facing wire pages; the SQL pipeline itself is in Statement lifecycle.

Three ways a language reaches storage

There is no single "unified" path. Each language uses one of three patterns:

  1. Parse to LogicalPlan, run on QueryEngine. The language has an analyzer that emits the same LogicalPlan the SQL parser emits, and QueryEngine::execute_plan runs it. Engine-side Cypher, the engine-side MQL analyzer and GraphQL work this way (source: src/query/mod.rs, Analyzer, QueryCompiler; src/query/engine.rs, QueryEngine::parse_query).
  2. Rewrite to SQL text, run on QueryEngine::execute. The wire translates each statement into SQL and calls the engine. CQL, the ClickHouse dialect, T-SQL and the MySQL dialect work this way (source: src/protocol/cassandra/exec.rs, run_sql; src/protocol/clickhouse/translate.rs; src/protocol/mssql/tsql.rs).
  3. Evaluate natively in the wire, persist through storage. The wire keeps its own data model (often in memory), evaluates queries itself, and writes records either into SQL tables through QueryEngine or straight into the key-value space. Bolt Cypher, Gremlin, the MongoDB wire, InfluxQL, Flux, PromQL, Elasticsearch Query DSL, DynamoDB expressions, CouchDB Mango and the Redis query engine work this way.

Pattern 3 means a language's semantics come from its own evaluator, not from the SQL planner or optimizer. It also means that the same data written through one wire is generally not queryable in another wire's language, except where a wire mirrors into SQL tables or the shared vector service (see each page).

flowchart LR A["SQL text"] --> E["QueryEngine::execute"] B["CQL, ClickHouse SQL, T-SQL, MySQL"] -->|"rewrite to SQL"| E C["Engine Cypher, engine MQL, GraphQL"] -->|"Analyzer to LogicalPlan"| P["QueryEngine::execute_plan"] E --> P P --> S["Storage engine"] D["Bolt Cypher, Gremlin, Mongo wire, InfluxQL, PromQL, ES DSL, DynamoDB, Mango, FT.SEARCH"] -->|"native evaluator"| M["Wire data model"] M -->|"SQL mirror tables or KV records"| S

(source: the files named in the table below)

Translation path summary

Language Engine Path Where data lives Page
Cypher (Bolt wire) src/protocol/bolt/ Native evaluator In-memory GraphStore, mirrored to _bolt_nodes, _bolt_relationships, _bolt_schema Cypher
Cypher (SQL wires, HTTP, gRPC) src/query/cypher/ LogicalPlan __graph_nodes__, __graph_edges__ Cypher
Gremlin src/protocol/gremlin/ Native step engine In-memory GremlinGraphStore, mirrored to _gremlin_vertices, _gremlin_edges Gremlin
MongoDB commands (wire) src/protocol/mongodb/commands.rs Native evaluator KV records mongodb:<db>:<coll>:<id> MongoDB query language
MQL command documents (SQL engine, HTTP Studio) src/query/mql/ LogicalPlan Relational table named after the collection MongoDB query language
InfluxQL, Flux src/protocol/influxdb/ Native evaluator; Flux by substring matching In memory, KV records __influx__: InfluxQL and Flux
PromQL src/protocol/prometheus/promql/ Native evaluator In-memory head, KV records __prom__: PromQL
CQL src/protocol/cassandra/ Rewrite to SQL SQL table ks__t CQL
GraphQL src/query/graphql/ LogicalPlan Any SQL table GraphQL
Elasticsearch Query DSL src/protocol/elasticsearch/ Native evaluator In memory, KV journal __es__:doc:, snapshot __es__:indices, SQL table _es_documents Elasticsearch Query DSL
DynamoDB expressions and PartiQL src/protocol/dynamodb/ Native evaluator In memory, SQL tables _dynamo_tables, _dynamo_items DynamoDB expressions
CouchDB Mango and views src/protocol/couchdb/ Native evaluator, QuickJS for map functions In memory, SQL tables _couchdb_dbs, _couchdb_docs CouchDB Mango and views
Redis query syntax (FT.SEARCH) src/protocol/redis/commands/search.rs Native evaluator Redis keyspace, index definitions under __redisft__: Redis query syntax
SPARQL src/query/sparql/ Own executor over an in-memory Dataset, or LogicalPlan over rdf_triples Not wired to any listener SPARQL
ClickHouse SQL src/protocol/clickhouse/translate.rs Rewrite to SQL SQL tables ClickHouse reference
T-SQL src/protocol/mssql/tsql.rs Rewrite to SQL, batch interpreter SQL tables SQL Server reference
MySQL dialect src/protocol/mysql/, engine dialect flags Rewrite plus engine dialect SQL tables MySQL reference

(source: src/protocol/bolt/mod.rs, GraphStore::with_storage; src/query/cypher/planner.rs, CypherPlanner::node_to_insert; src/protocol/gremlin/traversal.rs, GremlinGraphStore::with_storage; src/protocol/mongodb/commands.rs, storage_key_with_db; src/query/mql/planner.rs, MqlPlanner::plan; src/protocol/influxdb/mod.rs, PT_PREFIX; src/protocol/prometheus/persist.rs, DATA_PREFIX; src/protocol/cassandra/exec.rs, run_sql; src/protocol/elasticsearch/journal.rs, PREFIX; src/protocol/elasticsearch/mod.rs, ES_STORE_KEY; src/protocol/dynamodb/mod.rs, backing tables; src/protocol/couchdb/store.rs, CREATE_DOCS; src/protocol/redis/commands/search.rs, FT_DEF_PREFIX; src/query/sparql/planner.rs, SparqlPlanner::new; src/protocol/mysql/mod.rs, translate_mysql_sql)

Language detection inside QueryEngine

Text that reaches QueryEngine::execute is routed by detect_language on a plan-cache miss. Text that starts with MATCH , OPTIONAL MATCH , MERGE or CREATE (, or a CREATE that is not an SQL object keyword and contains a (x:Label) pattern without ::, is Cypher. Text that starts with { or db. is MQL. Everything else is SQL. QueryLanguage::GraphQL and QueryLanguage::SynergyQL are parsed as SQL, and QueryLanguage::SPARQL returns "SPARQL queries not supported in QueryEngine; use QueryCompiler" (source: src/query/engine.rs, QueryEngine::detect_language, QueryEngine::parse_query). The full rule list is on the lifecycle page.

Consequences of these rules:

  • Any SQL wire (PostgreSQL, MySQL and the others that call execute) accepts Cypher text and MQL command documents, and runs them on the engine-side analyzers, not on the Bolt or MongoDB wire engines.
  • CREATE INDEX and DROP INDEX always go to SQL, so the Cypher analyzer's own CREATE INDEX ... FOR (n:L) ON (n.p) form is reachable only through callers that pick the Cypher analyzer directly (HTTP /api/v1/query with "language": "cypher", gRPC without storage).
  • db. text is classified as MQL, but MqlParser::parse_command expects a JSON-like command document, so shell syntax such as db.users.find({}) fails to parse on this path. Only the HTTP Studio route converts shell syntax first (convert_mongo_shell_to_json) (source: src/query/mql/parser.rs, MqlParser::parse_command; src/protocol/http/routes.rs, execute_query_for_studio).

QueryCompiler in src/query/mod.rs is a second dispatcher with its own compile_auto detector. No code outside src/query/mod.rs constructs it, so it is reachable only from Rust callers of the library (source: src/query/mod.rs, QueryCompiler). Not wired: no server path uses QueryCompiler.

HTTP entry points that pick a language

Route Language selection Engine call
POST /api/v1/query language: sql or synergyql to SqlAnalyzer, cypher to CypherAnalyzer; mql is refused ("MQL queries should use the MongoDB endpoint"); anything else is "Unsupported language" execute_plan
POST /api/query (Studio) protocol: SQL-family wires to SQL, mongodb to MQL (after shell-syntax conversion), bolt to Cypher; redis, memcached and influxdb return a hint to use the native port; elasticsearch, dynamodb, http, grpc take JSON execute_plan
POST /api/v1/graph/query Text detection execute
POST /api/v1/graphql, POST /graphql GraphQLAnalyzer::parse execute_plan

(source: src/protocol/http/routes.rs, execute_query, execute_query_for_studio, graph_query, execute_graphql)

The gRPC query service calls execute (text detection) when storage is present; without storage it only parses, with language sql, synergyql or empty to SQL and cypher to Cypher (source: src/protocol/grpc/service.rs).

SynergyQL

SynergyQLAnalyzer holds a SqlAnalyzer and forwards every call to it; its comment says "For now, SynergyQL is just SQL". There is no extended syntax: vector, graph and full-text operations are whatever the SQL parser accepts (source: src/query/synergyql/mod.rs, SynergyQLAnalyzer::parse). The June 2026 book described SynergyQL as a native extension language; that description does not match the code. Not verified: no test names SynergyQL.

Pages in this section