sap-hana-triple
Skill9 starsChanged 23 days agoApache-2.0View on GitHub
Use this skill when building Knowledge Graphs on SAP HANA Cloud's Triple Store — SPARQL 1.1 modeling, graph workspaces, ingestion from S/4 or business data, and the agent-over-KG NL→SPARQL→answer pattern. Includes hybrid KG+vector retrieval where both engines live in the same HANA tenant.
In this repository8 other files it gives its agents.
- sap-ai-coreSkill
- sap-hana-data-prepSkill
- sap-hana-vectorSkill
- sap-joule-capabilitySkill
- sap-kyma-cliSkill
- sap-repair-joule-accessSkill
- sap-setup-btp-agentSkill
- sap-sovereign-regionsSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 27
Keep the ontology in ontology/*.ttl files in the project — code-review changes the same way you do schema changes.
- Very specific: line 31
Run sap-hana-data-prep before this skill.
- Very specific: line 39
If prepared/ingestion-contract.yaml is absent or target_shape is not hana_triple, return to sap-hana-data-prep.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SAP HANA Cloud Triple Store — SPARQL 1.1 / Knowledge Graphs
HANA Cloud's Triple Store is SPARQL 1.1 over a graph workspace. You model your domain as RDF triples (subject, predicate, object), load them, and query with SPARQL.
Graph workspace
CREATE GRAPH IF NOT EXISTS COE_PILOT WORKSPACE;Modeling — ontology in Turtle
@prefix : <http://coe.example/customer#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
:Customer a rdfs:Class .
:hasPrimaryContact a rdf:Property ;
rdfs:domain :Customer ; rdfs:range :Contact .Keep the ontology in ontology/*.ttl files in the project — code-review changes the same way you do schema changes.
Before loading: data preparation
Run sap-hana-data-prep before this skill. It produces the entity mapping and Turtle triples this skill consumes:
prepared/entity_mapping.yaml -- entity classes, id fields, relationship predicates, IRI base
prepared/triples.ttl -- sample or full RDF in Turtle
prepared/ingestion-contract.yaml -- confirms target_shape: hana_triple, pii_handlingIf prepared/ingestion-contract.yaml is absent or target_shape is not hana_triple, return to sap-hana-data-prep.
Loading
Bulk load via SPARQL INSERT DATA over an hdbcli connection:
import hdbcli.dbapi as db
conn = db.connect(address=HANA_HOST, port=443, user=USER, password=PASS, encrypt=True)
cur = conn.cursor()
cur.execute("""
SPARQL INSERT DATA {
GRAPH <coe-pilot> {
<http://coe.example/customer#acme> a <http://coe.example/customer#Customer> ;
<http://coe.example/customer#hasPrimaryContact> <http://coe.example/customer#alice> .
<http://coe.example/customer#alice> a <http://coe.example/customer#Contact> .
}
}""")Query
cur.execute("""
SPARQL SELECT ?contactLabel WHERE {
GRAPH <coe-pilot> {
<http://coe.example/customer#acme> <http://coe.example/customer#hasPrimaryContact> ?c .
?c <http://www.w3.org/2000/01/rdf-schema#label> ?contactLabel .
}
}""")Agent-over-KG pattern
- Few-shot the LLM with the ontology to emit SPARQL from NL.
- Execute the SPARQL.
- Re-prompt the LLM to phrase the result.
This pattern lives conceptually in references/kg-project/agent/kg-agent.py (planned template; tracked as TODO in references/README.md). Until it lands, the SPARQL-over-HANA walkthrough is in recipes/optional/hana-kg-triple-store/.
Hybrid KG + Vector
You can put REAL_VECTOR columns on a graph's annotation table and use a vector pre-filter to narrow candidate nodes before SPARQL traversal. Not yet documented as its own recipe — combine recipes/optional/hana-vector-store/ and recipes/optional/hana-kg-triple-store/ for now.
Pitfalls
- Forgetting the
GRAPH <name>clause → query hits the default graph and returns nothing. - IRI vs literal confusion: enclose IRIs in
< >, literals in" ". - Mixing tenants: each HANA Cloud tenant has its own workspace; cross-tenant SPARQL is not transparent.
- Insert performance: batch INSERT DATA in chunks of 1000 triples — much faster than one-by-one.
Verify
cur.execute("SPARQL SELECT (COUNT(*) AS ?n) WHERE { GRAPH <coe-pilot> { ?s ?p ?o } }")
n = cur.fetchone()[0]
assert n > 0, "graph is empty — re-run ingest"Cross-references
- Upstream data prep:
skills/sap-hana-data-prep/— run this first for any new dataset - Walkthrough:
recipes/optional/hana-kg-triple-store/ - Template:
references/kg-project/— planned; tracked as TODO inreferences/README.md. - HANA docs: https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-sparql-1-1-reference
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

