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

Support optional match

Open Dtenwolde opened this issue 11 months ago • 1 comments

Many SNB queries such as IC1, IC4, IC5 (see https://github.com/cwida/duckpgq-experiments/issues/26 for all) require optional matches. The PGQ syntax would be ()-[]->?().

Snippet from the SQL/PGQ specification section 10.6:

<questioned path primary> ::=
  <path primary> <question mark>

"NOTE 130 — Unlike most regular expression languages, is not equivalent to the quantifier {0,1}: the quantifier {0,1} exposes variables as group, whereas does not change the singleton variables that it exposes to group. However, does expose any singleton variables as conditional singletons."

The way to translate this would be with a LEFT OUTER JOIN

(b:Student)<-[k:Know]-(a:Student)-[sa:studyAt]->?(u:University)
select * from student s
join know k on s.id = k.src
join student s2 on s2.id = k.dst
left join studyat sa on sa.studentid = s.id
join university u on sa.universityid = u.id;

Dtenwolde avatar Mar 25 '24 15:03 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]