GeezerVison is showing github.com — Improve result formatting for variable length pattern and undirected pattern by gounnaa · Pull Request #728 · graphframes/graphframes
Conversation
gounnaa
commented
Oct 9, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
What changes were proposed in this pull request?
This PR improves the formatting for the variable-length and undirected motif pattern.
- Add informative columns:
_hop, _pattern, _direction
- Fix the first column name change for a variable-length pattern
The first edge column name for the fixed pattern (u)-[e*1]-(v) and the variable length pattern should be _e1, not e, so that it matches with the other column.
Case 1: undirected pattern
g.find("(u)-[]-(v)").where("u.id == 0").show()
Before:
It took me quite some time to understand why it returns two rows, not three rows. The bidirectional edge returns one with the anonymous edge pattern.
+---------+---------+
| u| v|
+---------+---------+
|{0, a, f}|{1, b, m}|
|{0, a, f}|{2, c, m}|
+---------+---------+
After:
It returns three rows with the information, two in edges and one out edge.
+---------+---------+-----------+----------+
| u| v| _pattern|_direction|
+---------+---------+-----------+----------+
|{0, a, f}|{1, b, m}|(u)<-[]-(v)| in|
|{0, a, f}|{2, c, m}|(u)<-[]-(v)| in|
|{0, a, f}|{1, b, m}|(u)-[]->(v)| out|
+---------+---------+-----------+----------+
Case 2: undirected variable-length pattern
g.find("(v)-[e*1..3]-(u)").where("u.id == 2").show()
Before:
Cannot understand why e column is placed at the end of the data frame, and not easy to understand the result.
+---------+---------------+---------+--------------+---------+--------------+---------+---------------+
| u| _e1| _v1| _e2| _v2| _e3| v| e|
+---------+---------------+---------+--------------+---------+--------------+---------+---------------+
|{2, c, m}|{2, 0, unknown}|{0, a, f}|{0, 1, friend}|{1, b, m}|{1, 2, friend}|{2, c, m}| NULL|
|{2, c, m}|{2, 0, unknown}|{0, a, f}|{0, 1, friend}|{1, b, m}|{1, 0, follow}|{0, a, f}| NULL|
|{2, c, m}|{2, 0, unknown}|{0, a, f}|{0, 1, friend}| NULL| NULL|{1, b, m}| NULL|
|{2, c, m}| NULL| NULL| NULL| NULL| NULL|{3, d, f}| {2, 3, follow}|
|{2, c, m}| NULL| NULL| NULL| NULL| NULL|{0, a, f}|{2, 0, unknown}|
|{2, c, m}| {1, 0, follow}|{0, a, f}|{0, 1, friend}|{1, b, m}|{1, 2, friend}|{1, b, m}| NULL|
|{2, c, m}|{2, 0, unknown}|{0, a, f}|{0, 1, friend}|{1, b, m}|{1, 2, friend}|{2, c, m}| NULL|
|{2, c, m}| {0, 1, friend}|{1, b, m}|{1, 2, friend}| NULL| NULL|{0, a, f}| NULL|
|{2, c, m}| NULL| NULL| NULL| NULL| NULL|{1, b, m}| {1, 2, friend}|
+---------+---------------+---------+--------------+---------+--------------+---------+---------------+
After:
The informative columns such as _hop, _pattern, _direction is added to help understand the results. It also ordered by _hop, _direction.
+---------+---------------+---------+--------------+---------+--------------+---------+----+--------------+----------+
| u| _e1| _v1| _e2| _v2| _e3| v|_hop| _pattern|_direction|
+---------+---------------+---------+--------------+---------+--------------+---------+----+--------------+----------+
|{2, c, m}| {1, 2, friend}| NULL| NULL| NULL| NULL|{1, b, m}| 1|(u)<-[e*1]-(v)| in|
|{2, c, m}| {2, 3, follow}| NULL| NULL| NULL| NULL|{3, d, f}| 1|(u)-[e*1]->(v)| out|
|{2, c, m}|{2, 0, unknown}| NULL| NULL| NULL| NULL|{0, a, f}| 1|(u)-[e*1]->(v)| out|
|{2, c, m}| {0, 1, friend}|{1, b, m}|{1, 2, friend}| NULL| NULL|{0, a, f}| 2|(u)<-[e*2]-(v)| in|
|{2, c, m}|{2, 0, unknown}|{0, a, f}|{0, 1, friend}| NULL| NULL|{1, b, m}| 2|(u)-[e*2]->(v)| out|
|{2, c, m}| {1, 0, follow}|{0, a, f}|{0, 1, friend}|{1, b, m}|{1, 2, friend}|{1, b, m}| 3|(u)<-[e*3]-(v)| in|
|{2, c, m}|{2, 0, unknown}|{0, a, f}|{0, 1, friend}|{1, b, m}|{1, 2, friend}|{2, c, m}| 3|(u)<-[e*3]-(v)| in|
|{2, c, m}|{2, 0, unknown}|{0, a, f}|{0, 1, friend}|{1, b, m}|{1, 2, friend}|{2, c, m}| 3|(u)-[e*3]->(v)| out|
|{2, c, m}|{2, 0, unknown}|{0, a, f}|{0, 1, friend}|{1, b, m}|{1, 0, follow}|{0, a, f}| 3|(u)-[e*3]->(v)| out|
+---------+---------------+---------+--------------+---------+--------------+---------+----+--------------+----------+
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
SemyonSinchenko reacted with heart emoji
gounnaa
changed the title
Improve result formatting for variable length pattern and undirected pattern
[WIP] Improve result formatting for variable length pattern and undirected pattern
Oct 9, 2025
gounnaa
changed the title
[WIP] Improve result formatting for variable length pattern and undirected pattern
Improve result formatting for variable length pattern and undirected pattern
Oct 9, 2025
gounnaa
commented
Oct 9, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Now, it make sense to me. Please merge this improvement before releasing the new version.
@SemyonSinchenko and @rjurney, I am waiting for your review. :)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @goungoun
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
gounnaa reacted with thumbs up emoji
|
While checking the examples in the manual, I found a bug and fixed. The named edge pattern (u)<-[e]->(v) should be transformed to (u)-[e1]->(v);(v)-[e2]->(u). (u)-[e]->(v);(v)-[e]->(u) is wrong.
|
SemyonSinchenko reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
SemyonSinchenko reacted with eyes emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
SemyonSinchenko reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|