diff --git a/website/docs/docs/dbt-cloud-apis/sl-jdbc.md b/website/docs/docs/dbt-cloud-apis/sl-jdbc.md index 75ac38b4064..b50dd99ec75 100644 --- a/website/docs/docs/dbt-cloud-apis/sl-jdbc.md +++ b/website/docs/docs/dbt-cloud-apis/sl-jdbc.md @@ -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 {{ @@ -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 {{ @@ -98,11 +98,11 @@ semantic_layer.dimension_values(metrics=['food_order_amount'], group_by=['custom - + -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 {{ @@ -127,6 +127,33 @@ select * from {{ + + +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"] + ) +}} + +``` + + + + + +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']) +}} +``` + + ## Querying the API for metric values @@ -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 {{ @@ -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 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 {{ @@ -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: diff --git a/website/docs/terms/predicate-pushdown.md b/website/docs/terms/predicate-pushdown.md new file mode 100644 index 00000000000..8e9bad85b6b --- /dev/null +++ b/website/docs/terms/predicate-pushdown.md @@ -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. +