cwida / duckpgq-extension

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

Create if not exists property graph #155

Open Dtenwolde opened 3 weeks ago

Dtenwolde commented 3 weeks ago

What happens?

DuckDB has various "on conflict" modes, such as CREATE OR REPLACE and CREATE IF NOT EXISTS. Property graph creation syntax does not yet support CREATE IF NOT EXISTS, which would be the last one to support. Also, check if this is implemented for dropping a property graph.

Creating a property graph with this syntax should either create one if it doesn't exist, or silently return if it already does without throwing an error.

To Reproduce

CREATE TABLE Student(id BIGINT, name VARCHAR);
CREATE TABLE know(src BIGINT, dst BIGINT, createDate BIGINT);

CREATE TABLE School(school_name VARCHAR, school_id BIGINT, school_kind BIGINT);

INSERT INTO Student VALUES (0, 'Daniel'), (1, 'Tavneet'), (2, 'Gabor'), (3, 'Peter');

INSERT INTO know VALUES (0,1, 10), (0,2, 11), (0,3, 12), (1,2, 14), (1,3, 15), (2,3, 16

-CREATE IF NOT EXISTS PROPERTY GRAPH pg_all_properties
VERTEX TABLES (
    Student,
    School  LABEL School IN School_kind (Hogeschool, University)
    )
EDGE TABLES (
    know    SOURCE KEY ( src ) REFERENCES Student ( id )
            DESTINATION KEY ( dst ) REFERENCES Student ( id )
            LABEL Knows
    )

-- Shouldn't do anything
-CREATE IF NOT EXISTS PROPERTY GRAPH pg_all_properties
VERTEX TABLES (
    Student,
    School  LABEL School IN School_kind (Hogeschool, University)
    )
EDGE TABLES (
    know    SOURCE KEY ( src ) REFERENCES Student ( id )
            DESTINATION KEY ( dst ) REFERENCES Student ( id )
            LABEL Knows
    )

OS:

macOs 13 - Apple M1 Pro

DuckDB Version:

v1.1.2

DuckDB Client:

CLI

Full Name:

Daniel ten Wolde

Affiliation:

CWI

How did you load the extension?

Built from source

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?