URL: http://<db.host>:<db.port>/update/records
Runs multiple predicate-based updates in a single call. With the list of given expressions, any matching record's column values will be updated as provided in input parameter new_values_maps. There is also an optional 'upsert' capability where if a particular predicate doesn't match any existing record, then a new record can be inserted.
Note that this operation can only be run on an original table and not on a result view.
This operation can update primary key values. By default only 'pure primary key' predicates are allowed when updating primary key values. If the primary key for a table is the column 'attr1', then the operation will only accept predicates of the form: "attr1 == 'foo'" if the attr1 column is being updated. For a composite primary key (e.g. columns 'attr1' and 'attr2') then this operation will only accept predicates of the form: "(attr1 == 'foo') and (attr2 == 'bar')". Meaning, all primary key columns must appear in an equality predicate in the expressions. Furthermore each 'pure primary key' predicate must be unique within a given request. These restrictions can be removed by utilizing some available options through input parameter options.
The update_on_existing_pk option specifies the record primary key collision policy for tables with a primary key, while ignore_existing_pk specifies the record primary key collision error-suppression policy when those collisions result in the update being rejected. Both are ignored on tables with no primary key.
Input Parameter Description
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
table_name | string | Name of table to be updated, in [schema_name.]table_name format, using standard name resolution rules. Must be a currently existing table and not a view. | ||||||||||||||||||||||||||||||
expressions | array of strings | A list of the actual predicates, one for each update; format should follow the guidelines here. | ||||||||||||||||||||||||||||||
new_values_maps | array of maps of string to strings and/or nulls | List of new values for the matching records. Each element is a map with (key, value) pairs where the keys are the names of the columns whose values are to be updated; the values are the new values. The number of elements in the list should match the length of input parameter expressions. | ||||||||||||||||||||||||||||||
records_to_insert | array of bytes | An optional list of new binary-avro encoded records to insert, one for each update. If one of input parameter expressions does not yield a matching record to be updated, then the corresponding element from this list will be added to the table. The default value is an empty array ( [] ). | ||||||||||||||||||||||||||||||
records_to_insert_str | array of strings | An optional list of JSON encoded objects to insert, one for each update, to be added if the particular update did not match any objects. The default value is an empty array ( [] ). | ||||||||||||||||||||||||||||||
record_encoding | string | Identifies which of input parameter records_to_insert and input parameter records_to_insert_str should be used. The default value is binary. The supported values are:
| ||||||||||||||||||||||||||||||
options | map of string to strings | Optional parameters. The default value is an empty map ( {} ).
|
Output Parameter Description
The GPUdb server embeds the endpoint response inside a standard response structure which contains status information and the actual response to the query. Here is a description of the various fields of the wrapper:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
status | String | 'OK' or 'ERROR' | ||||||||||||||||||
message | String | Empty if success or an error message | ||||||||||||||||||
data_type | String | 'update_records_response' or 'none' in case of an error | ||||||||||||||||||
data | String | Empty string | ||||||||||||||||||
data_str | JSON or String | This embedded JSON represents the result of the /update/records endpoint:
Empty string in case of an error. |