1. HBase
  2. HBASE-2475

[stargate] Required ordering of JSON name/value pairs when performing Insert/Update


    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None


      From Tyler Coffin up on hbase-user@

      I am using the Stargate REST interface to HBase for inserting data. When using JSON to transmit the query content, I have found that specific ordering of key/value pairs within the JSON string is required in order for the query to succeed (otherwise a response of 'HTTP/1.1 500 Row key is invalid' error is thrown if "key" and "Cell" are reversed).

      This string receives the above error:


      This is the valid equivalent string:


      As you can see the only difference between these two instances is that the "key" and "Cell" name/value pairs have their order reversed.

      In the equivalent XML notation, the ordering is specifically required per the schema. However with JSON Objects (i.e. name/value pairs) order is not required (JSON Arrays are ordered, but not Objects). Some JSON libraries will preserve ordering of Objects but not all which is how I discovered this problem in the first place because I was using the Perl JSON library which does not guarantee order).
      I'm unsure if this is a bug in the REST implementation or an inconvenient ambiguity in the JSON specification. Regardless I thought I'd share this discovery with the community for feedback (or at the very least to document this for users' future reference).

      For reference this is the table schema for the above query:

      {NAME => 'reftrack', FAMILIES => [{NAME => 'message', COMPRESSION =>
      'NONE', VERSIONS => '1', TTL => '2147483647', BLOCKSIZE => '65536',
      IN_MEMORY => 'false', BLOCKCACHE => 'true'}]}
      1. HBASE-2475.patch
        7 kB
        Andrew Purtell

        Issue Links


          Andrew Purtell created issue -
          stack made changes -
          Field Original Value New Value
          Fix Version/s 0.20.5 [ 12314800 ]
          Labels moved_from_0_20_5
          Andrew Purtell made changes -
          Link This issue is part of HBASE-2567 [ HBASE-2567 ]
          Andrew Purtell made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 0.20.5 [ 12314800 ]
          Resolution Fixed [ 1 ]
          Andrew Purtell made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Andrew Purtell made changes -
          Attachment HBASE-2475.patch [ 12530709 ]
          Andrew Purtell made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Assignee Andrew Purtell [ apurtell ]
          Fix Version/s 0.90.0 [ 12313607 ]
          Fix Version/s 0.20.5 [ 12314800 ]
          Resolution Fixed [ 1 ]


            • Assignee:
              Andrew Purtell
            • Votes:
              0 Vote for this issue
              3 Start watching this issue


              • Created: