← Back to ferrosa

SPARQL 1.1 Reference

Ferrosa includes a native SPARQL 1.1 endpoint for semantic web and RDF workloads. Query your CQL tables with W3C-standard SPARQL, including property paths, aggregations, and RDF* annotations. No separate triple store needed.

Endpoint

SPARQL queries are submitted over HTTP to port 8080 (configurable via FERROSA_SPARQL_BIND). Enable with FERROSA_SPARQL_ENABLED=true.

HTTP Methods

MethodPathContent-TypeDescription
POST /sparql application/sparql-query Execute a SPARQL query (raw text body)
GET /sparql?query=... - Execute a SPARQL query (URL-encoded)
GET /sparql/health - Health check

Query Examples

Basic Triple Pattern

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?name ?email
WHERE {
  ?person foaf:name ?name .
  ?person foaf:mbox ?email .
}
LIMIT 10

Property Path (Transitive Closure)

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

# Find all people reachable through "knows" chains
SELECT DISTINCT ?person ?friend
WHERE {
  ?person foaf:knows+ ?friend .
}

Aggregation

PREFIX schema: <http://schema.org/>

SELECT ?city (COUNT(?person) AS ?count)
WHERE {
  ?person schema:address ?addr .
  ?addr schema:addressLocality ?city .
}
GROUP BY ?city
ORDER BY DESC(?count)

INSERT DATA

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

INSERT DATA {
  <http://example.org/alice> foaf:name "Alice" .
  <http://example.org/alice> foaf:knows <http://example.org/bob> .
}

FILTER and OPTIONAL

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?name ?email
WHERE {
  ?person foaf:name ?name .
  OPTIONAL { ?person foaf:mbox ?email }
  FILTER(STRSTARTS(?name, "A"))
}

Feature Matrix

FeatureStatusNotes
SELECTAvailableBasic graph patterns, joins
WHERE / FILTERAvailablePredicate evaluation on bindings
ORDER BY / LIMIT / OFFSETAvailablePost-processing on result set
ASKAvailableBoolean existence
Property paths (+, *, ?)PlannedServer-side BFS/DFS via adjacency index
OPTIONAL / UNIONPlannedLeft-join, concat semantics
CONSTRUCT / DESCRIBEPlannedRDF graph construction
INSERT DATA / DELETE DATAPlannedSPARQL Update
RDF* annotationsPlannedStatement-about-statement queries
Aggregates (COUNT, SUM, AVG)PlannedGROUP BY support

Response Formats

FormatContent-TypeStatus
SPARQL JSON Resultsapplication/sparql-results+jsonAvailable
Turtletext/turtlePlanned
N-Triplesapplication/n-triplesPlanned
JSON-LDapplication/ld+jsonPlanned

Architecture

SPARQL queries are parsed by the spargebra crate into an algebra tree, then translated by the ferrosa-sparql planner into storage reads against CQL-backed triple tables. Property path queries delegate to the graph engine's BFS/DFS traversal via the adjacency index. Results are serialized to W3C SPARQL JSON Results format.

RDF triples are stored in standard CQL tables with composite primary keys. Secondary indexes on predicate and object enable efficient pattern matching beyond simple subject lookups. The same storage engine, S3 durability, and distributed consensus that power CQL queries also power SPARQL.

Configuration

Environment VariableDefaultDescription
FERROSA_SPARQL_ENABLEDfalseEnable SPARQL endpoint
FERROSA_SPARQL_BIND0.0.0.0:8080SPARQL HTTP listen address

Ferrosa SPARQL is currently in beta. Feature availability reflects the current release.