duckpgq-extension icon indicating copy to clipboard operation
duckpgq-extension copied to clipboard

Persist PGQ database objects across sessions

Open dbeatty10 opened this issue 1 year ago • 2 comments

What happens?

After opening a persistent database (rather than a transient in-memory DuckDB database), I expected PGQ objects to persist after exiting and re-starting.

But I got this error instead:

Error: Binder Error: Property graph snb does not exist

To Reproduce

This works:

$ ./build/release/duckdb db.db
-CREATE OR REPLACE TABLE tbl1 AS SELECT 1;
-SELECT * FROM tbl1;
.exit
./build/release/duckdb db.db
-SELECT * FROM tbl1;

But this doesn’t:

Open a persistent database file (which will create it if it doesn't already exist):

$ ./build/release/duckdb db.db

Create a property graph, do a PGQ query, and then exit:

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

-CREATE PROPERTY GRAPH snb
  VERTEX TABLES (
      Person LABEL Person
      )
  EDGE TABLES (
      person_knows_person     SOURCE KEY ( person1id ) REFERENCES Person ( id )
                              DESTINATION KEY ( person2id ) REFERENCES Person ( id )
                              LABEL Knows
      );

-FROM GRAPH_TABLE(snb
  MATCH (a:Person WHERE a.firstName = 'Jan')-[k:Knows]->(b:Person)
  COLUMNS (b.firstName)
  );

.exit

Re-open the file for the persistent database:

$ ./build/release/duckdb db.db

And try the same query again:

-FROM GRAPH_TABLE(snb
  MATCH (a:Person WHERE a.firstName = 'Jan')-[k:Knows]->(b:Person)
  COLUMNS (b.firstName)
  );

Output:

Error: Binder Error: Property graph snb does not exist

Environment

OS: macOS Version: duckdb-pgq v0.10.0 3e6d77b923

After following these installation instructions, here is my current version:

$ ./build/release/duckdb --version

v0.10.0 3e6d77b923

dbeatty10 avatar Feb 17 '24 18:02 dbeatty10

By design, property graphs only exist within the lifecycle of a connection. This means that once the connection is closed, the property graph is also removed. In a future version I would like to make property graphs persistent, so I'll leave this issue open EDIT: Clarified in documentation here

Dtenwolde avatar Feb 19 '24 10:02 Dtenwolde

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Sep 03 '24 12:09 github-actions[bot]