You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@age.apache.org by "dukeofhazardz (via GitHub)" <gi...@apache.org> on 2023/06/13 20:30:11 UTC

[GitHub] [age] dukeofhazardz opened a new issue, #988: Unexpected output from MATCH RETURN query when nodes don't have a specific property

dukeofhazardz opened a new issue, #988:
URL: https://github.com/apache/age/issues/988

   I executed a Cypher query using the `MATCH` and `RETURN` clauses, expecting to retrieve nodes that have the `com` property (**N/B:** There was no such property). I expected an error message to be thrown, however, the query returned empty rows even for nodes that don't have the `com` property. I would like to know if this is the expected behavior or if it should return an error message indicating the absence of such property.
   
   **Steps to Reproduce**
   1. Execute the following Cypher query:
   ```
   demo=# SELECT *
   FROM cypher('demo', $$
   MATCH (u)
   RETURN u.com
   $$) as (a agtype);
    a
   ---
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   (15 rows)
   ```
   **Additional Information:**
   
   - PostgreSQL version: 11.17
   - AGE extension version: 1.3.0
   - Environment: Command Line


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] waleedahmed0001 commented on issue #988: Unexpected output from MATCH RETURN query when nodes don't have a specific property

Posted by "waleedahmed0001 (via GitHub)" <gi...@apache.org>.
waleedahmed0001 commented on issue #988:
URL: https://github.com/apache/age/issues/988#issuecomment-1595844328

   Yes, the behaviour of Cypher is expected, as it does not check for the existence of a property on a node by default and instead returns null for missing properties.
   
   I am explaining it with another example.
   
   Let's consider an example where we have a graph representing a social network, with nodes representing users and edges representing relationships between them. Each user node has different properties such as "name," "age," and "city."
   
   Suppose we have the following nodes in our graph:
   ```
   (:User {name: 'Alice', age: 25, city: 'New York'})
   (:User {name: 'Bob', age: 30})
   (:User {name: 'Charlie', city: 'London'}
   ```
   
   If we execute a Cypher query to retrieve the "city" property of all users, even though not all users have the "city" property, Cypher will handle it gracefully.
   
   ```
   MATCH (u:User)
   RETURN u.city
   ```
   
   The results of the above query will be:
   
   ```
   
   │ u.city │
   │ New York│
   │        │
   │ London │
   
   ```
   
   As you can see, the query returns null for users who don't have the "city" property. This behavior allows the query to proceed without throwing an error, and you can still work with the returned data, handling null values appropriately.
   
   If you want to filter out nodes that don't have the "city" property, you can use a WHERE clause to achieve that:
   
   ```
   MATCH (u:User)
   WHERE EXISTS(u.city)
   RETURN u.city
   ```
   
   This modified query will only return the "city" property for users who have it defined:
   
   ```
   │ u.city │
   │ New York│
   │ London │
   
   ```
   
   By using the WHERE clause with EXISTS(u.city), we ensure that only nodes with the "city" property are included in the result.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] RahimullahShaheen commented on issue #988: Unexpected output from MATCH RETURN query when nodes don't have a specific property

Posted by "RahimullahShaheen (via GitHub)" <gi...@apache.org>.
RahimullahShaheen commented on issue #988:
URL: https://github.com/apache/age/issues/988#issuecomment-1591424131

   In the documentation of cypher, in the section working with null you can find that in cypher returning a property from a node that does not have said property produces null instead of throwing error  because null in cypher represents missing or undefined values.
   In your case as well, as there is no `com` property defined for any of the nodes, the result is empty rows which indicates that all nodes have null value for `com` property.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] humzakt commented on issue #988: Unexpected output from MATCH RETURN query when nodes don't have a specific property

Posted by "humzakt (via GitHub)" <gi...@apache.org>.
humzakt commented on issue #988:
URL: https://github.com/apache/age/issues/988#issuecomment-1592471718

   As discussed in the above answers, it is the expected behavior of the cypher query. You can study more about cypher queries in the [Documentation](http://age.apache.org/).
   If you want to filter out the nodes that don't have the 'com' property, you could use a WHERE clause to do this:
   
   ```
   demo=# SELECT *
   FROM cypher('demo', $$
   MATCH (u)
   WHERE u.com IS NOT NULL
   RETURN u.com
   $$) as (a agtype);
   
   ```
   
   This will only return nodes that have the 'com' property.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] TalhaMunir-JD commented on issue #988: Unexpected output from MATCH RETURN query when nodes don't have a specific property

Posted by "TalhaMunir-JD (via GitHub)" <gi...@apache.org>.
TalhaMunir-JD commented on issue #988:
URL: https://github.com/apache/age/issues/988#issuecomment-1591157173

   As already said this is the expected result. Incase if the property doesnot exist it will not throw any error and will return null for such nodes. In your case it doesn't throw an error when a property is not found, but instead, it returns NULL for that property.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] titoausten commented on issue #988: Unexpected output from MATCH RETURN query when nodes don't have a specific property

Posted by "titoausten (via GitHub)" <gi...@apache.org>.
titoausten commented on issue #988:
URL: https://github.com/apache/age/issues/988#issuecomment-1591128539

   Yes, this is expected. 
   The query simply searches all nodes with that property `com` and simply returns **NULL** which means there's no such property in the nodes available in the graph.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] dukeofhazardz closed issue #988: Unexpected output from MATCH RETURN query when nodes don't have a specific property

Posted by "dukeofhazardz (via GitHub)" <gi...@apache.org>.
dukeofhazardz closed issue #988: Unexpected output from MATCH RETURN query when nodes don't have a specific property
URL: https://github.com/apache/age/issues/988


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] jrgemignani commented on issue #988: Unexpected output from MATCH RETURN query when nodes don't have a specific property

Posted by "jrgemignani (via GitHub)" <gi...@apache.org>.
jrgemignani commented on issue #988:
URL: https://github.com/apache/age/issues/988#issuecomment-1601859543

   If this is resolved, please close the issue :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] Amr-Shams commented on issue #988: Unexpected output from MATCH RETURN query when nodes don't have a specific property

Posted by "Amr-Shams (via GitHub)" <gi...@apache.org>.
Amr-Shams commented on issue #988:
URL: https://github.com/apache/age/issues/988#issuecomment-1591060739

   Yes, the behavior of Cypher is expected, as it does not check for the existence of a property on a node by default and instead returns null for missing properties. This allows for flexible querying of graph data, as it is designed to handle graph nodes with different sets of properties. The flexibility of the query language allows for efficient querying and avoids the need for preprocessing the data, which can negatively impact performance.
   
   For example, if you have a graph with 12 nodes and you execute a query that attempts to retrieve nodes based on a particular property, Cypher will retrieve all nodes and check if that property exists in any of them. If the property is found, it will return the value of that property for the node, otherwise, it will return null. This approach allows for more efficient querying of graph data, as it avoids the need for preprocessing the data to ensure that all nodes have the same properties.
   
   Overall, the behavior of Cypher is designed to be flexible and efficient, allowing for querying of graph data with nodes that have different sets of properties, while also avoiding the need for preprocessing the data, which can negatively impact performance.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] AhmedMo0 commented on issue #988: Unexpected output from MATCH RETURN query when nodes don't have a specific property

Posted by "AhmedMo0 (via GitHub)" <gi...@apache.org>.
AhmedMo0 commented on issue #988:
URL: https://github.com/apache/age/issues/988#issuecomment-1591529833

   In Cypher, `null` is used to represent missing or undefined values. Conceptually, `null` means ‘a missing unknown value. For example getting a property from a vertex that does not have said property produces `null`. and that what happened in your example 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] Omar-Saad commented on issue #988: Unexpected output from MATCH RETURN query when nodes don't have a specific property

Posted by "Omar-Saad (via GitHub)" <gi...@apache.org>.
Omar-Saad commented on issue #988:
URL: https://github.com/apache/age/issues/988#issuecomment-1591627950

   Yes, the behavior you described is the expected behavior. In graph databases, the schema is flexible, allowing properties to be added dynamically to nodes and relationships. So when executing a Cypher query in a graph database and specifying a property that does not exist, the query is designed to return empty rows rather than throwing an error message. This flexibility in the graph database schema allows for easy adaptation to changing data requirements and the addition of new properties as needed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org