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

Using an alias as table name in the source/destination edge definition #50

Closed Dtenwolde closed 11 months ago

Dtenwolde commented 1 year ago

In this case we have a table student, having the alias student_alias. The alias should then be able to be used in the source and destination key definition.

-CREATE PROPERTY GRAPH pg2
VERTEX TABLES (
    Student as Student_alias PROPERTIES ( id as id_alias, name ) LABEL Person
    )
EDGE TABLES (
    know    SOURCE KEY ( src ) REFERENCES Student_alias ( id )
            DESTINATION KEY ( dst ) REFERENCES Student ( id )
            PROPERTIES ( createDate ) LABEL Knows
    )

Current behaviour: Binder Error: Referenced vertex table Student_alias does not exist.

Expected behaviour: No error

Dtenwolde commented 11 months ago

You should be able to use the table_alias, but maybe it's best to translate this under the hood as soon as possible to reference the real table name. We should keep track of what aliases have been registered and upon seeing new tables, check if their source/destination references match an alias. In that case, don't use the alias but register the real table name.

During CREATE only an edge table can reference a vertex table with an alias. ~During MATCH both () and [] can use an alias. In both cases, we should catch this in the transformer and translate.~

Dtenwolde commented 11 months ago

Fixed in https://github.com/cwida/duckpgq-extension/commit/954f99fc1216fa3ad77f5491e1cce270bed8a72a