HTTP
HTTP table-valued-function (TVF) allows users to read data returned from any HTTP endpoint as if accessing relational table format data. As long as the returned data is in a supported format, it can be queried and analyzed directly via SQL. Currently supports csv/csv_with_names/csv_with_names_and_types/json/parquet/orc data formats.
Typical use cases include:
- Querying data files hosted on HTTP/HTTPS (e.g., GitHub, S3, etc.).
- Directly querying HTTP API endpoints that return JSON-formatted data.
- Accessing datasets hosted on Hugging Face.
Note:
This function is available in Core 26.1.3.
Syntax
HTTP(
"uri" = "<uri>",
"format" = "<format>"
[, "<optional_property_key>" = "<optional_property_value>" [, ...] ]
)
Required parameters
| Parameter | Description |
|---|---|
| uri | The HTTP address to access. Supports http, https, and hf protocols. Can be a URL to a data file or an API endpoint that returns data. |
| format | Data format, i.e., how the content returned by the HTTP endpoint is parsed. Supports csv/csv_with_names/csv_with_names_and_types/json/parquet/orc. |
For hf:// (Hugging Face), please refer to Analyzing Hugging Face Data.
Optional parameters
| Parameter | Description | Notes |
|---|---|---|
http.header.xxx | Used to specify arbitrary HTTP Headers, which are passed directly to the HTTP Client. | e.g., "http.header.Authorization" = "Bearer <access-token>", the resulting Header will be Authorization: Bearer <access-token> |
http.enable.range.request | Whether to use range requests to access the HTTP service. Default is true. | |
http.max.request.size.bytes | Maximum access size limit when using non-range request mode. The compiled default is 100 MiB (104,857,600 bytes). |
For a server that does not support HTTP Range requests, set http.enable.range.request to false explicitly and size http.max.request.size.bytes for the response. Non-Range reads can buffer the full response and increase query memory usage. The compiled size limit is 100 MiB (104,857,600 bytes).
Examples
Read data files over HTTP
-
Read CSV data from GitHub
SELECT COUNT(*) FROMHTTP("uri" = "https://raw.githubusercontent.com/apache/doris/refs/heads/master/regression-test/data/load_p0/http_stream/all_types.csv","format" = "csv","column_separator" = ","); -
Read Parquet data from GitHub
SELECT arr_map, id FROMHTTP("uri" = "https://raw.githubusercontent.com/apache/doris/refs/heads/master/regression-test/data/external_table_p0/tvf/t.parquet","format" = "parquet"); -
Read JSON data from GitHub and use
DESC FUNCTIONto view the schemaDESC FUNCTIONHTTP("uri" = "https://raw.githubusercontent.com/apache/doris/refs/heads/master/regression-test/data/load_p0/stream_load/basic_data.json","format" = "json","strip_outer_array" = "true");
Query HTTP API endpoints
You can use the HTTP table function to directly query HTTP API endpoints that return JSON-formatted data. For example, querying a REST API that returns JSON data:
SELECT * FROM
HTTP(
"uri" = "https://api.example.com/v1/data",
"format" = "json",
"http.header.Authorization" = "Bearer <access-token>",
"strip_outer_array" = "true"
);
Tip:
For an HTTP API endpoint without Range support, set
http.enable.range.requesttofalseand configure the response-size limit before querying.