Skip to content
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

Traverse strategy breadth_first won't work with LIMIT keyword #5330

Closed
giacomoParigi opened this issue Nov 16, 2015 · 7 comments
Closed

Traverse strategy breadth_first won't work with LIMIT keyword #5330

giacomoParigi opened this issue Nov 16, 2015 · 7 comments
Assignees
Labels
Milestone

Comments

@giacomoParigi
Copy link

I already posted a question in the issue tracker here : #5314 , but I realized that the question is too wide and decided to try and break it into smaller issues.

The first issue is a bug on the parsing of the Traverse operator. If the keyword <limit> is added, both with -1 or with an actual positive limit, the statement <strategy breadh_first> is ignored in turn, as shown by the results of these two simple queries on the GratefulDeadConcerts default database (start node is chosen randomly):

First query (without <limit>):

  select $current.traversedVertex(-1), $path from
  (
  traverse * from #9:24
    while $depth < 4

    strategy breadth_first
  ) 

Results (only first 20):

$current $path
#9:24 (#9:24)
#9:15 (#9:24).in_followed_by0
#9:15 (#9:24).in_followed_by1
#9:15 (#9:24).in_followed_by2
#9:15 (#9:24).in_followed_by3
#9:15 (#9:24).in_followed_by4
#9:15 (#9:24).out_followed_by0
#9:15 (#9:24).out_followed_by1
#9:15 (#9:24).out_followed_by2
#9:15 (#9:24).out_followed_by3
#9:15 (#9:24).out_followed_by4
#9:15 (#9:24).out_followed_by5
#9:15 (#9:24).out_followed_by6
#9:15 (#9:24).out_followed_by7
#9:15 (#9:24).out_followed_by8
#9:15 (#9:24).out_followed_by9
#9:15 (#9:24).out_followed_by10
#9:15 (#9:24).out_followed_by11
#9:15 (#9:24).out_followed_by12
#9:15 (#9:24).out_followed_by13

Second query (with <limit>):

  select $current.traversedVertex(-1), $path from
  (
  traverse * from #9:24
    while $depth < 4
    limit -1
    strategy breadth_first
  ) 

Results (only first 20):

$current $path
#9:24 (#9:24)
#9:15 (#9:24).in_followed_by0
#9:15 (#9:24).in_followed_by0.out(#9:15)
#9:3 (#9:24).in_followed_by0.out(#9:15).in_followed_by0
#9:4 (#9:24).in_followed_by0.out(#9:15).in_followed_by1
#9:5 (#9:24).in_followed_by0.out(#9:15).in_followed_by2
#9:11 (#9:24).in_followed_by0.out(#9:15).in_followed_by3
#9:12 (#9:24).in_followed_by0.out(#9:15).in_followed_by4
#9:14 (#9:24).in_followed_by0.out(#9:15).in_followed_by5
#9:17 (#9:24).in_followed_by0.out(#9:15).in_followed_by6
#9:16 (#9:24).in_followed_by0.out(#9:15).in_followed_by7
#9:92 (#9:24).in_followed_by0.out(#9:15).in_followed_by8
#9:109 (#9:24).in_followed_by0.out(#9:15).in_followed_by9
#9:54 (#9:24).in_followed_by0.out(#9:15).in_followed_by10
#9:83 (#9:24).in_followed_by0.out(#9:15).in_followed_by11
#9:48 (#9:24).in_followed_by0.out(#9:15).in_followed_by12
#9:53 (#9:24).in_followed_by0.out(#9:15).in_followed_by13
#9:41 (#9:24).in_followed_by0.out(#9:15).in_followed_by14
#9:160 (#9:24).in_followed_by0.out(#9:15).in_followed_by15
#9:146 (#9:24).in_followed_by0.out(#9:15).in_followed_by16
@lvca lvca added this to the 2.1.x (next hotfix) milestone Nov 17, 2015
@lvca lvca added the bug label Nov 17, 2015
@luigidellaquila
Copy link
Member

Hi @giacomoParigi

you should apply the LIMIT clause to the outer query, otherwise Studio will apply a 20 by default,
eg.

  select $current.traversedVertex(-1), $path from
  (
  traverse * from #9:24
    while $depth < 4
    strategy breadth_first
  ) 
  limit -1

@luigidellaquila
Copy link
Member

I'm closing this, please reopen in case I missed something

Thanks

Luigi

@giacomoParigi
Copy link
Author

The problem is not on the number of results (in that case you would be right pointing at the position of the LIMIT clause), but on their order. When the LIMIT clause is applied to the inner query - i.e. the TRAVERSE - the strategy falls back to the default depth_first, ignoring the following strategy statement.

@giacomoParigi
Copy link
Author

To replicate it should be enough to copy and paste the queries - the results are from the public GratefulDeadConcerts database - but if it is useful I can add a scripted toy example.

@luigidellaquila
Copy link
Member

ouch... ok, reopening

@luigidellaquila
Copy link
Member

Ciao @giacomoParigi

I just pushed a fix on 2.1.x branch, it was a trivial parsing problem.
Now I'm porting the fix to develop branch

Thanks

Luigi

@luigidellaquila
Copy link
Member

Ok, it's also fixed in develop branch.
I'm closing this, please reopen in case something is missing

Thanks

Luigi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants