Skip to content

Commit

Permalink
Update sl-jdbc.md (#3953)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 authored Sep 19, 2023
2 parents 6d63f3a + 6d5be30 commit a757e5a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 12 deletions.
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.

0 comments on commit a757e5a

Please sign in to comment.