Skip to content

Commit

Permalink
Merge pull request #175 from cwida/89-make-graph-table-name-optional
Browse files Browse the repository at this point in the history
Change parser, add test
  • Loading branch information
Dtenwolde authored Feb 13, 2024
2 parents 0817ac6 + 41aca59 commit 93b6325
Show file tree
Hide file tree
Showing 4 changed files with 14,648 additions and 14,581 deletions.
8 changes: 5 additions & 3 deletions src/parser/transform/tableref/transform_match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,11 @@ unique_ptr<PathPattern> Transformer::TransformPath(duckdb_libpgquery::PGPathPatt
unique_ptr<TableRef> Transformer::TransformMatch(duckdb_libpgquery::PGMatchClause &root) {
auto match_info = make_uniq<MatchExpression>();
match_info->pg_name = root.pg_name; // Name of the property graph to bind to

auto alias = TransformQualifiedName(*root.graph_table);
match_info->alias = alias.name;
string alias_name;
if (root.graph_table) {
alias_name = TransformQualifiedName(*root.graph_table).name;
}
match_info->alias = alias_name.empty() ? "unnamed_graphtable" : alias_name;

if (root.where_clause) {
match_info->where_clause = TransformExpression(root.where_clause);
Expand Down
8 changes: 7 additions & 1 deletion third_party/libpg_query/grammar/statements/pgq.y
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,15 @@ GraphTableWhereOptional:
/* EMPTY */ { $$ = NULL; }
;

GraphTableNameOptional:
qualified_name { $$ = $1; }
|
/* EMPTY */ { $$ = NULL; }
;

GraphTableStmt:
'(' PGQ_IDENT MATCH PathPatternList KeepOptional GraphTableWhereOptional
COLUMNS '(' ColumnList ')' ')' qualified_name
COLUMNS '(' ColumnList ')' ')' GraphTableNameOptional
{
PGMatchClause *n = makeNode(PGMatchClause);
n->pg_name = $2;
Expand Down
3 changes: 2 additions & 1 deletion third_party/libpg_query/grammar/types/pgq.yh
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@
%type <list> VertexPattern
%type <node> pgq_expr
%type <str> LabelOptional
%type <list> EdgeTablesClauseOptional
%type <list> EdgeTablesClauseOptional
%type <range> GraphTableNameOptional
Loading

0 comments on commit 93b6325

Please sign in to comment.