-
Notifications
You must be signed in to change notification settings - Fork 275
feat: variable length pattern matching #685
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
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fd5a548
variable length pattern matching
gounnaa e2980ac
scalafmtAll
gounnaa 0b947f4
fix exhaustive match error
gounnaa 588d8eb
more test cases
gounnaa 8532f9b
to specify the test result type to long
gounnaa 36a1acc
fixed formatting by scalafmtAll to pass Scala CI test
gounnaa 5e7c708
Improve error message
gounnaa ec12d16
var-length pattern prototype
gounnaa a121c02
find variable length pattern
gounnaa 8074635
unsupported case handling
gounnaa 2c47bcc
scalafmtAll
gounnaa 5efe0b7
fixed and var length with named edge support
gounnaa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
|
|
||
| package org.graphframes.pattern | ||
|
|
||
| import org.graphframes.GraphFramesUnreachableException | ||
| import org.graphframes.InvalidParseException | ||
| import org.graphframes.SparkFunSuite | ||
|
|
||
|
|
@@ -51,6 +52,36 @@ class PatternSuite extends SparkFunSuite { | |
| AnonymousEdge(NamedVertex("u"), NamedVertex("v")), | ||
| AnonymousEdge(NamedVertex("v"), NamedVertex("w")), | ||
| Negation(AnonymousEdge(NamedVertex("u"), NamedVertex("w"))))) | ||
|
|
||
| assert( | ||
| Pattern.parse("(u)-[*3]->(v)") === | ||
| Seq( | ||
| AnonymousEdge(NamedVertex("u"), NamedVertex("_v1")), | ||
| AnonymousEdge(NamedVertex("_v1"), NamedVertex("_v2")), | ||
| AnonymousEdge(NamedVertex("_v2"), NamedVertex("v")))) | ||
|
|
||
| assert( | ||
| Pattern.parse("(u)-[*5]->(v)") === | ||
| Seq( | ||
| AnonymousEdge(NamedVertex("u"), NamedVertex("_v1")), | ||
| AnonymousEdge(NamedVertex("_v1"), NamedVertex("_v2")), | ||
| AnonymousEdge(NamedVertex("_v2"), NamedVertex("_v3")), | ||
| AnonymousEdge(NamedVertex("_v3"), NamedVertex("_v4")), | ||
| AnonymousEdge(NamedVertex("_v4"), NamedVertex("v")))) | ||
|
|
||
| assert( | ||
| Pattern.parse("(u)-[*10]->(v)") === | ||
| Seq( | ||
| AnonymousEdge(NamedVertex("u"), NamedVertex("_v1")), | ||
| AnonymousEdge(NamedVertex("_v1"), NamedVertex("_v2")), | ||
| AnonymousEdge(NamedVertex("_v2"), NamedVertex("_v3")), | ||
| AnonymousEdge(NamedVertex("_v3"), NamedVertex("_v4")), | ||
| AnonymousEdge(NamedVertex("_v4"), NamedVertex("_v5")), | ||
| AnonymousEdge(NamedVertex("_v5"), NamedVertex("_v6")), | ||
| AnonymousEdge(NamedVertex("_v6"), NamedVertex("_v7")), | ||
| AnonymousEdge(NamedVertex("_v7"), NamedVertex("_v8")), | ||
| AnonymousEdge(NamedVertex("_v8"), NamedVertex("_v9")), | ||
| AnonymousEdge(NamedVertex("_v9"), NamedVertex("v")))) | ||
| } | ||
|
|
||
| test("bad parses") { | ||
|
|
@@ -123,6 +154,26 @@ class PatternSuite extends SparkFunSuite { | |
| } | ||
| } | ||
|
|
||
| test("unsupported parse on the fixed length patterns") { | ||
| withClue("Failed to catch parse error with graph frame unreachable") { | ||
| intercept[GraphFramesUnreachableException] { | ||
| Pattern.parse("(u)-[*0]->(v)") | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahhh thank you for this clarification! After we merge this PR, want to take on variable lengths as well? :) |
||
| } | ||
|
|
||
| withClue("Failed to catch parse error with bad motif string") { | ||
| intercept[InvalidParseException] { | ||
| Pattern.parse("(u)-[*]->(v)") | ||
| } | ||
| } | ||
|
|
||
| withClue("Failed to catch parse error with chaining quantified length pattern") { | ||
| intercept[InvalidParseException] { | ||
| Pattern.parse("(u)-[*2]->(v);(v)-[e]->(w)") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test("empty pattern should be parsable") { | ||
| Pattern.parse("") | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.