You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@age.apache.org by "MuhammadTahaNaveed (via GitHub)" <gi...@apache.org> on 2023/04/21 22:50:04 UTC

[GitHub] [age] MuhammadTahaNaveed opened a new issue, #829: Reuse of variable with label constraint in concurrent MATCH clauses does not error out

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

   **Describe the bug**
   Reuse of variable with label constraint in concurrent MATCH clauses neither filter nor error out 'multiple labels for variable not supported'
   
   **How are you accessing AGE (Command line, driver, etc.)?**
   - Command Line
   
   **What data setup do we need to do?**
   ```pgsql
   ...
   SELECT * from cypher('graph', $$
     CREATE ({name:'bobby'}),
            (:Person {name:'bobby'}),
            (:Bobby {name:'bobby'})
   $$) as (a agtype);
   ...
   ```
   
   
   **What is the command that caused the error?**
   ```pgsql
   SELECT * from cypher('graph', $$
         MATCH (u)
         MATCH (u:Person)
         RETURN u;
   $$) as (a agtype);
   ```
   ```
                                             a                                          
   -------------------------------------------------------------------------------------
    {"id": 281474976710657, "label": "", "properties": {"name": "bobby"}}::vertex
    {"id": 844424930131969, "label": "Person", "properties": {"name": "bobby"}}::vertex
    {"id": 1125899906842625, "label": "Bobby", "properties": {"name": "bobby"}}::vertex
   (3 rows)
   
   ```
   
   **Expected behavior**
   Most probably, should have error out like in `MATCH (a),(a:Person)` saying `ERROR:  multiple labels for variable 'u' are not supported`,
   
   **Environment (please complete the following information):**
   - Version: Latest
   
   


-- 
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] panosfol commented on issue #829: Reuse of variable with label constraint in concurrent MATCH clauses does not error out

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

   So it does perform filtering according to the properties but not on the labels. I stand corrected then, I agree with you that this is actually a bug, an interesting one i might add.


-- 
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 closed issue #829: Reuse of variable with label constraint in concurrent MATCH clauses does not error out

Posted by "jrgemignani (via GitHub)" <gi...@apache.org>.
jrgemignani closed issue #829: Reuse of variable with label constraint in concurrent MATCH clauses does not error out
URL: https://github.com/apache/age/issues/829


-- 
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] CapnSpek commented on issue #829: Reuse of variable with label constraint in concurrent MATCH clauses does not error out

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

   Ideally, the second MATCH should work as an intersection over the results of the first MATCH. So the result should be only one  vertex
   " {"id": 844424930131969, "label": "Person", "properties": {"name": "bobby"}}::vertex".
   This is how it works in Neo4j as well, and the second MATCH does perform intersection in case of properties with AGE as well. As demonstrated here
   
   ```
   test=# SELECT * from cypher('test', $$
     CREATE ({name:'bobby', age:25}),
            (:Person {name:'bobby'}),
            (:Bobby {name:'bobby', age:25, cigar:2})
   $$) as (a agtype);
    a 
   ---
   (0 rows)
   
   test=# SELECT * from cypher('test', $$
         MATCH (u {name:'bobby'})
         MATCH (u {cigar:2})
         RETURN u
   $$) as (a agtype);
                                                        a                                                      
   ------------------------------------------------------------------------------------------------------------
    {"id": 1407374883553282, "label": "Bobby", "properties": {"age": 25, "name": "bobby", "cigar": 2}}::vertex
   (1 row)
   ```
   
   Another interesting result is this
   ```
   test=# SELECT * from cypher('test', $$
         MATCH (u:Bobby {name:'bobby'})
         MATCH (u:Person)
         RETURN u
   $$) as (a agtype);
                                                        a                                                      
   ------------------------------------------------------------------------------------------------------------
    {"id": 1407374883553281, "label": "Bobby", "properties": {"name": "bobby"}}::vertex
    {"id": 1407374883553282, "label": "Bobby", "properties": {"age": 25, "name": "bobby", "cigar": 2}}::vertex
   (2 rows)
   ```
   And this
   ```
   test=# SELECT * from cypher('test', $$
         MATCH (u:Bobby {name:'bobby'})
         MATCH (u:Person {age:25})
         RETURN u
   $$) as (a agtype);
                                                        a                                                      
   ------------------------------------------------------------------------------------------------------------
    {"id": 1407374883553282, "label": "Bobby", "properties": {"age": 25, "name": "bobby", "cigar": 2}}::vertex
   (1 row)
   ```
   
   It appears that AGE performs filtration based on the first MATCH clause, ignores the label (if any) of the second clause, only performs filtration based on the given properties and returns the result.
   
   It should instead give an error regarding support of multiple labels (as of now).
   


-- 
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] CapnSpek commented on issue #829: Reuse of variable with label constraint in concurrent MATCH clauses does not error out

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

   > `MATCH (u),(u:Person) RETURN u`
   > 
   > But this same query errors out in AGE saying `ERROR: multiple labels for variable 'u' are not supported`
   
   I'm not sure why, but this query does not give an error for me. I'm using AGE 1.3.0 and it gives this output.
   
   ```
   test=# SELECT * from cypher('test', $$
         MATCH (u)                                                                
         MATCH (u:Person)
         RETURN u
   $$) as (a agtype);
                                                        a                                                      
   ------------------------------------------------------------------------------------------------------------
    {"id": 281474976710657, "label": "", "properties": {"name": "bobby"}}::vertex
    {"id": 281474976710658, "label": "", "properties": {"age": 25, "name": "bobby"}}::vertex
    {"id": 1125899906842625, "label": "Person", "properties": {"name": "bobby"}}::vertex
    {"id": 1125899906842626, "label": "Person", "properties": {"name": "bobby"}}::vertex
    {"id": 1407374883553281, "label": "Bobby", "properties": {"name": "bobby"}}::vertex
    {"id": 1407374883553282, "label": "Bobby", "properties": {"age": 25, "name": "bobby", "cigar": 2}}::vertex
   (6 rows)
   ```
   


-- 
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] panosfol commented on issue #829: Reuse of variable with label constraint in concurrent MATCH clauses does not error out

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

   When you create the vertex with "properties" : {"name": "bobby"} and "Person" as a label, it creates a new label table for vertices and inserts that vertex in that table. Also it assigns an ID that is generated according to the label table ID. When you create another vertex and assign it a different label (in this case "Bobby") the same procedure happens but a different ID is assigned on the vertex because the table that the vertex will be inserted is the "Bobby" label table (that has a different ID).
   
   Since those 2 vertices have different ID's and exist in different tables the above query works as intented. Implementing multiple labels and actually fetching one vertex with multiple labels needs a complete refactor, but for now the way creating a vertex and assigning a label works, I wouldn't call it a bug. Tell me if I missed something


-- 
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] MuhammadTahaNaveed commented on issue #829: Reuse of variable with label constraint in concurrent MATCH clauses does not error out

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

   > Ideally, the second MATCH should work as an intersection over the results of the first MATCH. So the result should be only one vertex " {"id": 844424930131969, "label": "Person", "properties": {"name": "bobby"}}::vertex". This is how it works in Neo4j as well, and the second MATCH does perform intersection in case of properties with AGE as well. As demonstrated here
   > 
   > ```
   > test=# SELECT * from cypher('test', $$
   >   CREATE ({name:'bobby', age:25}),
   >          (:Person {name:'bobby'}),
   >          (:Bobby {name:'bobby', age:25, cigar:2})
   > $$) as (a agtype);
   >  a 
   > ---
   > (0 rows)
   > 
   > test=# SELECT * from cypher('test', $$
   >       MATCH (u {name:'bobby'})
   >       MATCH (u {cigar:2})
   >       RETURN u
   > $$) as (a agtype);
   >                                                      a                                                      
   > ------------------------------------------------------------------------------------------------------------
   >  {"id": 1407374883553282, "label": "Bobby", "properties": {"age": 25, "name": "bobby", "cigar": 2}}::vertex
   > (1 row)
   > ```
   > 
   > Another interesting result is this
   > 
   > ```
   > test=# SELECT * from cypher('test', $$
   >       MATCH (u:Bobby {name:'bobby'})
   >       MATCH (u:Person)
   >       RETURN u
   > $$) as (a agtype);
   >                                                      a                                                      
   > ------------------------------------------------------------------------------------------------------------
   >  {"id": 1407374883553281, "label": "Bobby", "properties": {"name": "bobby"}}::vertex
   >  {"id": 1407374883553282, "label": "Bobby", "properties": {"age": 25, "name": "bobby", "cigar": 2}}::vertex
   > (2 rows)
   > ```
   > 
   > And this
   > 
   > ```
   > test=# SELECT * from cypher('test', $$
   >       MATCH (u:Bobby {name:'bobby'})
   >       MATCH (u:Person {age:25})
   >       RETURN u
   > $$) as (a agtype);
   >                                                      a                                                      
   > ------------------------------------------------------------------------------------------------------------
   >  {"id": 1407374883553282, "label": "Bobby", "properties": {"age": 25, "name": "bobby", "cigar": 2}}::vertex
   > (1 row)
   > ```
   > 
   > It appears that AGE performs filtration based on the first MATCH clause, ignores the label (if any) of the second clause, only performs filtration based on the given properties and returns the result.
   > 
   > It should instead give an error regarding support of multiple labels (as of now).
   > 
   > Hence, yes, I would call it a bug.
   > 
   > Given that in case 2 labels are provided in 2 different MATCH clauses, it does not perform an intersection of the 2 MATCH clauses, instead completely ignores the label provided in the second MATCH clause.
   
   Thanks for your valuable response.
   
   In addition to your response, the below query also filters out results in neo4j
   
   `MATCH (u),(u:Person) RETURN u`
   
   But this same query errors out in AGE saying `ERROR:  multiple labels for variable 'u' are not supported`
   
   So the query
   `MATCH (u) MATCH (u:Person) RETURN` should also error out the same until it is supported.
   
   
   
   


-- 
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 #829: Reuse of variable with label constraint in concurrent MATCH clauses does not error out

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

   When I did the work for variable reuse I only did it for the properties. I should have also considered the labels, but didn't. I would imagine that the same code could be expanded to cover this.


-- 
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