Skip to content

feat: YARRRML → SPARQL converter + API endpoint#63

Open
ThHanke wants to merge 2 commits into
mainfrom
feat/yarrrml-to-sparql
Open

feat: YARRRML → SPARQL converter + API endpoint#63
ThHanke wants to merge 2 commits into
mainfrom
feat/yarrrml-to-sparql

Conversation

@ThHanke

@ThHanke ThHanke commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Adds yarrrml_to_sparql() utility and POST /api/yarrrmltosparql endpoint that converts a YARRRML mapping YAML into a SPARQL SELECT query reconstructing the original JSON from an RDF graph.

What it does

  • Traverses YARRRML mapping structure (flat, sub-object, array patterns)
  • Emits CONCAT(...) SELECT column building JSON from RDF triples
  • Arrays: GROUP_CONCAT(DISTINCT ...) with per-item JSON fragments
  • Non-array sub-objects: nested {} keyed by predicate local name
  • Ghost sub-object detection: skips children whose fields duplicate the parent
  • Numeric/boolean coercion via IF(REGEX(...)) in SPARQL output
  • STRSTARTS subject prefix filter for cross-mapping isolation

Verification

  • 25/25 unit tests (test_yarrrml_sparql.py)
  • 28/28 production EDCAR SAMM mappings roundtrip (test_yarrrml_sparql_roundtrip.py)
  • SimulationParameter skipped: empty {} sub-objects don't survive RDF roundtrip by design

Thomas Hanke added 2 commits June 25, 2026 14:16
yarrrml-parser silently drops valid two-line nested-list po: blocks.
Add normalize_yarrrml_nested_lists (yarrrml_utils.py) that converts
them to inline-list form before the request hits yarrrml-parser.

Wire normalization into convert_yarrrml_to_rml (handles all callers)
and refactor /api/yarrrmltorml to use that helper.

Add /api/normalizeyarrrml endpoint for inspection/debugging.

Unit tests in test_normalize_yarrrml.py; integration tests added
to test_createrdfupload.py.
…ndpoint

Converts YARRRML mapping YAML to SPARQL SELECT queries that reconstruct
the original JSON from an RDF graph. Handles flat, sub-object (non-array),
and array patterns with GROUP_CONCAT; ghost sub-object detection skips
duplicate fields; numeric/boolean coercion in output; STRSTARTS scoping
filter for cross-mapping isolation. Roundtrip verified: 28/28 production
EDCAR mappings pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant