vesoft-inc / nebula-graph

A distributed, fast open-source graph database featuring horizontal scalability and high availability. This is an archived repo for v2.5 only, from 2.6.0 +, NebulaGraph switched back to https://github.com/vesoft-inc/nebula

Home Page:https://nebula-graph.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The property order of the returned results has changed

cooper-lzy opened this issue · comments

In the schema, name comes first and age comes second, but the order in the returned result is wrong.

image

I checked opencypher specification and tck tests. And I also googled. Very few about this behavior.

# a tck case about add property
  Scenario: Overwrite values when using +=
    Given an empty graph
    And having executed:
      """
      CREATE (:X {name: 'A', name2: 'B'})
      """
    When executing query:
      """
      MATCH (n:X {name: 'A'})
      SET n += {name2: 'C'}
      RETURN n
      """
    Then the result should be, in any order:
      | n                             |
      | (:X {name: 'A', name2: 'C'}) |
    And the side effects should be:
      | +properties | 1 |
      | -properties | 1 |
  Scenario: `properties()` on a node
    Given an empty graph
    And having executed:
      """
      CREATE (n:Person {name: 'Popeye', level: 9001})
      """
    When executing query:
      """
      MATCH (p:Person)
      RETURN properties(p) AS m
      """
    Then the result should be, in any order:
      | m                             |
      | {name: 'Popeye', level: 9001} |
    And no side effects

name/level are not ordered in the alphabet, and {} is a map.

My suggestion is to clarify that: Properties have no guaranteed order in the doc.

commented

Thanks for taking care of this. The opencypher do not specify such a behavior, and i think there would not be one of such a specification. As said by @whitewum , we implement the map by an unordered map, the order would not be guaranteed. As far as i know, this is not a big problem for using. So i'll close this issue first unless we really meet any using problems in real world.