1

In regards to orderability between different agtypes: - https://age.apache.org/age-manual/master/intro/comparability.html

I was testing the orderability between path and an edge, and I found this odd behavior: -

Comparing a path with an edge with p > e inequality: -

test=# SELECT *
FROM cypher('test', $$
        WITH [{id: 0, label: "label_name_1", properties: {i: 0}}::vertex,
            {id: 2, start_id: 0, end_id: 1, label: "edge_label", properties: {i: 0}}::edge,
           {id: 1, label: "label_name_2", properties: {}}::vertex
           ]::path as p
MATCH (n)-[e]-(m) RETURN p>e
$$) AS (e agtype);
  e   
------
 true
 true
 true
 true
(4 rows)

Fair enough, same result holds when we compare it with p < e inequality

test=# SELECT *
FROM cypher('test', $$
        WITH [{id: 0, label: "label_name_1", properties: {i: 0}}::vertex,
            {id: 2, start_id: 0, end_id: 1, label: "edge_label", properties: {i: 0}}::edge,
           {id: 1, label: "label_name_2", properties: {}}::vertex
           ]::path as p
MATCH (n)-[e]-(m) RETURN p<e
$$) AS (e agtype);
   e   
-------
 false
 false
 false
 false
(4 rows)

But look, when we change the inequality to e > p

test=# SELECT *
FROM cypher('test', $$
        WITH [{id: 0, label: "label_name_1", properties: {i: 0}}::vertex,
            {id: 2, start_id: 0, end_id: 1, label: "edge_label", properties: {i: 0}}::edge,
           {id: 1, label: "label_name_2", properties: {}}::vertex
           ]::path as p
MATCH (n)-[e]-(m) RETURN e>p
$$) AS (e agtype);
  e   
------
 true
 true
 true
 true
(4 rows)

We get true again, which is in direct contradiction to p > e inequality

And when we check for e < p, we get false again

test=# SELECT *
FROM cypher('test', $$
        WITH [{id: 0, label: "label_name_1", properties: {i: 0}}::vertex,
            {id: 2, start_id: 0, end_id: 1, label: "edge_label", properties: {i: 0}}::edge,
           {id: 1, label: "label_name_2", properties: {}}::vertex
           ]::path as p
MATCH (n)-[e]-(m) RETURN e<p
$$) AS (e agtype);
   e   
-------
 false
 false
 false
 false
(4 rows)

Again, in direct contradiction to the first 2 results.

It seems that in the case of edge and path, irrespective of which is which '>' inequality yields true, while '<' inequality yields false.

Is this the intended behavior or a bug? And if this is the intended behavior then why?

  • The documentation referenced in the original post shows that edge is both less than and greater than path with regards to orderability and also includes a note stating that the behavior is subject to change in future releases. That documentation, along with the empirical observations, implies that one should not rely upon orderability between edge and path objects. – JohnH Apr 28 '23 at 21:15
  • In that case it should have been true for vertex as well since vertex lies in between the 2 mentions of edge as well. However, when tested, it becomes obvious that vertex > edge under every scenario. I had asked about the ambiguous position of edge earlier here https://stackoverflow.com/questions/75845310/clarification-regarding-apache-age-documentation-orderability-between-different , to which everyone seemed to agree that the 2 mentions of edge is a typo in the documentation. I think it is a bug. – Bhaskar Sharma Apr 28 '23 at 21:22

2 Answers2

0

So far, it does appear to be unintended behavior, and hence, a bug indeed. It arises from lack of clear assignment of priority to both path and edge in the code.

I have created an issue for this behavior https://github.com/apache/age/issues/870

And have also suggested ways of correcting it there.

0

The documentation is ambiguous, and it has been flagged as an issue in the repository. For now, I suggest programming defensively to protect against bugs due to this behaviour.

tokamak32
  • 27
  • 7