PutRow

Last Updated: Oct 11, 2016

PutRow

Action:

Inserts data in the specified row. If this row does not exist, a new row is added. If the row exists, the original row is overwritten.

Request Message Structure:

  1. message PutRowRequest {
  2. required string table_name = 1;
  3. required Condition condition = 2;
  4. repeated Column primary_key = 3;
  5. repeated Column attribute_columns = 4;
  6. }

table_name:

  • Type: string

  • Required Parameter: Yes

  • The name of the table to write data to.

condition:

  • Type: Condition

  • Required Parameter: Yes

  • Determines whether or not to perform row existence check before writing data. There are three values:

    • IGNORE indicates that the row existence check is not performed.

    • EXPECT_EXIST indicates that the row is expected to exist.

    • EXPECT_NOT_EXIST indicates that the row is not expected to exist.

  • If the row is not expected to exist but it does, insertion will fail and an error will be returned. Vice versa.

primary_key:

  • Type: repeated Column

  • Required Parameter: Yes

  • All primary key columns for the row to be written.

attribute_columns:

  • Type: repeated Column

  • Required Parameter: No

  • The attributes of the row to be written. If attribute_columns is null, this indicates the row to be written does not have any attribute columns.

  • In attribute_columns, the number of columns cannot exceed 128.

Response Message Structure:

  1. message PutRowResponse {
  2. required ConsumedCapacity consumed = 1;
  3. }

consumed:

Capacity Unit Consumption:

  • If this row does not exist, the number of consumed write capacity units is the size of all data to be inserted divided by 1KB and rounded up. For information on data size calculation, please refer to Billing Explanation.

  • If this row exists, the number of consumed write capacity units is the sum of the size of all original row data and the size of modified row data respectively divided by 1KB and rounded up.

  • If an internal error code is returned (HTTP status code: 5XX), this operation will not consume capacity units. If other errors are returned, it will consume 1 write capacity unit.

  • If request timeout occurs and the results are undefined, a capacity unit may or may not be consumed.

Request Example:

  1. PutRowRequest {
  2. table_name: "consume_history"
  3. condition {
  4. row_existence: EXPECT_NOT_EXIST
  5. }
  6. primary_key {
  7. name: "CardID"
  8. value {
  9. type: STRING
  10. v_string: "2007035023"
  11. }
  12. }
  13. primary_key {
  14. name: "SellerID"
  15. value {
  16. type: STRING
  17. v_string: "00022"
  18. }
  19. }
  20. primary_key {
  21. name: "DeviceID"
  22. value {
  23. type: STRING
  24. v_string: "061104"
  25. }
  26. }
  27. primary_key {
  28. name: "OrderNumber"
  29. value {
  30. type: INTEGER
  31. v_int: 142857
  32. }
  33. }
  34. attribute_columns {
  35. name: "Amount"
  36. value {
  37. type: DOUBLE
  38. v_double: 2.5
  39. }
  40. }
  41. attribute_columns {
  42. name: "Remarks"
  43. value {
  44. type: STRING
  45. v_string: "ice cream"
  46. }
  47. }
  48. }

Response Example:

  1. PutRowResponse {
  2. consumed {
  3. capacity_unit {
  4. write: 1
  5. }
  6. }
  7. }
  8. ~~~~~~~~~~~~~~~~
Thank you! We've received your feedback.