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
Copy file name to clipboardExpand all lines: docs/Cube.js-Frontend/Query-Format.md
+32-32Lines changed: 32 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,34 +5,34 @@ category: Cube.js Frontend
5
5
menuOrder: 1
6
6
---
7
7
8
-
Query is plain JavaScript object, describing an analytics query. The basic elements of query (query members) are `measures`, `dimensions`, and `segments`.
8
+
Cube Queries are plain JavaScript objects, describing an analytics query. The basic elements of a query (query members) are `measures`, `dimensions`, and `segments`.
9
9
10
-
The query member format name is `CUBE_NAME.MEMBER_NAME`, for example dimension email in the Cube Users would have the following name `Users.email`.
10
+
The query member format name is `CUBE_NAME.MEMBER_NAME`, for example the dimension `email` in the Cube `Users` would have the name `Users.email`.
11
11
12
-
In a case of dimension of type time granularity could be optionally added to the name, in the following format `CUBE_NAME.TIME_DIMENSION_NAME.GRANULARITY`, ex: `Stories.time.month`.
12
+
In the case of dimension of type `time` granularity could be optionally added to the name, in the following format `CUBE_NAME.TIME_DIMENSION_NAME.GRANULARITY`, ex: `Stories.time.month`.
-`filters`: An array of objects, describing filters. Learn about [filters format](#filters-format).
23
-
-`timeDimensions`: A convient way to specify a time dimension with a filter. It is an array of objects in [timeDimension format.](#time-dimensions-format)
24
-
-`segments`: An array of segments. Segment is a named filter, created in the Data Schema.
23
+
-`timeDimensions`: A convenient way to specify a time dimension with a filter. It is an array of objects in [timeDimension format.](#time-dimensions-format)
24
+
-`segments`: An array of segments. A segment is a named filter, created in the Data Schema.
25
25
-`limit`: A row limit for your query. The default value is `10000`. The
26
26
maximum allowed limit is `50000`.
27
-
-`offset`: Number of first rows to be skipped for your query. The default value is `0`.
28
-
-`order`: An object, where keys are measures or dimensions to order by and
27
+
-`offset`: The number of initial rows to be skipped for your query. The default value is `0`.
28
+
-`order`: An object, where the keys are measures or dimensions to order by and
29
29
their corresponding values are either `asc` or `desc`. The order of the
30
-
fields to order is based on the order of the keys in the object.
30
+
fields to order on is based on the order of the keys in the object.
31
31
-`timezone`: All time based calculations performed within Cube.js are timezone-aware. Using this property you can set your desired timezone in [TZ Database Name](https://en.wikipedia.org/wiki/Tz_database) format, e.g.: `America/Los_Angeles`. The default value is `UTC`.
32
-
-`renewQuery`: If `renewQuery` is set to `true`, Cube.js will renew all `refreshKey` for query and query result itself in foreground. However if `refreshKey` or `refreshKeyRenewalThreshold` don't indicate that there's a need for update this setting has no effect. The default value is `false`.
33
-
-`ungrouped`: If `ungrouped` is set to `true` no `GROUP BY` statement will be added to the query and raw results after filtering and joining will be returned without grouping.
34
-
By default `ungrouped`query requires to pass primary key as a dimension of every cube involved in query for security purpose.
35
-
To disable this behavior please see [allowUngroupedWithoutPrimaryKey](@cubejs-backend-server-core#options-reference-allow-ungrouped-without-primary-key) server option.
32
+
-`renewQuery`: If `renewQuery` is set to `true`, Cube.js will renew all `refreshKey` for queries and query results in the foreground. However if the `refreshKey` or `refreshKeyRenewalThreshold` don't indicate that there's a need for an update this setting has no effect. The default value is `false`.
33
+
-`ungrouped`: If `ungrouped` is set to `true` no `GROUP BY` statement will be added to the query. Instead, the raw results after filtering and joining will be returned without grouping.
34
+
By default `ungrouped`queries require a primary key as a dimension of every cube involved in the query for security purposes.
35
+
To disable this behavior please see the [allowUngroupedWithoutPrimaryKey](@cubejs-backend-server-core#options-reference-allow-ungrouped-without-primary-key) server option.
36
36
37
37
```js
38
38
{
@@ -60,7 +60,7 @@ To disable this behavior please see [allowUngroupedWithoutPrimaryKey](@cubejs-ba
60
60
61
61
### Default order
62
62
63
-
If `order` property is not specified in the query, Cube.js sorts results by default using the following rules:
63
+
If the `order` property is not specified in the query, Cube.js sorts results by default using the following rules:
64
64
65
65
- The first time dimension with granularity, ascending. If no time dimension with granularity exists...
66
66
- The first measure, descending. If no measure exists...
@@ -70,11 +70,11 @@ If `order` property is not specified in the query, Cube.js sorts results by defa
70
70
71
71
A filter is a Javascript object with the following properties:
72
72
73
-
-`member`: Dimension or measure to be used in the filter, for example: `Stories.isDraft`. See below on difference on filtering dimensions vs filtering measures.
74
-
-`operator`: An operator to be used in filter. Only some operators are available for measures, for dimensions available operators depend on the type
73
+
-`member`: Dimension or measure to be used in the filter, for example: `Stories.isDraft`. See below on difference between filtering dimensions vs filtering measures.
74
+
-`operator`: An operator to be used in the filter. Only some operators are available for measures. For dimensions the available operators depend on the type
75
75
of the dimension. Please see the reference below for the full list of available
76
76
operators.
77
-
-`values`: An array of values for the filter. Values must be of type String. If you need to pass a date, pass it as a string in `YYYY-MM-DD`.
77
+
-`values`: An array of values for the filter. Values must be of type String. If you need to pass a date, pass it as a string in `YYYY-MM-DD` format.
78
78
79
79
#### Filtering Dimensions vs Filtering Measures
80
80
Filters are applied differently to dimensions and measures.
@@ -83,7 +83,7 @@ When you filter on a dimension, you are restricting the raw data before any calc
83
83
When you filter on a measure, you are restricting the results after the measure has been calculated.
84
84
85
85
## Filters Operators
86
-
Only some operators are available for measures. For dimensionsavailable operators are depend on the [type of the dimension](types-and-formats#dimensions-types).
86
+
Only some operators are available for measures. For dimensions, the available operators depend on the [type of the dimension](types-and-formats#dimensions-types).
87
87
88
88
### equals
89
89
@@ -102,7 +102,7 @@ Use it when you need an exact match. It supports multiple values.
102
102
103
103
### notEquals
104
104
105
-
An opposite operator of `equals`. It supports multiple values.
105
+
The opposite operator of `equals`. It supports multiple values.
106
106
107
107
* Applied to measures.
108
108
* Dimension types: `string`, `number`, `time`.
@@ -117,7 +117,7 @@ An opposite operator of `equals`. It supports multiple values.
117
117
118
118
### contains
119
119
120
-
`contains` filter acts as a wildcard case insensitive `LIKE` operator. In the majority of SQL backends it uses `ILIKE` operator with values being surrounded by `%`. It supports multiple values.
120
+
The `contains` filter acts as a wildcard case insensitive `LIKE` operator. In the majority of SQL backends it uses `ILIKE` operator with values being surrounded by `%`. It supports multiple values.
121
121
122
122
* Dimension types: `string`.
123
123
@@ -131,7 +131,7 @@ An opposite operator of `equals`. It supports multiple values.
131
131
132
132
### notContains
133
133
134
-
An opposite operator of `contains`. It supports multiple values.
134
+
The opposite operator of `contains`. It supports multiple values.
135
135
136
136
* Dimension types: `string`.
137
137
@@ -145,7 +145,7 @@ An opposite operator of `contains`. It supports multiple values.
145
145
146
146
### gt
147
147
148
-
The `gt` operator means **greater than** and is used with measures or dimensions of type number.
148
+
The `gt` operator means **greater than** and is used with measures or dimensions of type `number`.
149
149
150
150
* Applied to measures.
151
151
* Dimension types: `number`.
@@ -160,7 +160,7 @@ The `gt` operator means **greater than** and is used with measures or dimensions
160
160
161
161
### gte
162
162
163
-
The `gte` operator means **greater than or equal to** and is used with measures or dimensions of type number.
163
+
The `gte` operator means **greater than or equal to** and is used with measures or dimensions of type `number`.
164
164
165
165
* Applied to measures.
166
166
* Dimension types: `number`.
@@ -175,7 +175,7 @@ The `gte` operator means **greater than or equal to** and is used with measures
175
175
176
176
### lt
177
177
178
-
The `lt` operator means **less than** and is used with measures or dimensions of type number.
178
+
The `lt` operator means **less than** and is used with measures or dimensions of type `number`.
179
179
180
180
* Applied to measures.
181
181
* Dimension types: `number`.
@@ -190,7 +190,7 @@ The `lt` operator means **less than** and is used with measures or dimensions of
190
190
191
191
### lte
192
192
193
-
The `lte` operator means **less than or equal to** and is used with measures or dimensions of type number.
193
+
The `lte` operator means **less than or equal to** and is used with measures or dimensions of type `number`.
194
194
195
195
* Applied to measures.
196
196
* Dimension types: `number`.
@@ -220,7 +220,7 @@ need to pass `values` for this operator.
220
220
221
221
### notSet
222
222
223
-
An opposite to `set` operator. It checks whether the value of the member **is**`NULL`. You don't
223
+
An opposite to the `set` operator. It checks whether the value of the member **is**`NULL`. You don't
224
224
need to pass `values` for this operator.
225
225
226
226
* Applied to measures.
@@ -235,7 +235,7 @@ need to pass `values` for this operator.
235
235
236
236
### inDateRange
237
237
238
-
Operator `inDateRange` used to filter a time dimension into specific date range. The values must be an array of dates with following format '2015-01-01'. If only one date specified the filter would be set exactly to this date.
238
+
The operator `inDateRange`is used to filter a time dimension into a specific date range. The values must be an array of dates with the following format 'YYYY-MM-DD'. If only one date specified the filter would be set exactly to this date.
239
239
240
240
There is a convient way to use date filters with grouping - [learn more about
@@ -281,7 +281,7 @@ values should be an array of one element in `YYYY-MM-DD` format.
281
281
282
282
### afterDate
283
283
284
-
The same as `beforeDate`, but used to get all results after specific date.
284
+
The same as `beforeDate`, but is used to get all results after a specific date.
285
285
286
286
287
287
* Dimension types: `time`.
@@ -297,16 +297,16 @@ The same as `beforeDate`, but used to get all results after specific date.
297
297
298
298
## Time Dimensions Format
299
299
300
-
Since grouping and filtering by a time dimension is quite a common case, Cube.js provides a convient shortcut to pass a dimension and a filter as a `timeDimension` property.
300
+
Since grouping and filtering by a time dimension is quite a common case, Cube.js provides a convenient shortcut to pass a dimension and a filter as a `timeDimension` property.
301
301
302
302
-`dimension`: Time dimension name.
303
303
-`dateRange`: An array of dates with the following format `YYYY-MM-DD` or in `YYYY-MM-DDTHH:mm:ss.SSS` format.
304
304
Values should always be local and in query `timezone`.
305
305
Dates in `YYYY-MM-DD` format are also accepted.
306
-
Such dates padded to start and end of day if used in start and end of date range interval accordingly.
307
-
If only one date specified it's equivalent to passing two same dates as a date range.
306
+
Such dates are padded to the start and end of the day if used in start and end of date range interval accordingly.
307
+
If only one date is specified it's equivalent to passing two of the same dates as a date range.
308
308
You can also pass a string instead of array with relative date range, for example: `last quarter` or `last 360 days`.
309
-
-`granularity`: A granularity for a time dimension. It supports following values `second`, `minute`, `hour`, `day`, `week`, `month`, `year`. If you pass `null` to the granularity, the Cube.js will only perform a filtering by specified time dimension, without grouping.
309
+
-`granularity`: A granularity for a time dimension. It supports the following values `second`, `minute`, `hour`, `day`, `week`, `month`, `year`. If you pass `null` to the granularity, Cube.js will only perform filtering by a specified time dimension, without grouping.
0 commit comments