Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sl-jdbc.md #4102

Merged
merged 19 commits into from
Oct 13, 2023
Merged
Changes from 8 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
132668e
Update sl-jdbc.md
rpourzand Sep 20, 2023
1cc4c03
Update sl-jdbc.md
rpourzand Sep 20, 2023
6911c26
Merge branch 'current' into rpourzand-order-by-and-where-updates
mirnawong1 Sep 22, 2023
438568b
Update website/docs/docs/dbt-cloud-apis/sl-jdbc.md
rpourzand Sep 22, 2023
85f1772
Update sl-jdbc.md
rpourzand Sep 22, 2023
daad977
Merge branch 'current' into rpourzand-order-by-and-where-updates
mirnawong1 Sep 25, 2023
c7271ef
Merge branch 'current' into rpourzand-order-by-and-where-updates
mirnawong1 Sep 25, 2023
690e5bc
Update website/docs/docs/dbt-cloud-apis/sl-jdbc.md
mirnawong1 Sep 25, 2023
caff001
Merge branch 'current' into rpourzand-order-by-and-where-updates
mirnawong1 Oct 2, 2023
904d209
update tabs
mirnawong1 Oct 2, 2023
6cf965b
Merge branch 'rpourzand-order-by-and-where-updates' of https://github…
mirnawong1 Oct 2, 2023
cc5eb65
Merge branch 'current' into rpourzand-order-by-and-where-updates
mirnawong1 Oct 2, 2023
c7ad961
Merge branch 'current' into rpourzand-order-by-and-where-updates
mirnawong1 Oct 2, 2023
0ba8510
clarify integrations
mirnawong1 Oct 2, 2023
a6a1d67
Update website/snippets/_sl-partner-links.md
mirnawong1 Oct 13, 2023
d6b21b5
Merge branch 'current' into rpourzand-order-by-and-where-updates
mirnawong1 Oct 13, 2023
12d3e7e
Update avail-sl-integrations.md
mirnawong1 Oct 13, 2023
86ec8b6
Merge branch 'current' into rpourzand-order-by-and-where-updates
mirnawong1 Oct 13, 2023
8180f4b
Merge branch 'current' into rpourzand-order-by-and-where-updates
mirnawong1 Oct 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions website/docs/docs/dbt-cloud-apis/sl-jdbc.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ To query metric values, here are the following parameters that are available:
| `metrics` | The metric name as defined in your dbt metric configuration | `metrics=['revenue']` | Required |
| `group_by` | Dimension names or entities to group by. We require a reference to the entity of the dimension (other than for the primary time dimension), which is pre-appended to the front of the dimension name with a double underscore. | `group_by=['user__country', 'metric_time']` | Optional |
| `grain` | A parameter specific to any time dimension and changes the grain of the data from the default for the metric. | `group_by=[Dimension('metric_time')` <br/> `grain('week\|day\|month\|quarter\|year')]` | Optional |
| `where` | A where clause that allows you to filter on dimensions and entities using parameters - comes with `TimeDimension`, `Dimension`, and `Entity` objects. Granularity is required with `TimeDimension` | `"{{ where=Dimension('customer__country') }} = 'US')"` | Optional |
| `where` | A where clause that allows you to filter on dimensions and entities using parameters. This takes a filter list OR string. Inputs come with `Dimension`, and `Entity` objects. Granularity is required if the `Dimension` is a time dimension | `"{{ where=Dimension('customer__country') }} = 'US')"` | Optional |
| `limit` | Limit the data returned | `limit=10` | Optional |
|`order` | Order the data returned | `order_by=['-order_gross_profit']` (remove `-` for ascending order) | Optional |
|`order` | Order the data returned | `order_by=['-order_gross_profit']` (remove `-` for ascending order). | Optional |
| `explain` | If true, returns generated SQL for the data platform but does not execute | `explain=True` | Optional |


Expand Down Expand Up @@ -244,13 +244,13 @@ select * from {{

Where filters in API allow for a filter list or string. We recommend using the filter list for production applications as this format will realize all benefits from the <Term id="predicate-pushdown" /> where possible.

Where filters have the following components that you can use:
Where Filters have a few objects that you can use:

- `Dimension()` - This is used for any categorical or time dimensions. If used for a time dimension, granularity is required - `Dimension('metric_time').grain('week')` or `Dimension('customer__country')`

- `TimeDimension()` - This is used for all time dimensions and requires a granularity argument - `TimeDimension('metric_time', 'MONTH)`
- `Entity()` - Used for entities like primary and foreign keys - `Entity('order_id')`

- `Entity()` - This is used for entities like primary and foreign keys - `Entity('order_id')`
Note: If you prefer a more explicit path to create the `where` clause, you can optionally use the `TimeDimension` feature. This helps separate out categorical dimensions from time-related ones. The `TimeDimesion` input takes the time dimension name and also requires granularity, like this: `TimeDimension('metric_time', 'MONTH')`.


Use the following example to query using a `where` filter with the string format:
Expand All @@ -259,7 +259,7 @@ Use the following example to query using a `where` filter with the string format
select * from {{
semantic_layer.query(metrics=['food_order_amount', 'order_gross_profit'],
group_by=[Dimension('metric_time').grain('month'),'customer__customer_type'],
where="{{ TimeDimension('metric_time', 'MONTH') }} >= '2017-03-09' AND {{ Dimension('customer__customer_type' }} in ('new') AND {{ Entity('order_id') }} = 10")
where="{{ Dimension('metric_time').grain('month') }} >= '2017-03-09' AND {{ Dimension('customer__customer_type' }} in ('new') AND {{ Entity('order_id') }} = 10")
}}
```

Expand All @@ -269,7 +269,7 @@ Use the following example to query using a `where` filter with a filter list for
select * from {{
semantic_layer.query(metrics=['food_order_amount', 'order_gross_profit'],
group_by=[Dimension('metric_time').grain('month'),'customer__customer_type'],
where=[{{ TimeDimension('metric_time', 'MONTH')}} >= '2017-03-09', {{ Dimension('customer__customer_type' }} in ('new'), {{ Entity('order_id') }} = 10])
where=[{{ Dimension('metric_time').grain('month') }} >= '2017-03-09', {{ Dimension('customer__customer_type' }} in ('new'), {{ Entity('order_id') }} = 10])
}}
```

Expand All @@ -285,6 +285,20 @@ semantic_layer.query(metrics=['food_order_amount', 'order_gross_profit'],
order_by=['order_gross_profit'])
}}
```

When using `order_by` and making changes to the object (like changing granularity), use this syntax:

```bash
...
order_by=[Dimension('metric_time').grain('month')]
```

```
...
order_by=[Dimension('metric_time').grain('month').descending(true)]
```


### Query with explain keyword

Use the following example to query using a `explain` keyword:
Expand Down