Request message
Request line
-
Query data across databases in a specified catalog. If a table is used in the SQL query, you must prefix the table name with its database name.
-
Query data from a specified catalog and database.
Authentication method
credentials (-u '<username>:<password>'). If no password is set for the username, you can pass in only <username>: and leave the password empty. For example, if the root account is used, you can enter -u 'root:'.
A token issued by your identity provider is also accepted, if a JWT or OAuth 2.0 security integration is configured:
principal_field. For which credential each kind of user can send, see Where each authentication method works.
Request body
Request header
Response message
Status code
- 200: HTTP request succeeded and the server is normal before data is sent to the client.
- 4xx: HTTP request error, which indicates a client error.
500 Internal Server Error: HTTP request succeeded but the server encounters an error before data is sent to the client.- 503: HTTP request succeeded but the FE cannot provide service.
Response header
content-type indicates the format of the response body. Newline delimited JSON is used, which means the response body consists of multiple JSON objects that are separated by \n.
Response body
Failed before the request is sent
Request fails on the client side or the server encounters an error before it returns data to the client. The response body is in the following format, wheremsg is the error information.
Failed after the request is sent
Part of the result is returned and the HTTP status code is 200. Data sending is suspended, the connection is closed, and the error is logged.Succeeded
Each row in the response message is a JSON object. JSON objects separated by\n.
- For a SELECT statement, the following JSON objects are returned.
- For a SHOW statement,
meta,data, andstatisticsare returned. - For the EXPLAIN statement, an
explainobject is returned to show detailed execution plan of the query.
\n as the separator. The database transmits data using HTTP chunked mode. Each time the FE obtains a data chunk, it streams the data chunk to the client. The client can parse data by row, which eliminates the need for data caching and the need to wait for the entire data, reducing memory consumption for the client.
Examples
Run a SELECT query
-
Query data from a internal table (
catalog_nameisdefault_catalog).Result: -
Query data from an Iceberg table.
Result:
Cancel a query
To cancel a query that run an unexpected long time, you can close the connection. The database will cancel this query when it detects the connection is closed. You can also call KILLconnectionId to cancel this query. For example:
connectionId from the response body or by calling SHOW PROCESSLIST. For example: