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

MATCH after alter table returns binder exception #44

Closed Dtenwolde closed 2 months ago

Dtenwolde commented 1 year ago

Unsure how this should be handled. When updating a table that has been registered within a property graph, the following query won't work anymore, since the primary (or foreign key) which was used during registration no longer matches with the actual column value. Perhaps this is the way to handle it

# Data
CREATE TABLE Student(id BIGINT, name VARCHAR);
CREATE TABLE know(src BIGINT, dst BIGINT, createDate BIGINT);
CREATE TABLE School(name VARCHAR, Id BIGINT, Kind VARCHAR);
CREATE TABLE StudyAt(personId BIGINT, schoolId BIGINT);

INSERT INTO Student VALUES (0, 'Daniel'), (1, 'Tavneet'), (2, 'Gabor'), (3, 'Peter'), (4, 'David');
INSERT INTO know VALUES (0,1, 10), (0,2, 11), (0,3, 12), (3,0, 13), (1,2, 14), (1,3, 15), (2,3, 16), (4,3, 17);
INSERT INTO School VALUES ('VU', 0, 'University'), ('UVA', 1, 'University');
INSERT INTO StudyAt VALUES (0, 0), (1, 0), (2, 1), (3, 1), (4, 1);
-CREATE PROPERTY GRAPH pg
VERTEX TABLES (
    Student PROPERTIES ( id, name ) LABEL Person,
    School LABEL SCHOOL
    )
EDGE TABLES (
    know    SOURCE KEY ( src ) REFERENCES Student ( id )
            DESTINATION KEY ( dst ) REFERENCES Student ( id )
            LABEL Knows,
    studyAt SOURCE KEY ( personId ) REFERENCES Student ( id )
            DESTINATION KEY ( SchoolId ) REFERENCES School ( id )
            LABEL StudyAt
    );

ALTER TABLE student RENAME id TO jd;

-FROM GRAPH_TABLE (pg
    MATCH
    (a:Person)-[s:StudyAt]->(b:School)
    WHERE a.name = 'Daniel'
    COLUMNS (a.jd)
    ) study;

Binder Error: Table "a" does not have a column named "id"

Views provide a similar error:


create view v1 as select id from student; 
select * from v1; 
alter table student rename id to jd;
select * from v1; 
Error: Binder Error: Referenced column "id" not found in FROM clause!
Candidate bindings: "student.jd" 
Dtenwolde commented 1 year ago

Check what the behavior for a VIEW is and replicate that.

github-actions[bot] commented 2 months ago

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.

Dtenwolde commented 2 months ago

Running the example above returns Binder Error: Table "a" does not have a column named "id" which is the expected behaviour and in line with VIEW. Therefore closing this issue