Skip to content

REST Implementation Non-Standard Operation - MergeInsertIntoTable

REST Route Definition

  /v1/table/{id}/merge_insert:
    parameters:
      - $ref: '#/components/parameters/id'
      - $ref: '#/components/parameters/delimiter'
      - name: "on"
        in: query
        description: Column name to use for matching rows (required)
        required: true
        schema:
          type: string
      - name: "when_matched_update_all"
        in: query
        description: Update all columns when rows match
        required: false
        schema:
          type: boolean
          default: false
      - name: "when_matched_update_all_filt"
        in: query
        description: The row is updated (similar to UpdateAll) only for rows where the SQL expression evaluates to true
        required: false
        schema:
          type: string
      - name: "when_not_matched_insert_all"
        in: query
        description: Insert all columns when rows don't match
        required: false
        schema:
          type: boolean
          default: false
      - name: "when_not_matched_by_source_delete"
        in: query
        description: Delete all rows from target table that don't match a row in the source table
        required: false
        schema:
          type: boolean
          default: false
      - name: "when_not_matched_by_source_delete_filt"
        in: query
        description: Delete rows from the target table if there is no match AND the SQL expression evaluates to true
        schema:
          type: string
    post:
      tags:
        - Table
        - Data
      summary: Merge insert (upsert) records into a table
      operationId: MergeInsertIntoTable
      description: |
        Performs a merge insert (upsert) operation on table `id`.
        This operation updates existing rows
        based on a matching column and inserts new rows that don't match.
        It returns the number of rows inserted and updated.

        REST NAMESPACE ONLY
        REST namespace uses Arrow IPC stream as the request body.
        It passes in the `MergeInsertIntoTableRequest` information in the following way:
        - `id`: pass through path parameter of the same name
        - `on`: pass through query parameter of the same name
        - `when_matched_update_all`: pass through query parameter of the same name
        - `when_matched_update_all_filt`: pass through query parameter of the same name
        - `when_not_matched_insert_all`: pass through query parameter of the same name
        - `when_not_matched_by_source_delete`: pass through query parameter of the same name
        - `when_not_matched_by_source_delete_filt`: pass through query parameter of the same name
      requestBody:
        description: Arrow IPC stream containing the records to merge
        content:
          application/vnd.apache.arrow.stream:
            schema:
              type: string
              format: binary
        required: true
      responses:
        200:
          $ref: '#/components/responses/MergeInsertIntoTableResponse'
        400:
          $ref: '#/components/responses/BadRequestErrorResponse'
        401:
          $ref: '#/components/responses/UnauthorizedErrorResponse'
        403:
          $ref: '#/components/responses/ForbiddenErrorResponse'
        404:
          $ref: '#/components/responses/NotFoundErrorResponse'
        503:
          $ref: '#/components/responses/ServiceUnavailableErrorResponse'
        5XX:
          $ref: '#/components/responses/ServerErrorResponse'