Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Jira
    serverJira Cloud
    columnIdsissuekey,summary,issuetype,created,updated,duedate,assignee,reporter,priority,status,resolution
    columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
    serverId6dd774b6-00ac-3344-8265-fe491188c468
    keyDM-42617
  • Jira
    serverJira Cloud
    serverId6dd774b6-00ac-3344-8265-fe491188c468
    keyDM-43465
  • Jira
    serverJira Cloud
    serverId6dd774b6-00ac-3344-8265-fe491188c468
    keyDM-43497

The frontend complements the existing one based on  mysql-proxy.

...

Note

The API adheres to the optional version control mechanism introduced in:

Jira
serverJIRA
serverId9da94fb6-5771-303d-a785-1b6c5ab0f2d2
keyDM-35456

Application developers are encouraged to use the mechanism to reinforce the integrity of the applications. The document corresponds to version number 32 33 of the API.

Each implementation of the API has a specific version. The version number will change if any changes to the implementation or the API that might affect users will be made. The current document will be also kept updated to reflect the latest available version of the API.

...

Code Block
languagejson
themeDJango
{"kind":"qserv-czar-query-frontend",
 "name":"http",
 "id":8,
 "instance_id":"qserv-prod",
 "version":3233,
 "success":1,
 ...
}

Push mode

...

Code Block
languagebash
themeFadeToGrey
curl 'http://localhost:4041/query-async/status/1234?version=3233' -X GET

For other HTTP methods used by the API, the number is required to be provided within the body of a request as shown below:

Code Block
languagebash
themeFadeToGrey
curl 'http://localhost:4041/query-async' -X POST -H 'Content-Type: application/json' -d'{"version":3233,"query":"SELECT ..."}'

If the number does not match expectations, such a request will fail and the service return the following response. Here is an example of what will happen if the wrong version number 29 is specified instead of 32 33  (as per the current version of the API):

Code Block
languagejson
themeDJango
{"success":0,
 "error":"The requested version 29 of the API is not in the range supported by the service.",
 "error_ext":{
  "max_version":32,
  "min_version":32
 },
 "warning":""
}

Submitting queries

Anchor
SYNC_SUBMIT
SYNC_SUBMIT
Synchronous interface

The following REST service implements the synchronous interface:

...

A client is required to pass the JSON  object in the request body of the request to specify what query needs to be executed. The object has the following schema:

Code Block
languagejson
themeDJango
{"query":<string>,
 "database":<string>,
 "binary_encoding":<string>
}

Where:

attrdescriptiondefault
query
The query text in which the default database may be missing. In the latter case, a client
would need
needs to provide the name in a separate parameter. 
database
The optional name of the default database for queries where no such name was provided explicitly.""

A call to this service will block a client application until one of the following events will happen:

  • The query will be successfully processed and its result returned to a caller.
  • The query will fail and the corresponding error will be returned to the caller.
  • The frontend will become unavailable (due to a crash, restart, or networking problem, etc.) and a network connection will be lost.

In case of the successful completion of the request, the service will return a result set in the JSON object explained in the section Result sets.

Asynchronous interface

The following REST service implements the asynchronous interface:

...

A client is required to pass the JSON  object in the body of the request to specify what query needs to be executed. The object has the following schema:

Code Block
languagejson
themeDJango
{"query":<string>,
 "database":<string>
}

Where:

...

query

...

binary_encoding

The optional format for encoding the binary data into JSON, where the following options for the values of the parameter are allowed:

  • hex - for serializing each byte into the hexadecimal format of 2 ASCII characters per each byte of the binary data, where the encoded characters will be in a range of ‘0' .. ‘F’ . In this case, the encoded value will be packaged into the JSON string.

  • array - for serializing bytes into the JSON array of numbers in a range of 0 … 255.

The missing parameter will be treated as if the hexadecimal encoding was requested.

Here is an example of the same sequence of 4-bytes encoded into the hexadecimal format:

"0A11FFD2"

The array representation of the same binary sequence would look like this:

[10,17,255,210]

"hex"

A call to this service will block a client application until one of the following events will happen:

  • The query will be successfully processed and its result is returned to a caller.
  • The query will fail and the corresponding error will be returned to the caller.
  • The frontend will become unavailable (due to a crash, restart, or networking problem, etc.) and a network connection will be lost.

In case of the successful completion of the request, the service will return a result set in the JSON object explained in the section Result sets.

Asynchronous interface

The following REST service implements the asynchronous interface:

methodresource name
POST/query-async

A client is required to pass the JSON  object in the request body to specify what query needs to be executed. The object has the following schema:

Code Block
languagejson
themeDJango
{"query":<string>,
 "database":<string>
}

Where:

attrdescriptiondefault
query
The query text in which the default database may be missing. In the latter case, a client needs to provide the name in a separate parameter. 
database
The optional name of the default database for queries where no such name was provided explicitly.""

A call to this service will normally block a client application for a short period until one of the following events will happen:

  • The query will be successfully analyzed and queued for asynchronous processing by Qserv and a response object with the unique identifier of the query returned to a caller.
  • The query will fail and the corresponding error will be returned to the caller.
  • The frontend will become unavailable (due to a crash, restart, or networking problem, etc.) and a network connection will be lost.

In case of the successful completion of the request, the service will return the following JSON object:

Code Block
languagejson
themeDJango
{"queryId":<number>}

The number reported in the object should be further used for making the following requests explained in the dedicated subsections below:

  • checking the status of the query to see when it's finished
  • requesting a result set of the query
  • or, canceling the query if needed

Checking the status of the ongoing query

(warning) This service can be also used for checking the status of queries submitted via the synchronous interface, provided the unique identifier of such query is known to a

...

database

...

A call to this service will normally block a client application for a short period until one of the following events will happen:

  • The query will be successfully analyzed and queued for asynchronous processing by Qserv and a response object with the unique identifier of the query returned to a caller.
  • The query will fail and the corresponding error will be returned to the caller.
  • The frontend will become unavailable (due to a crash, restart, or networking problem, etc.) and a network connection will be lost.

In case of the successful completion of the request, the service will return the following JSON object:

Code Block
languagejson
themeDJango
{"queryId":<number>}

The number reported in the object should be further used for making the following requests explained in the dedicated subsections below:

  • checking the status of the query to see when it's finished
  • requesting a result set of the query
  • or, canceling the query if needed

Checking the status of the ongoing query

(warning) This service can be also used for checking the status of queries submitted via the synchronous interface, provided the unique identifier of such query is known to a user.

The status of the query can be checked using:

...

Code Block
languagejson
themeDJango
{"success":1,
 "status":{
   "queryId":310554,
   "status":"EXECUTING",
   "totalChunks":1477,
   "completedChunks":112,
   "queryBeginEpoch":1708141345,
   "lastUpdateEpoch":1708141359
  }
}

The status service could be used by users to make rough estimates of Users could use the status service to estimate when the query will finish. However, normallyNormally, the client applications are encouraged to wait before the query reaches the status "COMPLETED" and fetch a result set by calling another service explained next.

Anchor
ASYNC_RESULT
ASYNC_RESULT
Requesting result sets

The result sets resultsets could be retrieved by calling the following service:

methodresource name
GET/query-async/result/<queryId>[?binary_encoding=<encoding>] 

Where:

attrtypedescriptiondefault
queryId
number

The unique identifier of the previously submitted query.

Like in the case of the status inquiry request, if the identifier of the query is not valid then the service will report an error in the response object. Otherwise, a JSON object explained in the section Result sets will be returned.

...


encoding
string

The optional format for encoding the binary data into JSON, where the following options for the values of the parameter are allowed:

  • hex - for serializing each byte into the hexadecimal format of 2 ASCII characters per each byte of the binary data, where the encoded characters will be in a range of ‘0' .. ‘F’ . In this case, the encoded value will be packaged into the JSON string.

  • array - for serializing bytes into the JSON array of numbers in a range of 0 … 255.

The missing parameter will be treated as if the hexadecimal encoding was requested.

Here is an example of the same sequence of 4-bytes encoded into the hexadecimal format:

"0A11FFD2"

The array representation of the same binary sequence would look like this:

[10,17,255,210]

"hex"

Like in the case of the status inquiry request, if the query identifier is not valid then the service will report an error in the response object. Otherwise, a JSON object explained in the section Result sets will be returned.

Anchor
RESULT_SET
RESULT_SET
Result sets

Both flavors of the query submission services will return the following JSON object in case of the successful completion of the queries:

Code Block
languagejson
themeDJango
{"schema":[
  [{"table":<string>, "column":<string>, "type":<string>, "is_binary":<number>],   // Col 0
  

Both flavors of the query submission services will return the following JSON object in case of the successful completion of the queries:

Code Block
languagejson
themeDJango
{"schema":[
  [{"table":<string>, "column":<string>, "type":<string>],   // Col 0
  [{"table":<string>, "column":<string>, "type":<string>],   // Col 1
  ...
  [{"table":<string>, "column":<string>, "type":<string>, "is_binary":<number>],   // Col (NUM_COLUMNS - 1)
 ],
 "rows":[
   // Col 1
  ...
  [{"table":<string>, "column":<string>, "type":<string>, "is_binary":<number>],   // Col (NUM_COLUMNS - 1)
 ],
 "rows":[
   // Col 0   Col 1         Col (NUM_COLUMNS - 1)
   // ------  --------      --------
   [<string>, <string>, ... <string>],                       // Result row 0
   [<string>, <string>, ... <string>],                       // Result row 1
   ...
   [<string>, <string>, ... <string>],                       // Result row (NUM_ROWS - 1)
  ],
 ...
}

Where:

],
 ...
}

Where:

attrtypedescription
schema
array

A collection of rows, in which each row is a dictionary representing a definition of the corresponding column of the result set:

attrtypedescription
table
string

The name of the result table. The string will be empty in the current version of the frontend.

column
string

The name of a column.

type
string

The MySQL type of the column as in the MySQL CREATE TABLE ... statement.

is_binary
number

The numeric flag indicates if the column type represents the binary type. The MySQL binary types are listed below:

A value that is not 0  indicates the binary type.

(warning) Binary values need to be processed according to a format specified in the optional attribute "binary_encoding" mentioned in the descriptions of the query submission and result retrieval services:

attrtypedescription
schema
array

A collection of rows, in which each row is a dictionary representing a definition of the corresponding column of the result set:

attrtypedescription
table
string

The name of the result table. The string will be empty in the current version of the frontend.

column
string

The name of a column.

type
string
The MySQL type of the column as in the MySQL CREATE TABLE ... statement.

(warning) The number of columns will match the number of columns in the collection of result rows.

rows
array

A collection of the result rows, where each row is a row of strings representing values at positions of the corresponding columns (see schema attribute above).

...

Canceling queries

(warning) This service can be also used for terminating queries submitted via the synchronous interface, provided the unique identifier of such query is known to a user.

...