Remote service input and output data formats
When Spark communicates with a remote service - sending or receiving data - it's crucial to adhere to the proper data formats to ensure the external code is executed and returned successfully. When developing the remote service, it is important to conform to the input and output data requirements. The design of the input and output formats aligns with the definitions in the aligns with Execute API (v4) "JSON array" Execute API (v4).
If you are using a Proxy service to intermediate the XConnector, it would need to be able to reformat the inputs and outputs to conform to the requirements of the Introduction to XConnector and Introduction to XConnector.
After reading this section, you should be able to understand the data formats that the Introduction to XConnector must follow to accept and return requests.
Request format from Spark XConnector to Remote service

This section describes the format of the HTTP request that is being sent from the Introduction to XConnector to the Proxy service and Introduction to XConnector. This is important because the Introduction to XConnector needs to be able to consume the input data to process the result of the code execution. The HTTP request from Spark takes the form of a POST request containing headers and a request body.
Request headers
The header information typically appears to the remote service as a collection of key value pairs. Usually the HTTP request header will incorporate Authorization key with a Bearer token.
Request body
The top-level is a JSON object, presenting a set of name/value pairs (also termed a "dictionary"). There is a JSON array called inputs that is used to denote all the input records to pass to the Introduction to XConnector.
The JSON should follow the format prescribed in Execute API (v4) Execute API (v4), however note that for XConnector, only the JSON array format is supported.
Data type serialization is described in Execute API (v3) request_data.
Example 1: Single value inputs
Within
inputs, the first record[ "key1", "key2" ]defines the string keys.Subsequent arrays are used to define the values for the subsequent input records.
gP9iRaleAcio-MHpRkbvLxbZY
Example 2: Tables of inputs
Within
inputs, the first record[ "Table" ]defines the string keys.Subsequent arrays are used to define the values for the subsequent input records.
zuxt33WEgjC8-MHpRkbvLxbZY
Example 3: Multiple records of single values and tables
Response format from the Remote service to Spark XConnector

This section describes the format of the HTTP response that is returned from the Introduction to XConnector to the Introduction to XConnector. This is important because the Introduction to XConnector needs to be able to return the appropriate data as the result of the code execution. The HTTP response from the Introduction to XConnector should take the form of a POST request containing headers and a request body.
Response body
This is very similar to the format described for the Request body.
The top-level is a JSON object, presenting a set of name/value pairs (also termed a "dictionary"). There is a JSON array called outputs that is used to denote all the output records to pass back to the Introduction to XConnector.
The JSON should follow the format prescribed in Execute API (v4) Execute API (v4), however note that for XConnector, only the JSON array format is supported.
Data type serialization is described in Execute API (v3) request_data.
The response body from the remote service encapsulates the serialized data, adhering to the following JSON structure:
Outputs
outputs is a JSON array, where each element is a JSON array that represents one record of the response data. Outputs should follow the same structure denoted above for the Request body.
The first record defines the string keys.
Subsequent arrays can be returned corresponding to the processing of multiple records.
Warnings
Warning messages can be returned from the Introduction to XConnector. It should be constructed with a JSON array containing a JSON array for every record of data with a warning. If a record does not have any warnings, return null.
Errors
Errors should be returned in a similar way to Warnings.
Process time
The process time is used to return he amount of calculation time needed for each row of data in milliseconds. We would recommend every successful execution to elapse at least 1 millisecond.
Example 1: Successful response
Example 2: Response with warning
Example 3: Unsuccessful response
Last updated
