/append/records

URL: http://<db.host>:<db.port>/append/records

Append (or insert) all records from a source table (specified by input parameter source_table_name) to a particular target table (specified by input parameter table_name). The field map (specified by input parameter field_map) holds the user specified map of target table column names with their mapped source column names.

Input Parameter Description

NameTypeDescription
table_namestringThe table name for the records to be appended, in [schema_name.]table_name format, using standard name resolution rules. Must be an existing table.
source_table_namestringThe source table name to get records from, in [schema_name.]table_name format, using standard name resolution rules. Must be an existing table name.
field_mapmap of string to stringsContains the mapping of column names from the target table (specified by input parameter table_name) as the keys, and corresponding column names or expressions (e.g., 'col_name+1') from the source table (specified by input parameter source_table_name). Must be existing column names in source table and target table, and their types must be matched. For details on using expressions, see Expressions.
optionsmap of string to strings

Optional parameters. The default value is an empty map ( {} ).

Supported Parameters (keys)Parameter Description
offsetA positive integer indicating the number of initial results to skip from input parameter source_table_name. Default is 0. The minimum allowed value is 0. The maximum allowed value is MAX_INT. The default value is '0'.
limitA positive integer indicating the maximum number of results to be returned from input parameter source_table_name. Or END_OF_SET (-9999) to indicate that the max number of results should be returned. The default value is '-9999'.
expressionOptional filter expression to apply to the input parameter source_table_name. The default value is ''.
order_byComma-separated list of the columns to be sorted by from source table (specified by input parameter source_table_name), e.g., 'timestamp asc, x desc'. The order_by columns do not have to be present in input parameter field_map. The default value is ''.
update_on_existing_pk

Specifies the record collision policy for inserting source table records (specified by input parameter source_table_name) into a target table (specified by input parameter table_name) with a primary key. If set to true, any existing table record with primary key values that match those of a source table record being inserted will be replaced by that new record (the new data will be "upserted"). If set to false, any existing table record with primary key values that match those of a source table record being inserted will remain unchanged, while the source record will be rejected and an error handled as determined by ignore_existing_pk. If the specified table does not have a primary key, then this option has no effect. The default value is false.

Supported ValuesDescription
trueUpsert new records when primary keys match existing records
falseReject new records when primary keys match existing records
ignore_existing_pk

Specifies the record collision error-suppression policy for inserting source table records (specified by input parameter source_table_name) into a target table (specified by input parameter table_name) with a primary key, only used when not in upsert mode (upsert mode is disabled when update_on_existing_pk is false). If set to true, any source table record being inserted that is rejected for having primary key values that match those of an existing target table record will be ignored with no error generated. If false, the rejection of any source table record for having primary key values matching an existing target table record will result in an error being raised. If the specified table does not have a primary key or if upsert mode is in effect (update_on_existing_pk is true), then this option has no effect. The default value is false.

Supported ValuesDescription
trueIgnore source table records whose primary key values collide with those of target table records
falseRaise an error for any source table record whose primary key values collide with those of a target table record
truncate_strings

If set to true, it allows inserting longer strings into smaller charN string columns by truncating the longer strings to fit. The default value is false. The supported values are:

  • true
  • false

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:

NameTypeDescription
statusString'OK' or 'ERROR'
messageStringEmpty if success or an error message
data_typeString'append_records_response' or 'none' in case of an error
dataStringEmpty string
data_strJSON or String

This embedded JSON represents the result of the /append/records endpoint:

NameTypeDescription
table_namestring 
infomap of string to stringsAdditional information. The default value is an empty map ( {} ).

Empty string in case of an error.