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

Merged
merged 26 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8176b66
Update sl-jdbc.md
rpourzand Aug 18, 2023
678daaf
Update website/docs/docs/dbt-cloud-apis/sl-jdbc.md
mirnawong1 Aug 23, 2023
9c850c7
Update website/docs/docs/dbt-cloud-apis/sl-jdbc.md
mirnawong1 Aug 23, 2023
8f458f6
Update website/docs/docs/dbt-cloud-apis/sl-jdbc.md
mirnawong1 Aug 23, 2023
59a4c76
Merge branch 'current' into rpourzand-jdbc-updates-where-filters
mirnawong1 Aug 23, 2023
fd53519
Merge branch 'current' into rpourzand-jdbc-updates-where-filters
mirnawong1 Aug 29, 2023
832a64a
Update sl-jdbc.md
rpourzand Aug 29, 2023
78f4276
Update sl-jdbc.md
rpourzand Aug 29, 2023
d7525ac
Merge branch 'current' into rpourzand-jdbc-updates-where-filters
mirnawong1 Aug 31, 2023
86f9593
Create predicate-pushdown.md
mirnawong1 Aug 31, 2023
33800bb
Update predicate-pushdown.md
mirnawong1 Aug 31, 2023
5d68215
clarify predicate pushdown and add term
mirnawong1 Aug 31, 2023
2bdfdd1
Merge branch 'current' into rpourzand-jdbc-updates-where-filters
mirnawong1 Sep 5, 2023
6f5e46e
Merge branch 'current' into rpourzand-jdbc-updates-where-filters
marcodamore Sep 5, 2023
97bd5a1
Update website/docs/docs/dbt-cloud-apis/sl-jdbc.md
mirnawong1 Sep 5, 2023
ae83b1f
Merge branch 'current' into rpourzand-jdbc-updates-where-filters
mirnawong1 Sep 7, 2023
826b267
Merge branch 'current' into rpourzand-jdbc-updates-where-filters
mirnawong1 Sep 11, 2023
968be37
Merge branch 'current' into rpourzand-jdbc-updates-where-filters
mirnawong1 Sep 18, 2023
e53523c
Update sl-jdbc.md
rpourzand Sep 18, 2023
86ac6dd
Update sl-jdbc.md
rpourzand Sep 18, 2023
de2e325
Update sl-jdbc.md
mirnawong1 Sep 19, 2023
bfe1f3f
Merge branch 'current' into rpourzand-jdbc-updates-where-filters
mirnawong1 Sep 19, 2023
58ba503
Merge branch 'current' into rpourzand-jdbc-updates-where-filters
mirnawong1 Sep 19, 2023
15f9d70
Update sl-jdbc.md
mirnawong1 Sep 19, 2023
35c22e6
Merge branch 'current' into rpourzand-jdbc-updates-where-filters
mirnawong1 Sep 19, 2023
6d5be30
Merge branch 'current' into rpourzand-jdbc-updates-where-filters
mirnawong1 Sep 19, 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
64 changes: 52 additions & 12 deletions website/docs/docs/dbt-cloud-apis/sl-jdbc.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ select * from {{

Use this query to fetch all dimensions for a metric.

Note, `metrics` is a required argument that lists with one or multiple metrics in it.
Note, `metrics` is a required argument that lists one or multiple metrics in it.

```bash
select * from {{
Expand All @@ -89,7 +89,7 @@ select * from {{

Use this query to fetch dimension values for one or multiple metrics and single dimension.

Note, `metrics` is a required argument that lists with one or multiple metrics in it, and a single dimension.
Note, `metrics` is a required argument that lists one or multiple metrics in it, and a single dimension.

```bash
select * from {{
Expand All @@ -98,11 +98,11 @@ semantic_layer.dimension_values(metrics=['food_order_amount'], group_by=['custom

</TabItem>

<TabItem value="queryablegranularitiesformetrics" label="Fetch queryable time granularities for metrics">
<TabItem value="queryablegranularitiesformetrics" label="Fetch queryable primary time granularities for metrics">

Use this query to fetch queryable granularities for a list of metrics. This argument allows you to only show the time granularities that make sense for the source model that the metrics are built off of.
Use this query to fetch queryable granularities for a list of metrics. This API request allows you to only show the time granularities that make sense for the primary time dimension of the metrics (such as `metric_time`), but if you want queryable granularities for other time dimensions, you can use the `dimensions()` call, and find the column queryable_granularities.

Note, `metrics` is a required argument that lists with one or multiple metrics in it.
Note, `metrics` is a required argument that lists one or multiple metrics in it.

```bash
select * from {{
Expand All @@ -127,6 +127,33 @@ select * from {{

</TabItem>

<TabItem value="queryablegranularitiesalltimedimensions" label="Fetch queryable granularities for all time dimensions">

Use this example query to fetch available granularities for all time dimesensions (the similar queryable granularities API call only returns granularities for the primary time dimensions for metrics). The following call is a derivative of the `dimensions()` call and specifically selects the granularities field.

```bash
select NAME, QUERYABLE_GRANULARITIES from {{
semantic_layer.dimensions(
metrics=["order_total"]
)
}}

```

</TabItem>

<TabItem value="fetchprimarytimedimensionnames" label="Determine what time dimension(s) make up metric_time for your metric(s)">

It may be useful in your application to expose the names of the time dimensions that represent `metric_time` or the common thread across all metrics.
You can first query the `metrics()` argument to fetch a list of measures, then use the `measures()` call which will return the name(s) of the time dimensions that make up metric time.

```bash
select * from {{
semantic_layer.measures(metrics=['orders'])
}}
```
</TabItem>

</Tabs>

## Querying the API for metric values
Expand Down Expand Up @@ -193,7 +220,7 @@ select * from {{

### Query with a time grain

Use the following example query to fetch multiple metrics with a change time dimension granularities:
Use the following example query to fetch multiple metrics with a change in time dimension granularities:

```bash
select * from {{
Expand All @@ -215,15 +242,18 @@ select * from {{

### Query with where filters

Where filters have three components:
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:

- `TimeDimension()` is used for any time dimension and requires a granularity argument - `TimeDimension('metric_time', 'DAY')`
- `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')`

- `Dimension()` - This is used for any categorical dimensions - `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')`

Use the following example to query using a `where` filter:

Use the following example to query using a `where` filter with the string format:

```bash
select * from {{
Expand All @@ -233,7 +263,17 @@ where="{{ TimeDimension('metric_time', 'MONTH') }} >= '2017-03-09' AND {{ Dimens
}}
```

### Query with a limit and order_by
Use the following example to query using a `where` filter with a filter list format:

```bash
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])
}}
```

### Query with a limit and order by

Use the following example to query using a `limit` or `order_by` clauses:

Expand Down
10 changes: 10 additions & 0 deletions website/docs/terms/predicate-pushdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
id: predicate-pushdown
title: predicate pushdown
description: A predicate pushdown is an expression used to determine what rows in a database apply to a particular query
displayText: Predicate pushdown
hoverSnippet: A predicate pushdown is an expression used to determine what rows in a database apply to a particular query
---

A predicate pushdown is an expression used to determine what rows in a database apply to a particular query. For example, if you filter in a `WHERE` clause based on a specific dimension value, the database searches to determine what values in the database apply to the query. The optimization known as "predicate pushdown" involves applying this filtering process to the database, leading to enhanced and faster query performance.

Loading