Skip to content

Add support for GPML-style graph query parsing #548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 21, 2025
Merged

Conversation

jpschorr
Copy link
Contributor

@jpschorr jpschorr commented Mar 18, 2025

This adds addtional features to the draft parser/AST support for a subset of GPML as outlined by Graph Pattern Matching in GQL and SQL/PGQ.

The targeted language definition is what was proposed in RFC-0025 and RFC-0033.

Added by this PR:

  • basic and abbreviated node and edge patterns (section 4.1 of the GPML paper)
  • concatenated path patterns (section 4.2 of the GPML paper)
  • path variables (section 4.2 of the GPML paper)
  • graph patterns (i.e., comma separated path patterns) (section 4.3 of the GPML paper)
  • AST support for path quantifiers (section 4.4 of the GPML paper)
  • parenthesized patterns (section 4.4 of the GPML paper)
  • parsing support for path quantifiers (section 4.4 of the GPML paper)
  • restrictors and selector (section 5.1 of the GPML paper)
  • parsing support for pre-filters and post-filters (section 5.2 of the GPML paper)
  • AST support for pre-filters (section 5.2 of the GPML paper)

GPML features not yet implemented:

  • group variables (section 4.4 of the GPML paper)
  • path pattern union and multiset (section 4.5 of the GPML paper)
  • conditional variables (section 4.6 of the GPML paper)
  • graphical predicates (section 4.7 of the GPML paper)
  • aggregates of unbounded variables (section 5.3 of the GPML paper)

Reviving #148


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jpschorr jpschorr changed the title Import 'Add experimental draft support for GPML-style graph query par… Import 'Add experimental draft support for GPML-style graph query parsing Mar 18, 2025
Copy link

codecov bot commented Mar 18, 2025

Codecov Report

Attention: Patch coverage is 90.76087% with 34 lines in your changes missing coverage. Please review.

Project coverage is 81.91%. Comparing base (24ab5bd) to head (440d5ac).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
partiql-ast/src/visit.rs 66.66% 12 Missing ⚠️
partiql-common/src/pretty.rs 50.00% 9 Missing ⚠️
partiql-ast/src/pretty.rs 95.62% 6 Missing and 2 partials ⚠️
partiql-parser/src/lexer/partiql.rs 55.55% 4 Missing ⚠️
...sion/partiql-extension-visualize/src/ast_to_dot.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #548      +/-   ##
==========================================
+ Coverage   81.78%   81.91%   +0.13%     
==========================================
  Files         106      106              
  Lines       22037    22386     +349     
  Branches    22037    22386     +349     
==========================================
+ Hits        18022    18337     +315     
- Misses       3504     3536      +32     
- Partials      511      513       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

github-actions bot commented Mar 18, 2025

Conformance comparison report

Base (24ab5bd) 2d1f652 +/-
% Passing 87.15% 87.15% 0.00%
✅ Passing 5603 5603 0
❌ Failing 826 826 0
🔶 Ignored 0 0 0
Total Tests 6429 6429 0

Number passing in both: 5603

Number failing in both: 826

Number passing in Base (24ab5bd) but now fail: 0

Number failing in Base (24ab5bd) but now pass: 0

@jpschorr jpschorr changed the title Import 'Add experimental draft support for GPML-style graph query parsing Add support for GPML-style graph query parsing Mar 20, 2025
@jpschorr jpschorr marked this pull request as ready for review March 20, 2025 19:02
@jpschorr jpschorr requested review from alancai98 and am357 March 20, 2025 19:02
Comment on lines +414 to +425
pub fn is_var_non_reserved(&self) -> bool {
matches!(
self,
Token::Acyclic | Token::Any | Token::Simple | Token::Shortest | Token::Trail
)
}
pub fn is_fn_non_reserved(&self) -> bool {
matches!(
self,
Token::Acyclic | Token::Any | Token::Simple | Token::Shortest | Token::Trail
)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will some more tokens be added as non-reserved in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is, generally, the nature of non-reserved tokens. If you add a new token to the grammar (generally in a subset that didn't exist before), that was previously able to be used as, e.g., a name, then this is a way to handle it.

Comment on lines +981 to +983
AnyK(NonZeroU32),
ShortestK(NonZeroU32),
ShortestKGroup(NonZeroU32),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the GPML paper require the k be non-zero? perhaps it's non-sensical to have a k of 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shortest 0 paths are the empty set.

@jpschorr jpschorr mentioned this pull request Mar 21, 2025
3 tasks
@jpschorr jpschorr requested a review from alancai98 March 21, 2025 20:48
@jpschorr jpschorr merged commit eb01344 into main Mar 21, 2025
19 checks passed
@jpschorr jpschorr deleted the feat-parse-gpml branch March 21, 2025 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants