surfacevisualizationto_property_graph
Visualizationpipeline · returns table

TO_PROPERTY_GRAPH

Convert triples to relational node/edge graph tables for recursive CTE traversal

Table-in, table-out — composes downstream of SELECTs.

visualizationllmpipeline-composabletext

Syntax

THEN TO_PROPERTY_GRAPH({{ graph_name }})
THEN TO_PROPERTY_GRAPH({{ graph_name }}, {{ subject_col }}, {{ predicate_col }}, {{ object_col }})
THEN TO_PROPERTY_GRAPH({{ graph_name }}, {{ subject_col }}, {{ predicate_col }}, {{ object_col }}, {{ evidence_col }})

Arguments

nametypedescription
graph_nameVARCHARName for the property graph
subject_col(optional)VARCHAR
predicate_col(optional)VARCHAR
object_col(optional)VARCHAR
evidence_col(optional)VARCHAR
_tableTABLE

About

PIPELINE cascade for converting triples to relational graph tables. Creates relational node/edge tables from triples data that can be queried with recursive CTE traversal in PostgreSQL. Uses pure SQL - no LLM calls. Prerequisites: - PostgreSQL 14+ - pgvector extension (for broader KG/RAG stack) Usage: -- From rich_triples extraction SELECT * FROM docs, LATERAL rich_triples_rows(content) t THEN TO_PROPERTY_GRAPH('my_knowledge_graph') -- From regular triples SELECT subject, predicate, object FROM my_edges THEN TO_PROPERTY_GRAPH('network', 'subject', 'predicate', 'object') -- Then query with recursive CTE traversal WITH RECURSIVE walk AS ( SELECT source_id, target_id, ARRAY[predicate]::text[] AS rel_path, 1 AS depth FROM my_knowledge_graph_edges WHERE source_id = 'orders' UNION ALL SELECT w.source_id, e.target_id, w.rel_path || e.predicate, w.depth + 1 FROM walk w JOIN my_knowledge_graph_edges e ON e.source_id = w.target_id WHERE w.depth < 4 ) SELECT * FROM walk;

Examples

Builds relational property-graph staging tables from triples

SELECT
  *
FROM
  (
    VALUES
      ('orders', 'depends_on', 'customers'),
      ('orders', 'depends_on', 'products')
  ) AS t (subject, predicate, object) THEN TO_PROPERTY_GRAPH ('bench_graph_signal')

Nearby rabbit holes

same domain
Climb back to The Looking Glass