You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To summarize, if a union is desired where one column is null for one of the query clauses, there does not seem to be a way to get the parser to work upon querying because it gets thrown off by the differing types and the parser's internal header only allowing one type.
To elaborate on the specific example experiencing this issue, there are nodes with labels "person" or "role". Relationships are "contains" and are either a role-node contains another role-node, or a role-node contains a person-node. In order to get all of the person-nodes contained by a certain role-node, we need
all of the person-nodes directly contained by the role-node
all person-nodes contained by role-nodes which are contained by the role-node (and so on with nesting).
Let's say the role for which we want all of the people in it has a property "code" which is "engineer" and let's say we want the role each member is directly in as well as the member.
The first part can be accomplished by this query: MATCH (:role {code: "engineer"})-[:contains]->(member:person) return null AS child_role, member
The second part is similar and can be accomplished by this query: MATCH (:role {code: "engineer"})-[:parent*]->(child_role:role)-[:contains]->(member:person) return child_role, member
The issue when running this query with a union is the parse fails. This seems to be because the null child_role and the node child_role are different types.
There is a work around something like the following to avoid the null which works.
MATCH (root_role:role {code: "engineer"})-[:contains]->(member:person) return root_role AS child_role, member UNION MATCH (:role {code: "engineer"})-[:parent*]->(child_role:role)-[:contains]->(member:person) return child_role, member
The text was updated successfully, but these errors were encountered:
Testing on the current version of RedisGraph 2.2.8
I've ran the simplified query: RETURN null AS A, 3 AS B UNION RETURN 1 AS A, 2 AS B
Snippet:
import redis
from redisgraph import Graph
r = redis.Redis(host='localhost', port=6379)
redis_graph = Graph('g', r)
result = redis_graph.query("return null AS A, 3 AS B UNION RETURN 1 AS A, 2 AS B")
result.pretty_print()
And this is the result I got:
python ./union_test.py
+------+---+
| A | B |
+------+---+
| None | 3 |
| 1 | 2 |
+------+---+
Cached execution 0.0
internal execution time 0.3316
Is it possible that you're using an older version of RedisGraph or RedisGraph-py ?
To summarize, if a union is desired where one column is null for one of the query clauses, there does not seem to be a way to get the parser to work upon querying because it gets thrown off by the differing types and the parser's internal header only allowing one type.
To elaborate on the specific example experiencing this issue, there are nodes with labels "person" or "role". Relationships are "contains" and are either a role-node contains another role-node, or a role-node contains a person-node. In order to get all of the person-nodes contained by a certain role-node, we need
Let's say the role for which we want all of the people in it has a property "code" which is "engineer" and let's say we want the role each member is directly in as well as the member.
The first part can be accomplished by this query:
MATCH (:role {code: "engineer"})-[:contains]->(member:person) return null AS child_role, member
The second part is similar and can be accomplished by this query:
MATCH (:role {code: "engineer"})-[:parent*]->(child_role:role)-[:contains]->(member:person) return child_role, member
The issue when running this query with a union is the parse fails. This seems to be because the null child_role and the node child_role are different types.
There is a work around something like the following to avoid the null which works.
The text was updated successfully, but these errors were encountered: