Skip to content

Commit e755776

Browse files
authored
docs(schema): add examples showing extended cubes using FILTER_PARAMS (#6102)
1 parent d14951a commit e755776

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

docs/content/Schema/Advanced/Code-Reusability-Extending-Cubes.mdx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ the cube is extended.
3737

3838
```javascript
3939
cube(`BaseEvents`, {
40-
sql: `select * from events`,
40+
sql: `SELECT * FROM events`,
4141

4242
joins: {
4343
Users: {
@@ -67,7 +67,7 @@ define only the specific dimensions – `productName` for product purchases and
6767

6868
```javascript
6969
cube(`ProductPurchases`, {
70-
sql: `select * from product_purchases`,
70+
sql: `SELECT * FROM product_purchases`,
7171
extends: BaseEvents,
7272

7373
dimensions: {
@@ -79,7 +79,7 @@ cube(`ProductPurchases`, {
7979
});
8080

8181
cube(`PageViews`, {
82-
sql: `select * from page_views`,
82+
sql: `SELECT * FROM page_views`,
8383
extends: BaseEvents,
8484

8585
dimensions: {
@@ -97,9 +97,23 @@ If the base cube is using [`FILTER_PARAMS`][ref-schema-ref-cube-filter-params]
9797
in any `sql` property, then extending cubes can do one of two things:
9898

9999
- Override the `sql` property in each target cube.
100+
```javascript
101+
cube(`ProductPurchases`, {
102+
sql: `SELECT * FROM events WHERE
103+
{$FILTER_PARAMS.ProductPurchases.timestamp.filter('time')}`,
104+
...
105+
```
100106
101107
- Put all filters inside the base cube and reference all specific cubes filters
102108
using `AND`. The unused filters will be rendered to `1 = 1` in the SQL query.
109+
```javascript
110+
cube(`BaseEvents`, {
111+
sql: `SELECT * FROM events WHERE
112+
{$FILTER_PARAMS.BaseEvents.timestamp.filter('time')}
113+
AND {$FILTER_PARAMS.ProductPurchases.timestamp.filter('time')}
114+
AND {$FILTER_PARAMS.PageViews.timestamp.filter('time')}`,
115+
...
116+
```
103117
104118
[mdn-js-objects]:
105119
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object

0 commit comments

Comments
 (0)