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

Different behavior of SQL statement when used within SQL function #8286

Closed
mollox opened this issue May 23, 2018 · 1 comment
Closed

Different behavior of SQL statement when used within SQL function #8286

mollox opened this issue May 23, 2018 · 1 comment
Assignees
Labels
Milestone

Comments

@mollox
Copy link

mollox commented May 23, 2018

OrientDB Version: 3.0.1 (official docker image)

Expected behavior

We ware trying to retrieve out vertices of a hierarchical structure in two different ways:
Via traverse, where all traversed vertices appear only once.
But we also need to retrieve them multiple times if they have multiple in edges (for counting in some scenarios). For that way we use the MATCH syntax.
Now when creating SQL functions with these statements, we expect the same result of the functions as when we execute the statements directly.

Actual behavior

Actually, when creating a SQL function with a MATCH statement, the function behaves like a traverse, but when executed directly, the multiple linked vertices appear multiple times.

Steps to reproduce

Simple data creation for reproducing:

CREATE CLASS C EXTENDS V
CREATE PROPERTY C.ID INTEGER

CREATE CLASS C_C EXTENDS E

INSERT INTO C (ID) VALUES (1)
INSERT INTO C (ID) VALUES (2)
INSERT INTO C (ID) VALUES (3)
INSERT INTO C (ID) VALUES (4)

CREATE EDGE C_C FROM (SELECT FROM C WHERE ID = 1) TO (SELECT FROM C WHERE ID = 2)
CREATE EDGE C_C FROM (SELECT FROM C WHERE ID = 1) TO (SELECT FROM C WHERE ID = 3)
CREATE EDGE C_C FROM (SELECT FROM C WHERE ID = 2) TO (SELECT FROM C WHERE ID = 4)
CREATE EDGE C_C FROM (SELECT FROM C WHERE ID = 3) TO (SELECT FROM C WHERE ID = 4)

Calculating vertices where they should only appear once (works, getting all 4 vertices):

TRAVERSE out() FROM (SELECT FROM C WHERE ID = 1)

Calculating vertex where they should appear multiple times (works when directly executed, getting vertice with ID 4 two times):

MATCH {class: C, where: (ID = 1)}.out(){as: result, while: (true)} RETURN result

Calculating vertices where they should appear multiple times from a function (does not work as expected, getting vertex with ID 4 only once, like traverse):

CREATE FUNCTION test "MATCH {class: C, where: (ID = 1)}.out(){as: result, while: (true)} RETURN result" LANGUAGE SQL

SELECT test()

Can be reproduced from console or within OrientDB Studio.

@luigidellaquila
Copy link
Member

Hi @mollox

I'm pushing a fix for this problem, it will be released with v 3.0.2

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

2 participants