You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"SELECT\n date_trunc('day', (users.created_at::timestamptz AT TIME ZONE 'UTC')) \"users.created_at_date\", count(users.id) \"users.count\"\n FROM\n public.users AS users\n WHERE (users.created_at >= $1::timestamptz AND users.created_at <= $2::timestamptz) GROUP BY 1 ORDER BY 1 ASC LIMIT 10000",
164
-
["2019-03-01T00:00:00Z", "2019-03-31T23:59:59Z"]
165
-
],
166
-
"timeDimensionAlias": "users.created_at_date",
167
-
"timeDimensionField": "users.createdAt",
168
-
"order": [
169
-
{
170
-
"id": "users.createdAt",
171
-
"desc": false
172
-
}
163
+
"SELECT sum(`base_orders__count`) `orders__count` FROM prod_pre_aggregations.base_orders_orders_by_month AS `base_orders__orders_by_month` LIMIT 10000",
164
+
[]
165
+
]
166
+
}
167
+
}
168
+
```
169
+
170
+
Request with a query in the SQL API format:
171
+
172
+
```bash
173
+
curl \
174
+
-H "Authorization: TOKEN" \
175
+
-G \
176
+
--data-urlencode 'query=SELECT COUNT(*) FROM orders' \
177
+
--data-urlencode 'format=sql'\
178
+
http://localhost:4000/cubejs-api/v1/sql
179
+
```
180
+
181
+
Response:
182
+
183
+
```json
184
+
{
185
+
"sql": {
186
+
"status": "ok",
187
+
"sql": [
188
+
"SELECT\n count(\"base_orders\".id) \"count_uint8_1__\"\n FROM\n (SELECT * FROM 's3://cube-tutorial/orders.csv') AS \"base_orders\" LIMIT 50000",
189
+
[]
173
190
],
174
-
"cacheKeyQueries": {
175
-
"queries": [
176
-
["select max(users.created_at) from public.users AS users", []]
177
-
],
178
-
"renewalThreshold": 21600
179
-
},
180
-
"preAggregations": []
191
+
"query_type": "regular"
181
192
}
182
193
}
183
194
```
184
195
185
-
<InfoBox>
196
+
Request with a query in the SQL API format that is executed with post-processing:
186
197
187
-
Note that a generated query can contain placeholders, e.g., `?` or `$1`, for parameters
188
-
that Cube passes to an underlying data source driver later when executing the query.
198
+
```bash
199
+
curl \
200
+
-H "Authorization: TOKEN" \
201
+
-G \
202
+
--data-urlencode 'query=SELECT AVG(count) FROM (SELECT COUNT(*) AS count FROM orders) AS table' \
203
+
--data-urlencode 'format=sql'\
204
+
http://localhost:4000/cubejs-api/v1/sql
205
+
```
189
206
190
-
</InfoBox>
207
+
Response:
208
+
209
+
```json
210
+
{
211
+
"sql": {
212
+
"status": "error",
213
+
"error": "Provided query can not be executed without post-processing.",
214
+
"query_type": "post_processing"
215
+
}
216
+
}
217
+
```
218
+
219
+
Request with a query in the SQL API format that is forced to be executed without
220
+
post-processing, i.e., as a query with pushdown:
221
+
222
+
```bash
223
+
curl \
224
+
-H "Authorization: TOKEN" \
225
+
-G \
226
+
--data-urlencode 'query=SELECT AVG(count) FROM (SELECT COUNT(*) AS count FROM orders) AS table' \
227
+
--data-urlencode 'format=sql' \
228
+
--data-urlencode 'disable_post_processing=true' \
229
+
http://localhost:4000/cubejs-api/v1/sql
230
+
```
231
+
232
+
Response:
233
+
234
+
```json
235
+
{
236
+
"sql": {
237
+
"status": "ok",
238
+
"sql": [
239
+
"SELECT \"table\".\"avg_table_count_\"\"avg_table_count_\"\nFROM (\n SELECT AVG(\"table\".\"count\") \"avg_table_count_\"\n FROM (\n SELECT\n count(\"base_orders\".id) \"count\"\n FROM\n (SELECT * FROM 's3://cube-tutorial/orders.csv') AS \"base_orders\"\n ) AS \"table\"\n) AS \"table\"\nLIMIT 50000",
240
+
[]
241
+
],
242
+
"query_type": "pushdown"
243
+
}
244
+
}
245
+
```
191
246
192
247
## `{base_path}/v1/meta`
193
248
@@ -210,7 +265,7 @@ Response
210
265
211
266
Example request:
212
267
213
-
```bash{outputLines: 2-4}
268
+
```bash
214
269
curl \
215
270
-H "Authorization: EXAMPLE-API-TOKEN" \
216
271
-G \
@@ -282,7 +337,7 @@ contain an array of `tokens` (identifiers) of triggered jobs.
282
337
Example request triggering builds of all pre-aggregations defined in all cubes
283
338
using an empty security context and a `UTC` timezone:
284
339
285
-
```bash{outputLines: 2-12}
340
+
```bash
286
341
curl \
287
342
-d '{
288
343
"action": "post",
@@ -300,7 +355,7 @@ curl \
300
355
Example request triggering builds of all pre-aggregations defined in the
301
356
`orders` cube using an empty security context and a `UTC` timezone:
302
357
303
-
```bash{outputLines: 2-13}
358
+
```bash
304
359
curl \
305
360
-d '{
306
361
"action": "post",
@@ -319,7 +374,7 @@ curl \
319
374
Example request triggering builds of the `main` pre-aggregation defined in the
320
375
`orders` cube using an empty security context and a `UTC` timezone:
321
376
322
-
```bash{outputLines: 2-13}
377
+
```bash
323
378
curl \
324
379
-d '{
325
380
"action": "post",
@@ -339,7 +394,7 @@ Example request triggering builds of the `main` pre-aggregation defined in the
339
394
`orders` cube within date range with some security context data
340
395
and an `America/Los_Angeles` timezone:
341
396
342
-
```bash{outputLines: 2-13}
397
+
```bash
343
398
curl \
344
399
-d '{
345
400
"action": "post",
@@ -389,7 +444,7 @@ In the `status` property of the payload, you can get the following statuses:
389
444
390
445
Example request:
391
446
392
-
```bash{outputLines: 2-14}
447
+
```bash
393
448
curl \
394
449
-d '{
395
450
"action": "get",
@@ -442,7 +497,7 @@ the connection to the _default_ [data source][ref-datasources].
442
497
443
498
Example of a successful request:
444
499
445
-
```bash{outputLines: 2-12}
500
+
```bash
446
501
curl -i http://localhost:4000/readyz
447
502
HTTP/1.1 200 OK
448
503
X-Powered-By: Express
@@ -459,7 +514,7 @@ Keep-Alive: timeout=5
459
514
460
515
Example of a failed response:
461
516
462
-
```bash{outputLines: 2-12}
517
+
```bash
463
518
curl -i http://localhost:4000/readyz
464
519
HTTP/1.1 500 Internal Server Error
465
520
X-Powered-By: Express
@@ -481,7 +536,7 @@ existing connections to data sources.
0 commit comments