API results, limits and errors#
The query API protects the client database with limits per user, per credential and per query, and answers each problem with a stable code. This page brings together the result formats, the limits with their configuration and the errors with their solution.
Before you start#
Read the walkthrough of the Query API. The limits are configured in ecenter.api.* (see the configuration reference) and almost all of them are per instance of the backend.
Result formats#
The format is chosen with the Accept header of GET /queries/{id}/rows:
Accept |
Response |
|---|---|
None, */* or application/json |
A page in JSON, with nextCursor for the next one |
text/csv |
The whole result in CSV |
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
The pivoted table in Excel |
application/vnd.apache.arrow.stream |
The whole result in Arrow |
| Another | 406 NOT_ACCEPTABLE, with the accepted ones in supported |
With several types in the header, the one with the highest quality (q) wins. The files carry Content-Disposition: attachment with the query's identifier.
JSON#
A page of the long form, of 1000 rows by default and up to 10,000 (limit=). nextCursor is opaque, only valid for that query and null on the last page. truncated is always false: above a cap, the API responds 422 instead of trimming.
CSV#
RFC 4180, UTF-8 without BOM, CRLF line endings, a header with the names, unformatted numbers with a decimal point and nulls empty. With delimiter=; it uses a semicolon, which is what Excel expects in Spanish. A text that begins with =, +, -, @, a tab or a carriage return carries an apostrophe in front, so that a spreadsheet does not take it for a formula; numbers are not touched.
Excel#
The pivoted table, as the cube viewer shows it: the rows dimensions in rows, the columns ones in columns, merged headers, shaded totals, frozen panes and the numbers with each metric's decimals. The first row carries the title (the query in one sentence) and the footer says what the holder does not see, counted and without names, and the date and time of the calculation. It is for people: programs have the long form.
A period comparison or a compound query has no pivoted table: its Excel is the long form in one sheet, with the same title and footer.
Arrow#
The whole long form in the Apache Arrow IPC stream format, to read it without converting types:
import pyarrow.ipc
tabla = pyarrow.ipc.open_stream(open("resultado.arrows", "rb").read()).read_all()
| Column type | Arrow type |
|---|---|
NUMBER |
float64; int64 in a code column with all values integer |
TEXT |
utf8 |
DATE |
date32 |
DATETIME |
timestamp[us] |
BOOLEAN |
bool |
IDS (TOTAL_OF) |
list<int64> |
Each field carries in its metadata the same as the JSON (ecenter:name, ecenter:role, ecenter:metric…). If two columns have the same name, the second carries “ (2)”.
How long a result lasts#
- A result is kept for 30 minutes from when it finishes (
expiresAt). Paging or downloading does not go back to the database. - At most 20 results per holder and 10,000,000 cells per instance are kept. When one of the caps is exceeded the oldest is discarded, which from then on responds
404 RESULT_NOT_FOUNDlike an expired one. - A query is only seen by the same credential that sent it: another credential of the same user, the application session or an administrator get
404 RESULT_NOT_FOUND. Having the identifier does not give access. - Revoking the credential, or disabling, locking or deleting the holder, cancels their queries in progress and forgets them.
Limits#
| Limit | Default | Property | Response |
|---|---|---|---|
| Queries in progress at once per holder | 2 | ecenter.api.max-running-per-user |
429 TOO_MANY_RUNNING with Retry-After |
| Requests per minute and credential | 60 | ecenter.api.rate |
429 RATE_LIMITED with Retry-After |
| Holder's jobs waiting in their queue | 100 | ecenter.jobs.max-queued-per-user |
429 TOO_MANY_RUNNING |
| Request wait | 10 s, at most 30 s | ecenter.api.wait, ecenter.api.max-wait |
202 with the identifier |
| Estimated rows from which it warns | 100,000 | ecenter.cube.warn-rows |
409 HEAVY_QUERY until repeated with confirmHeavy=true |
| Maximum estimated rows | 2,000,000 | ecenter.api.max-estimated-rows |
422 TOO_HEAVY, even when confirmed |
| Result rows | 50,000 | ecenter.api.max-rows |
422 TOO_HEAVY |
| Result cells | 2,000,000 | ecenter.api.max-cells |
422 TOO_HEAVY |
| Combinations the cube brings | 200,000 | ecenter.cube.max-rows |
422 TOO_HEAVY |
| Cells of the Excel pivoted table | 1,000,000 | ecenter.cube.max-export-cells |
422 TOO_HEAVY when requesting the Excel; the long form is still given |
| Time in the database | 5 min | ecenter.querying.timeout |
The query fails |
| Page size | 1000, at most 10,000 | ecenter.api.page-size, ecenter.api.max-page-size |
The CSV and the Arrow go whole |
API queries are jobs of their own class, which uses at most 2 sessions of each connection's pool (ecenter.jobs.max-concurrent.API), so that the API does not leave the application without sessions.
Note
The row estimate is requested inside the query's job: 409 HEAVY_QUERY with estimate.rows is the response of the send, if the estimate arrives within its wait, or of the follow-up (GET /queries/{id}). To calculate it anyway you have to repeat the send with confirmHeavy=true. An unattended program should not simply confirm: the prudent thing is to segment the query or notify a person.
Column security#
- The catalog only brings what the holder can see. What is not there does not exist for them.
- A query that names something hidden (a dimension of an axis or of a condition, a metric, a metric cited by a formula, a grouping of a hidden dimension) responds
403 COLUMNS_HIDDENwith the identifiers it sent, indimensionsandmetrics, and never with their names. The audit records it as a denied query. - An identifier that does not exist is not the same: it responds
400 INVALID_QUERYwithcandidates. - A starting document that uses something hidden is calculated without it and counts it in
hidden.
{
"type": "about:blank", "title": "Forbidden", "status": 403,
"detail": "La consulta usa 1 métrica a la que usted no tiene acceso",
"code": "COLUMNS_HIDDEN", "metrics": [1203], "dimensions": [], "segmentation": false
}
segmentation is true when what is hidden is in a segmentation condition.
Errors#
All errors are a ProblemDetail with code. The detail text is in Spanish and explains what to correct; programs should rely on code.
| HTTP | code |
When | What to do |
|---|---|---|---|
| 400 | INVALID_QUERY |
The query does not follow the cube rules or does not fit the metadata; with problems and, if an identifier does not exist, candidates. Also a malformed JSON. |
Correct what problems says. Validate before sending. |
| 401 | CREDENTIAL_REQUIRED |
The Authorization header is missing. |
Add it. |
| 401 | INVALID_CREDENTIAL |
The credential is not valid. | Check its status in Service credentials. |
| 403 | NOT_ALLOWED |
API and MCP access or Access to Empowerment Center is missing; the credential does not include the connection; a list the holder cannot use; the SQL without Metadata administration. | Review the holder's privileges or the credential's connections. |
| 403 | COLUMNS_HIDDEN |
The query uses something the holder does not see. | Remove it from the query. |
| 403 | LICENSE_INVALID |
No valid license. | Review the license. |
| 404 | CONNECTION_NOT_FOUND |
The connection does not exist or the holder cannot use it (it does not say which). | Use one from GET /connections. |
| 404 | RESULT_NOT_FOUND |
The result expired, was discarded, belongs to another credential or is on another instance. | Send the query again. With several instances, review the load balancer's affinity. |
| 404 | NOT_FOUND |
The workbook, the document or the bookmark does not exist or cannot be opened. | Use those from GET /workbooks. |
| 404 | API_DISABLED |
The API is disabled (ecenter.api.enabled: false). |
Enable it. |
| 400 | NOT_A_CUBE |
The requested document is not a cube. | Choose a cube document. |
| 406 | NOT_ACCEPTABLE |
The Accept is none of the accepted ones. |
Use one from supported. |
| 409 | HEAVY_QUERY |
The database estimates more rows than the warning; with estimate.rows. |
Segment, or repeat with confirmHeavy=true. |
| 409 | CONNECTION_UNAVAILABLE |
The connection is inactive. | Activate it in Administration › Connections. |
| 422 | TOO_HEAVY |
Above a cap. | Segment or remove dimensions. |
| 422 | DOCUMENT_NOT_QUERYABLE |
The document cannot be converted into a query. | Write the query. |
| 429 | RATE_LIMITED |
More requests per minute than allowed. | Wait for what Retry-After says. |
| 429 | TOO_MANY_RUNNING |
There are already 2 queries of the holder in progress, or the queue is full. | Wait for them to finish; Retry-After says how long. |
| 500 | QUERY_FAILED |
An internal failure. The detail is in the server log. | Notify whoever administers the system. |
| 502 | CLIENT_DATABASE |
The client database has failed, with a classified text (“la BD rechaza la sentencia (SQLSTATE 42703)”, the database rejects the statement; “no se llega a la BD”, the database cannot be reached; “la BD no responde a tiempo”, the database does not respond in time). | Review the connection and its database. |
The CLIENT_DATABASE text never carries the JDBC driver's message, which could name the connection's user or a column of a universe.
Monitoring metrics#
In /actuator/metrics and in the monitoring system you configure (see Operations):
| Metric | What it counts |
|---|---|
ecenter.api.requests |
The requests, per surface (query, mcp) and outcome |
ecenter.api.rejections |
What the limits, the hidden items and the origin stop, per reason |
ecenter.api.queries |
The finished queries and how long they take |
ecenter.api.runs.active |
The queries queued or being calculated |
ecenter.credentials.active, ecenter.credentials.expiring |
The valid credentials and those that expire within 30 days, per scope |
The tags never carry the holder, the client or the query.