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 #4604

Merged
merged 33 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e619ffa
Update sl-jdbc.md
rpourzand Dec 7, 2023
7dafb5f
Merge branch 'current' into rpourzand-patch-api-updates
mirnawong1 Dec 7, 2023
4844dd3
Merge branch 'current' into rpourzand-patch-api-updates
mirnawong1 Dec 7, 2023
dc49f19
Update sl-jdbc.md
rpourzand Dec 8, 2023
be5c52c
Update sl-graphql.md
rpourzand Dec 8, 2023
8c510b7
Update sl-jdbc.md
rpourzand Dec 8, 2023
436577f
Update sl-jdbc.md
rpourzand Dec 8, 2023
c250bb6
Update sl-graphql.md
rpourzand Dec 8, 2023
61af03e
Update sl-graphql.md
rpourzand Dec 8, 2023
c5afac9
Update sl-jdbc.md
rpourzand Dec 8, 2023
0b96df9
Merge branch 'current' into rpourzand-patch-api-updates
mirnawong1 Dec 19, 2023
384eba8
Update sl-graphql.md
rpourzand Dec 19, 2023
bc2239a
Update sl-jdbc.md
rpourzand Dec 21, 2023
a73e793
Update sl-graphql.md
mirnawong1 Dec 21, 2023
ceea7dc
Update website/docs/docs/dbt-cloud-apis/sl-graphql.md
mirnawong1 Dec 21, 2023
5f832e9
Update website/docs/docs/dbt-cloud-apis/sl-jdbc.md
mirnawong1 Dec 21, 2023
1b77419
Update website/docs/docs/dbt-cloud-apis/sl-jdbc.md
mirnawong1 Dec 21, 2023
e061521
Update website/docs/docs/dbt-cloud-apis/sl-jdbc.md
mirnawong1 Dec 21, 2023
7aa722d
Update website/docs/docs/dbt-cloud-apis/sl-jdbc.md
mirnawong1 Dec 21, 2023
7dc125e
Update website/docs/docs/dbt-cloud-apis/sl-jdbc.md
mirnawong1 Dec 21, 2023
ece5d3f
Update sl-jdbc.md
mirnawong1 Dec 21, 2023
b7cd78a
add toggles
mirnawong1 Dec 21, 2023
7b8cc9a
Apply suggestions from code review
matthewshaver Dec 22, 2023
871dabf
Merge branch 'current' into rpourzand-patch-api-updates
mirnawong1 Jan 9, 2024
6a32ba6
Update sl-graphql.md
rpourzand Jan 20, 2024
1d05363
Update sl-graphql.md
rpourzand Jan 20, 2024
d68dbf7
Merge branch 'current' into rpourzand-patch-api-updates
mirnawong1 Jan 23, 2024
357e5aa
Update website/docs/docs/dbt-cloud-apis/sl-jdbc.md
mirnawong1 Jan 23, 2024
192c2f0
Update website/docs/docs/dbt-cloud-apis/sl-jdbc.md
mirnawong1 Jan 23, 2024
250b3ba
Update website/docs/docs/dbt-cloud-apis/sl-jdbc.md
mirnawong1 Jan 23, 2024
fb3b8f6
Update website/docs/docs/dbt-cloud-apis/sl-graphql.md
mirnawong1 Jan 23, 2024
610da38
Update sl-graphql.md
mirnawong1 Jan 23, 2024
7f3cc44
Update sl-jdbc.md
mirnawong1 Jan 23, 2024
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
64 changes: 61 additions & 3 deletions website/docs/docs/dbt-cloud-apis/sl-graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,25 +432,83 @@ mutation {

The `where` filter takes a list argument (or a string for a single input). Depending on the object you are filtering, there are a couple of parameters:

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

- `Entity()` — Used for entities like primary and foreign keys, such as `Entity('order_id')`.

Note: If you prefer a more strongly typed `where` clause, you can optionally use `TimeDimension()` to separate out categorical dimensions from time ones. The `TimeDimension` input takes the time dimension name and also requires granularity. For example, `TimeDimension('metric_time', 'MONTH')`.
Note: If you prefer a more strongly typed `where` clause, you can optionally use `TimeDimension()` to separate out categorical dimensions from time ones. The `TimeDimension` input takes the time dimension and optionally the granularity level. `TimeDimension('metric_time', 'month')`.

```graphql
mutation {
createQuery(
environmentId: BigInt!
metrics:[{name: "order_total"}]
groupBy:[{name: "customer__customer_type"}, {name: "metric_time", grain: MONTH}]
groupBy:[{name: "customer__customer_type"}, {name: "metric_time", grain: month}]
where:[{sql: "{{ Dimension('customer__customer_type') }} = 'new'"}, {sql:"{{ Dimension('metric_time').grain('month') }} > '2022-10-01'"}]
) {
queryId
}
}
```

For both `TimeDimension()` and `Dimension()` objects, the grain is only required in the WHERE filter if the aggregation time dimensions for the measures & metrics associated with the where filter have different grains.

For example, consider this Semantic Model and Metric Configuration which contains two metrics that are aggregated across different time grains. This example shows a single Semantic Model, but the same goes for metrics across more than one Semantic Model.
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

```yaml
---
semantic_model:
name: my_model_source

defaults:
agg_time_dimension: created_month

measures:
- name: measure_0
agg: sum
- name: measure_1
agg: sum
agg_time_dimension: order_year

dimensions:
- name: created_month
type: time
type_params:
time_granularity: month
- name: order_year
type: time
type_params:
time_granularity: year
...


metrics:
name: metric_0
description: A metric with a month grain.
type: simple
type_params:
measure: measure_0

name: metric_1
description: A metric with a year grain
type: simple
type_params:
measure: measure_1

```

Assuming the user is querying metric_0 and metric_1 together, a valid filter would be:

* `"{{ TimeDimension('metric_time', 'year') }} > '2020-01-01'"`

Invalid Filters would be:

`* "{{ TimeDimension('metric_time') }} > '2020-01-01'"` - metrics in the query
rpourzand marked this conversation as resolved.
Show resolved Hide resolved
are defined based on measures with different grains.

* `"{{ TimeDimension('metric_time', 'month') }} > '2020-01-01'"` -
metric_1 is not available at a month grain.

**Query with Order**

```graphql
Expand Down
65 changes: 62 additions & 3 deletions website/docs/docs/dbt-cloud-apis/sl-jdbc.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,70 @@ Where filters in API allow for a filter list or string. We recommend using the f

Where Filters have a few objects that you can use:

- `Dimension()` - 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')`
- `Dimension()` - Used for any categorical or time dimensions. `Dimension('metric_time').grain('week')` or `Dimension('customer__country')`
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

- `Entity()` - Used for entities like primary and foreign keys - `Entity('order_id')`
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

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')`.

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 `TimeDimension` input takes the time dimension name optionally requires granularity, like this: `TimeDimension('metric_time', 'month')`.
rpourzand marked this conversation as resolved.
Show resolved Hide resolved

For both `TimeDimension()` and `Dimension()` objects, the grain is only required if in the WHERE filter if the aggregation time dimensions for the measures & metrics associated with the where filter have different grains.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grain is still required when querying a time dimension using Dimension(). For example you would still need to add Dimensions('metric_time','day').


For example, consider this Semantic Model and Metric Config which contains two metrics that are aggregated across different time grains. This example shows a single Semantic Model, but the same goes for metrics across more than one Semantic Model.
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

```yaml
---
semantic_model:
name: my_model_source

defaults:
agg_time_dimension: created_month

measures:
- name: measure_0
agg: sum
- name: measure_1
agg: sum
agg_time_dimension: order_year

dimensions:
- name: created_month
type: time
type_params:
time_granularity: month
- name: order_year
type: time
type_params:
time_granularity: year
...

metrics:
name: metric_0
description: A metric with a month grain.
type: simple
type_params:
measure: measure_0

name: metric_1
description: A metric with a year grain
type: simple
type_params:
measure: measure_1

```

Assuming the user is querying metric_0 and metric_1 together in a single request, a valid WHERE filter would be:

* `"{{ TimeDimension('metric_time', 'year') }} > '2020-01-01'"`

Invalid Filters would be:
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

`* "{{ TimeDimension('metric_time') }} > '2020-01-01'"` - metrics in the query
are defined based on measures with different grains.

* `"{{ TimeDimension('metric_time', 'month') }} > '2020-01-01'"` -
metric_1 is not available at a month grain.



- Use the following example to query using a `where` filter with the string format:
Expand Down Expand Up @@ -315,7 +374,7 @@ semantic_layer.query(metrics=['food_order_amount', 'order_gross_profit'],
order_by=[-'order_gross_profit']
}}
```
If you are ordering by an object that's been operated on (e.g., change granularity), or you are using the full object notation, descending order must look like:
If you are ordering by an object that's been operated on (e.g., you changed the the granularity of the time dimension), or you are using the full object notation, descending order must look like:
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

```bash
select * from {{
Expand Down
Loading