Skip to content

fix: allow undirected fixed length pattern#781

Merged
SemyonSinchenko merged 1 commit into
graphframes:mainfrom
goungoun:main
Jan 27, 2026
Merged

fix: allow undirected fixed length pattern#781
SemyonSinchenko merged 1 commit into
graphframes:mainfrom
goungoun:main

Conversation

@goungoun
Copy link
Copy Markdown
Contributor

@goungoun goungoun commented Jan 25, 2026

What changes were proposed in this pull request?

It aims to support undirected fixed length pattern (u)-[*2]-(v).

Why are the changes needed?

The pattern fails, which is unexpected.

$ spark-shell --packages io.graphframes:graphframes-spark4_2.13:0.10.0
scala> import org.graphframes.{examples,GraphFrame}
import org.graphframes.{examples, GraphFrame}

scala> val g: GraphFrame = examples.Graphs.friends
val g: org.graphframes.GraphFrame = GraphFrame(v:[id: string, name: string ... 1 more field], e:[src: string, dst: string ... 1 more field])

scala> g.find("(u)-[e*2]-(v)").show()
org.graphframes.InvalidParseException: Failed to parse bad motif string: '(u)-[e*2]-(v)'.  Returned message: '->' expected but '-' found
  at org.graphframes.pattern.Pattern$.parse(patterns.scala:83)
  at org.graphframes.GraphFrame.findAugmentedPatterns(GraphFrame.scala:520)
  at org.graphframes.GraphFrame.find(GraphFrame.scala:515)
  ... 42 elided

It may not easy to come up with a workaround by end users. It is to rewrite the pattern manually, (u)-[*2..2]-(v).

What changes were proposed in this pull request?

It implements exactly the way of workaround by adding the another pattern to the find method directly.

It does not yet cover undirected fixed-length chaining patterns such as (u)-[*2]-(v); (v)-[]->(k), but I am opening this PR as a quick fix in case someone needs it.

@goungoun goungoun changed the title [WIP] fix: allow undirected fixed length patternundirected fixed length pattern [WIP] fix: allow undirected fixed length pattern Jan 25, 2026
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 84.07%. Comparing base (e24f15e) to head (cdd3f79).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
...re/src/main/scala/org/graphframes/GraphFrame.scala 95.23% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #781      +/-   ##
==========================================
- Coverage   84.49%   84.07%   -0.43%     
==========================================
  Files          66       66              
  Lines        3179     3340     +161     
  Branches      387      401      +14     
==========================================
+ Hits         2686     2808     +122     
- Misses        493      532      +39     

☔ 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.

@goungoun goungoun changed the title [WIP] fix: allow undirected fixed length pattern fix: allow undirected fixed length pattern Jan 25, 2026
@goungoun goungoun marked this pull request as ready for review January 25, 2026 10:37
@goungoun
Copy link
Copy Markdown
Contributor Author

@SemyonSinchenko, I actually cannot understand the comment from Codecov. If there is anything I have to do, please let me know.

@SemyonSinchenko
Copy link
Copy Markdown
Collaborator

@SemyonSinchenko, I actually cannot understand the comment from Codecov. If there is anything I have to do, please let me know.

This codecov is a legacy from the ancient time. Someone should fix or remove it, but I dont have time :(

Ignore it, it is really strange.

Comment thread core/src/main/scala/org/graphframes/GraphFrame.scala
@SemyonSinchenko SemyonSinchenko merged commit 3270c22 into graphframes:main Jan 27, 2026
5 checks passed
@SemyonSinchenko
Copy link
Copy Markdown
Collaborator

Thanks again for owning this @goungoun !

@goungoun
Copy link
Copy Markdown
Contributor Author

goungoun commented Jan 27, 2026

@SemyonSinchenko I always appreciate for your help!

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.

3 participants