Skip to content

Commit

Permalink
Adding pgq keywords to colid & non-reserved keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
Dtenwolde committed Jun 28, 2023
1 parent 9c9df64 commit 7d10947
Show file tree
Hide file tree
Showing 5 changed files with 17,344 additions and 16,861 deletions.
64 changes: 64 additions & 0 deletions test/sql/sqlpgq/pgq_keywords.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

statement ok
pragma enable_verification

require duckpgq

statement ok
select 1 as path;

statement ok
select 1 as group;

statement ok
SELECT database_oid AS seq, database_name AS name, path AS file FROM duckdb_databases() WHERE NOT internal ORDER BY 1

statement ok
CREATE TABLE Student(id BIGINT, name VARCHAR);

statement ok
CREATE TABLE know(src BIGINT, dst BIGINT, createDate BIGINT);

statement ok
CREATE TABLE School(name VARCHAR, Id BIGINT, Kind VARCHAR);

statement ok
CREATE TABLE StudyAt(personId BIGINT, schoolId BIGINT);

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

statement ok
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);

statement ok
INSERT INTO School VALUES ('VU', 0, 'University'), ('UVA', 1, 'University');

statement ok
INSERT INTO StudyAt VALUES (0, 0), (1, 0), (2, 1), (3, 1), (4, 1);

statement ok
-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
);

query II
-SELECT study.name, study.school
FROM GRAPH_TABLE (pg
MATCH
(a:Person)-[s:StudyAt]->(b:School)
WHERE a.name = 'Daniel'
COLUMNS (a.name as name, b.name as school)
) study;
----
Daniel VU
3 changes: 3 additions & 0 deletions third_party/libpg_query/grammar/statements/common.y
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ qualified_name:
ColId: IDENT { $$ = $1; }
| unreserved_keyword { $$ = pstrdup($1); }
| col_name_keyword { $$ = pstrdup($1); }
| pgq_unreserved_keyword { $$ = pstrdup($1); }
;


Expand Down Expand Up @@ -76,5 +77,7 @@ ColLabel: IDENT { $$ = $1; }
| other_keyword { $$ = pstrdup($1); }
| unreserved_keyword { $$ = pstrdup($1); }
| reserved_keyword { $$ = pstrdup($1); }
| pgq_unreserved_keyword { $$ = pstrdup($1); }

;

1 change: 1 addition & 0 deletions third_party/libpg_query/grammar/statements/explain.y
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ ExplainableStmt:
NonReservedWord: IDENT { $$ = $1; }
| unreserved_keyword { $$ = pstrdup($1); }
| other_keyword { $$ = pstrdup($1); }
| pgq_unreserved_keyword { $$ = pstrdup($1); }
;


Expand Down
6 changes: 6 additions & 0 deletions third_party/libpg_query/grammar/statements/select.y
Original file line number Diff line number Diff line change
Expand Up @@ -3973,16 +3973,22 @@ Iconst: ICONST { $$ = $1; };
type_function_name: IDENT { $$ = $1; }
| unreserved_keyword { $$ = pstrdup($1); }
| type_func_name_keyword { $$ = pstrdup($1); }
| pgq_unreserved_keyword { $$ = pstrdup($1); }

;

function_name_token: IDENT { $$ = $1; }
| unreserved_keyword { $$ = pstrdup($1); }
| func_name_keyword { $$ = pstrdup($1); }
| pgq_unreserved_keyword { $$ = pstrdup($1); }

;

type_name_token: IDENT { $$ = $1; }
| unreserved_keyword { $$ = pstrdup($1); }
| type_name_keyword { $$ = pstrdup($1); }
| pgq_unreserved_keyword { $$ = pstrdup($1); }

;

any_name: ColId { $$ = list_make1(makeString($1)); }
Expand Down
Loading

0 comments on commit 7d10947

Please sign in to comment.