HTTP SQL API
Description
StarRocks v3.2.0 introduces the HTTP SQL API for users to perform various types of queries using HTTP. Currently, this API supports SELECT, SHOW, EXPLAIN, and KILL statements.
Syntax using the curl command:
curl -X POST 'http://<fe_ip>:<fe_http_port>/api/v1/catalogs/<catalog_name>/databases/<database_name>/sql' \
-u '<username>:<password>' -d '{"query": "<sql_query>;", "sessionVariables":{"<var_name>":<var_value>}}' \
--header "Content-Type: application/json"
Request message
Request line
POST 'http://<fe_ip>:<fe_http_port>/api/v1/catalogs/<catalog_name>/databases/<database_name>/sql'
Field | Description |
---|---|
fe_ip | FE node IP address. |
fe_http_port | FE HTTP port. |
catalog_name | The catalog name. In v3.2.0, you can use this API to query only StarRocks internal tables, which means <catalog_name> can only be set to default_catalog . Since v3.2.1, you can use this API to query tables in external catalogs. |
database_name | The database name. If no database name is specified in the request line and a table name is used in the SQL query, you must prefix the table name with its database name, for example, database_name.table_name . |
-
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.
POST /api/v1/catalogs/<catalog_name>/sql
-
Query data from a specified catalog and database.
POST /api/v1/catalogs/<catalog_name>/databases/<database_name>/sql