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

Cannot using multi target LET #9164

Open
anhzin opened this issue Mar 11, 2020 · 11 comments
Open

Cannot using multi target LET #9164

anhzin opened this issue Mar 11, 2020 · 11 comments
Assignees
Labels
Milestone

Comments

@anhzin
Copy link

anhzin commented Mar 11, 2020

OrientDB Version: 3.0.29

Java Version: 8

OS: window

Expected behavior

When executing the command:

SELECT expand($rFinal)
let
$result0 = (TRAVERSE outE('rel_1'),inV() from [#50:1] MAXDEPTH 2 STRATEGY BREADTH_FIRST ),
$result1 = (TRAVERSE outE('rel_2'),inV() from $result0 STRATEGY BREADTH_FIRST ),
$result2 = (TRAVERSE outE('rel_3'),inV() from $result1 STRATEGY BREADTH_FIRST ) ,
$rFinal = intersect( unionall(#50:1,$result0,$result1,$result2))

  • Returns all vertices for this query
  • Can use multi-target LET (using for regression )
  • Can use commands: intersect, unionall
  • Support regression query

Actual behavior

Exception: com.orientechnologies.orient.core.exception.OCommandExecutionException: Class $result0 not found DB name=

Steps to reproduce

In Orientdb 2.2.x the below used to work

SELECT expand($rFinal)
let
$result0 = (TRAVERSE outE('rel_1'),inV() from [#50:1] MAXDEPTH 2 STRATEGY BREADTH_FIRST ),
$result1 = (TRAVERSE outE('rel_2'),inV() from $result0 STRATEGY BREADTH_FIRST ),
$result2 = (TRAVERSE outE('rel_3'),inV() from $result1 STRATEGY BREADTH_FIRST ) ,
$rFinal = intersect( unionall(#50:1,$result0,$result1,$result2))

But in v3.0.29, this also throws exception with above query:
com.orientechnologies.orient.core.exception.OCommandExecutionException: Class $result0 not found DB name=

in v3.0.29, It can work If I change the query to
SELECT expand($result0)
let
$result0 = (TRAVERSE outE('rel_1'),inV() from [#50:1] MAXDEPTH 2 STRATEGY BREADTH_FIRST )

But my business logic need to using regression.
If the query had more than 2 LET. The error always appears.

@anhzin anhzin changed the title Cannot using multi target LET, intersect, unionall Cannot using multi target LET Mar 11, 2020
@luigidellaquila
Copy link
Member

Hi @anhzin

Could you please post an example using DemoDB? It will make it much easier for me to reproduce and debug

Thanks

Luigi

@luigidellaquila
Copy link
Member

Oh, I think I got it, could you please try the following:

TRAVERSE outE('rel_2'),inV() from (SELECT expand($result0)) STRATEGY BREADTH_FIRST 

TRAVERSE outE('rel_2'),inV() from (SELECT FROM $result0) STRATEGY BREADTH_FIRST 

Even if it works, please keep this issue open, I'd like to see if we can add the support for the original TRAVERSE query

Thanks

Luigi

@luigidellaquila luigidellaquila self-assigned this Mar 11, 2020
@anhzin
Copy link
Author

anhzin commented Mar 11, 2020

@luigidellaquila
Explain:
The business is: I want to make a dynamic report and for a specific customer.
The condition for getting edge will load from the config. It means that I need to use regression for generating the query like below.

Expected behavior:

  • I want to get all vertex and edge like the image below.

image

the real query will be

SELECT expand($rFinal)
let
$result0 = (TRAVERSE outE('User_Order'),inV() from [#21:0] MAXDEPTH 2 STRATEGY BREADTH_FIRST ),
$result1 = (TRAVERSE outE('Order_Product'),inV() from $result0 STRATEGY BREADTH_FIRST ),
$result2 = (TRAVERSE outE('Product_Factory'),inV() from $result1 STRATEGY BREADTH_FIRST ) ,
$rFinal = intersect( unionall(#21:0,$result0,$result1,$result2))

with v2.2.x, the result will be
image

the demo database

demo_test.zip

@anhzin
Copy link
Author

anhzin commented Mar 11, 2020

(SELECT expand($result0))

@luigidellaquila
With v3.0.29.x
When I changed the query like your suggestion

SELECT expand($rFinal)
let
$result0 = (TRAVERSE outE('User_Order'),inV() from [#21:0] MAXDEPTH 2 STRATEGY BREADTH_FIRST ),
$result1 = (TRAVERSE outE('Order_Product'),inV() from (SELECT expand($result0)) STRATEGY BREADTH_FIRST ),
$result2 = (TRAVERSE outE('Product_Factory'),inV() from (SELECT expand($result1)) STRATEGY BREADTH_FIRST ) ,
$rFinal = intersect( unionall(#21:0,$result0,$result1,$result2))

image

and change the query to second suggestion

SELECT expand($rFinal)
let
$result0 = (TRAVERSE outE('User_Order'),inV() from [#21:0] MAXDEPTH 2 STRATEGY BREADTH_FIRST ),
$result1 = (TRAVERSE outE('Order_Product'),inV() from (SELECT FROM $result0) STRATEGY BREADTH_FIRST ),
$result2 = (TRAVERSE outE('Product_Factory'),inV() from (SELECT FROM $result1) STRATEGY BREADTH_FIRST ) ,
$rFinal = intersect( unionall(#21:0,$result0,$result1,$result2))

image

Both of it returns Empty.

@anhzin
Copy link
Author

anhzin commented Mar 17, 2020

@luigidellaquila
Can you help me to set to Label for this issue and can you tell me the plan for resolving this issue?
I'm going to change from 2.2.x to 3.0.x
I want to know your thinking before changing and create a detailed plan.
Thanks a lot

@luigidellaquila
Copy link
Member

Hi @anhzin

Sorry, I had no chance to test it yet, I'll try to do ASAP and let you know

Thanks

Luigi

@KiyoshiCMF
Copy link

KiyoshiCMF commented Apr 15, 2020

Hi, @luigidellaquila
Could you share status of this LET issue?

Thanks,
Kiyoshi (bahalf of anhzin)

@tglman tglman added this to the 3.0.x milestone Jun 1, 2020
@tglman tglman added the bug label Jun 1, 2020
@KiyoshiCMF
Copy link

HI,
I hope this issue is in the queue to get fixed.
This one prevent us tp upgrade to v3.0.x.

Thanks,
Kiyoshi

@qualitesys
Copy link
Contributor

Hi,

I am also blocked because of this issue on multiple LET. The v2.xx versions of OrientDB a too outdated now.
I wish to intersect in and out edges to detect cycles in graphs.

Is this issue planed to be fixed ?
Thanks

PS : Here a broken simple example coming from here https://stackoverflow.com/questions/34601966/temporary-collection-in-an-orientdb-query-using-the-intersect-function

select intersect($a.left, $b.right)
let $a = (select [12, 34] as left), 
    $b = (select [1, 5, 9, 12, 28, 34, 45] as right)

@KiyoshiCMF
Copy link

I am still waiting the fix.
This issue blocking for us to upgrade and v3.x.

@ikysil
Copy link
Contributor

ikysil commented Oct 8, 2021

@qualitesys

It is possible to change the example from the StackOverflow so that it gives the same result with both OrientDB 2.x and OrientDB 3.x series:

select intersect($a[0].left, $b[0].right)
let $a = (select [12, 34] as left), 
    $b = (select [1, 5, 9, 12, 28, 34, 45] as right)

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

7 participants