cwida / duckpgq-extension

DuckDB extension that adds support for SQL/PGQ
https://duckpgq.notion.site/b8ac652667964f958bfada1c3e53f1bb?v=3b47a8d44bdf4e0c8b503bf23f1b76f2
MIT License
72 stars 7 forks source link

Describe property graph #115

Closed Dtenwolde closed 7 months ago

Dtenwolde commented 7 months ago

Fixes #114

It is now possible to do DESCRIBE PROPERTY GRAPH <pg_name> which shows you details of a property graph you have previously created. For example:

import database 'duckdb-pgq/data/SNB0.003'; 

-CREATE OR REPLACE PROPERTY GRAPH snb
  VERTEX TABLES (
      Person LABEL Person,
      Organisation LABEL Organisation IN typemask(company, university)
      )
  EDGE TABLES (
      Person_knows_person     SOURCE KEY (Person1Id) REFERENCES Person (id)
                              DESTINATION KEY (Person2Id) REFERENCES Person (id)
                              LABEL Knows
      );

Will be described as follows:

-DESCRIBE PROPERTY GRAPH snb;

┌─────────────────────┬──────────────┬─────────────────┬──────────────┬───────────┬─────────────┬───────────────────┬────────────────┬────────────────┬───────────────┬───────────────────────┐
│     table_name      │    label     │ is_vertex_table │ source_table │ source_pk │  source_fk  │ destination_table │ destination_pk │ destination_fk │ discriminator │      sub_labels       │
│       varchar       │   varchar    │     boolean     │   varchar    │ varchar[] │  varchar[]  │      varchar      │   varchar[]    │   varchar[]    │    varchar    │       varchar[]       │
├─────────────────────┼──────────────┼─────────────────┼──────────────┼───────────┼─────────────┼───────────────────┼────────────────┼────────────────┼───────────────┼───────────────────────┤
│ Organisation        │ organisation │ true            │              │           │             │                   │                │                │ typemask      │ [company, university] │
│ Person              │ person       │ true            │              │           │             │                   │                │                │               │                       │
│ Person_knows_person │ knows        │ false           │ Person       │ [id]      │ [Person1Id] │ Person            │ [id]           │ [Person2Id]    │               │                       │
└─────────────────────┴──────────────┴─────────────────┴──────────────┴───────────┴─────────────┴───────────────────┴────────────────┴────────────────┴───────────────┴───────────────────────┘

If the property graph does not exist, an error is thrown.