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

SQL: "bothE" function returns number of edges instead of array of edges #1590

Open
gramian opened this issue May 10, 2024 · 5 comments
Open
Assignees
Milestone

Comments

@gramian
Copy link
Collaborator

gramian commented May 10, 2024

ArcadeDB Version:

ArcadeDB Server v24.5.1-SNAPSHOT (build 7872d1acb3616c2866613dabcb7d899322bb3348/1715204385992/main)

OS and JDK Version:

Running on Mac OS X 12.7.4 - OpenJDK 64-Bit Server VM 17.0.11 (Homebrew)

Expected behavior

[{"@cat":"e","@type":"E","@rid":"#25:0","@in":"#1:0","@out":"#1:0"},{"@cat":"e","@type":"E","@rid":"#25:0","@in":"#1:0","@out":"#1:0"}]

Actual behavior

2

Steps to reproduce

CREATE VERTEX TYPE V;
CREATE EDGE TYPE E;
INSERT INTO V;
CREATE EDGE E FROM (SELECT FROM V) TO (SELECT FROM V);
SELECT bothE() FROM V;
@gramian
Copy link
Collaborator Author

gramian commented May 17, 2024

@gramian
Copy link
Collaborator Author

gramian commented Jun 9, 2024

@lvca this is weird:

Changing in https://github.com/ArcadeData/arcadedb/blob/main/engine/src/main/java/com/arcadedb/graph/GraphEngine.java#L438 :

return result;

to:

return () -> result;

seems to make it work, but I do not understand why, as for vertices (see getVertices in the same file) it works correctly without the () ->.

@lvca
Copy link
Contributor

lvca commented Jun 9, 2024

The issue is here:

if (useCollectionSizeForEdges && value.iterator().next() instanceof Edge)
. The serializer for studio put edge count every time a collection of edges is present.

From studio if you want to see the result in a table use this SELECT expand( bothE() ) FROM V.

With HTTP/JSON API, the recommended serializer used is "graph" that also uses this settings, so the result would still be 2.

@lvca lvca self-assigned this Jun 9, 2024
@lvca lvca added this to the 24.6.1 milestone Jun 9, 2024
@gramian
Copy link
Collaborator Author

gramian commented Jun 9, 2024

OK, but why do inE and outE work as expected? Also I confirm that bothE works in console.

@lvca
Copy link
Contributor

lvca commented Jun 12, 2024

The reason is that bothE returns a collection. I think it was introduced to avoid serializing vertices with thousands of edges. But in your case you're expressly asking for them, so it should return the edges, not the counter.

@lvca lvca modified the milestones: 24.6.1, 24.8.1 Jul 23, 2024
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

No branches or pull requests

2 participants