Inter-Operating SAP HANA Cloud Knowledge Graphs and Property Graphs

Objective

After completing this lesson, you will be able to work with the two types of SAP HANA Cloud Graphs

Knowledge Graph and Property Graph Interoperability

Interoperability Between Property Graph and Knowledge Graph

SAP HANA Cloud hosts two graph engines within the same database instance.

  • The Property Graph Engine models data as vertices and edges stored in SQL tables, queried with openCypher through a graph workspace.

  • The Knowledge Graph Engine models data as RDF triples in a dedicated triple store, queried with SPARQL.

Both engines can interact at two levels: query-time federation and model conversion.

Query-Time Federation

Available since QRC1 2025, two functions enable federated queries across the two engines at runtime, without copying or moving data. SQL acts as the pivot language: results from both engines are ultimately consumed through a standard SQL connection, and SPARQL statements are themselves executed via a SQL stored procedure call.

Query-time federation functions

FunctionDirectionDescription
SPARQL_TABLE()Knowledge Graph → SQLEmbeds a SPARQL SELECT query inside a SQL statement and returns results as a SQL table
SQL_TABLE()SQL → Knowledge GraphEmbeds a SQL query inside a SPARQL statement and feeds relational rows into a SPARQL graph pattern

Model Conversion

Introduced in QRC4 2025, two built-in procedures in the SYS schema convert between the two graph models.

Model conversion procedures

ProcedureDirection
SYS.RDF_GRAPH_FROM_GRAPH_WORKSPACEProperty Graph → Knowledge Graph (RDF)
SYS.RDF_GRAPH_TO_GRAPH_WORKSPACEKnowledge Graph (RDF) → Property Graph

Caution

Both procedures copy the data. After conversion, the two models remain independent: subsequent changes in one do not propagate to the other.

RDF_GRAPH_FROM_GRAPH_WORKSPACE accepts the following parameters:

Parameters of SYS.RDF_GRAPH_FROM_GRAPH_WORKSPACE

ParameterDescription
GRAPH_WORKSPACE_SCHEMA_NAMESchema owning the source property graph workspace
GRAPH_WORKSPACE_NAMEName of the source property graph workspace
TARGET_GRAPH_URIIRI of the target RDF named graph (created if it does not exist)
MAPPING_MODEAUTO to generate URIs automatically; alternatively, supply a custom mapping table for full control
MAPPING_OUTOutput parameter returning the mapping details applied

Syntax to Convert Property Graph into Knowledge Graph

Code Snippet
1234567
CALL SYS.RDF_GRAPH_FROM_GRAPH_WORKSPACE( GRAPH_WORKSPACE_SCHEMA_NAME => 'MY_SCHEMA', GRAPH_WORKSPACE_NAME => 'MY_GRAPH_WORKSPACE', TARGET_GRAPH_URI => '<my_knowledge_graph>', MAPPING_MODE => 'AUTO', MAPPING_OUT => ? );

With MAPPING_MODE = 'AUTO', the procedure applies the following automatic mapping rules:

  • Each vertex → an RDF resource (URI derived from the key column value)
  • Each edge → an RDF triple linking two vertex URIs, with the edge table name as predicate
  • Each vertex or edge property → an additional triple with the column name as predicate and the column value as literal

Bulk Import and Export

Introduced in QRC2 2025, two SQL statements enable file-based bulk exchange of Knowledge Graph data with external systems. Both statements require a cloud storage path; Microsoft Azure, Amazon S3, Google Cloud, and SAP HANA Data Lake are supported. A local filesystem path is not accepted.

The file format is Turtle (.ttl), a compact, human-readable W3C standard for serializing RDF data.

Syntax to Import from / Export into an RDF File

Code Snippet
1234567
IMPORT FROM RDF FILE <storage_path> INTO SPARQL_GRAPH { DEFAULT | <graph> } [ WITH <import_options> ]; EXPORT INTO RDF FILE <storage_path> FROM SPARQL_GRAPH { DEFAULT | <graph> } [ WITH <export_options> ];

The following example exports a named graph to Azure cloud storage:

Code Snippet
123
EXPORT INTO RDF FILE 'azure://myaccount.blob.core.windows.net/container/kg_logistics.ttl' FROM SPARQL_GRAPH <kg_logistics>;

Release Summary

Graph interoperability features by release

ReleaseCapability
QRC1 2025Query-time federation: SPARQL_TABLE(), SQL_TABLE()
QRC2 2025Bulk file exchange: IMPORT FROM RDF FILE, EXPORT INTO RDF FILE
QRC4 2025Model conversion: SYS.RDF_GRAPH_FROM_GRAPH_WORKSPACE, SYS.RDF_GRAPH_TO_GRAPH_WORKSPACE