File size: 1,337 Bytes
e699b35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// TigerGraph GSQL Schema & Bulk Loader for Financial Graph
// Run this in GraphStudio or via GSQL shell.

// 1. Drop existing graph if necessary (Warning: this deletes data)
// DROP GRAPH FinancialGraph

// 2. Define Schema
// We use a generalized 'Entity' vertex and 'RELATIONSHIP' edge 
// to dynamically handle the Gemini extraction output without strict schema limits.
CREATE VERTEX Entity (PRIMARY_ID id STRING, entity_type STRING) WITH PRIMARY_ID_AS_ATTRIBUTE="true"
CREATE DIRECTED EDGE RELATIONSHIP (FROM Entity, TO Entity, rel_type STRING)

CREATE GRAPH FinancialGraph (Entity, RELATIONSHIP)

// 3. Define Loading Job
USE GRAPH FinancialGraph

CREATE LOADING JOB load_financial_graph FOR GRAPH FinancialGraph {
    // IMPORTANT: Update these paths to where you saved your vertices.csv and edges.csv
    DEFINE FILENAME v_file = "ANY:/path/to/vertices.csv";
    DEFINE FILENAME e_file = "ANY:/path/to/edges.csv";
    
    // Load Vertices
    LOAD v_file TO VERTEX Entity VALUES($0, $1) 
        USING SEPARATOR=",", HEADER="true", EOL="\n", QUOTE="double";
        
    // Load Edges
    LOAD e_file TO EDGE RELATIONSHIP VALUES($0, $1, $2) 
        USING SEPARATOR=",", HEADER="true", EOL="\n", QUOTE="double";
}

// 4. Run the Loading Job (Uncomment and run after updating paths above)
// RUN LOADING JOB load_financial_graph