-- Step 1: Define schema manually
DROP TABLE IF EXISTS Arc;
CREATE TABLE Arc(x INTEGER, y INTEGER);

-- Step 2: Load Arc.csv (path is inside container)
COPY Arc FROM '/hostdata/test/G5K-0.001/Arc.csv' (DELIMITER ',', FORMAT csv);

-- Step 3: Compute transitive closure
WITH RECURSIVE Tc(x, y) AS (
    SELECT x, y FROM Arc
    UNION
    SELECT a.x, b.y
    FROM Tc AS a
    JOIN Arc AS b ON a.y = b.x
)
SELECT COUNT(*) FROM Tc;
