From a939fb5f47a33da7a153e92e6b8c0d5c610638f5 Mon Sep 17 00:00:00 2001 From: mirnawong1 Date: Fri, 26 Jan 2024 12:54:55 +0000 Subject: [PATCH 1/5] add to jdbc --- website/docs/docs/dbt-cloud-apis/sl-jdbc.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/website/docs/docs/dbt-cloud-apis/sl-jdbc.md b/website/docs/docs/dbt-cloud-apis/sl-jdbc.md index 2e928db6af2..ec48aa0f885 100644 --- a/website/docs/docs/dbt-cloud-apis/sl-jdbc.md +++ b/website/docs/docs/dbt-cloud-apis/sl-jdbc.md @@ -413,6 +413,24 @@ semantic_layer.query(metrics=['food_order_amount', 'order_gross_profit'], }} ``` +You can compile SQL with a [saved query](/docs/build/saved-queries) using the following example: + +```sql +select * from {{ semantic_layer.query(saved_query="new_customer_orders", limit=5, compile=True}} +``` + +In the previous saved query example, the `compile=True` argument indicates that the SQL will be compiled using a saved query before executed. This means the JDBC API will first translate the saved query (`new_customer_orders`) into executable SQL code and then apply the limit of 5 records. + +### Query a saved query + +Use the following example to query a [saved query](/docs/build/saved-queries): + +```sql +select * from {{ semantic_layer.query(saved_query="new_customer_orders", limit=5}} +``` + +The JDBC API will use the saved query (`new_customer_orders`) as defined and apply a limit of 5 records. + ## FAQs From 29f597c64e94da717302780943e7552a841c7125 Mon Sep 17 00:00:00 2001 From: mirnawong1 Date: Fri, 26 Jan 2024 15:25:46 +0000 Subject: [PATCH 2/5] add changes --- .../docs/docs/build/metricflow-commands.md | 41 +++++++----- .../docs/docs/dbt-cloud-apis/sl-graphql.md | 63 +++++++++++++++++++ website/docs/docs/dbt-cloud-apis/sl-jdbc.md | 37 ++++++----- 3 files changed, 110 insertions(+), 31 deletions(-) diff --git a/website/docs/docs/build/metricflow-commands.md b/website/docs/docs/build/metricflow-commands.md index a0964269e68..19f1b095da0 100644 --- a/website/docs/docs/build/metricflow-commands.md +++ b/website/docs/docs/build/metricflow-commands.md @@ -25,7 +25,7 @@ Using MetricFlow with dbt Cloud means you won't need to manage versioning &mdash -- MetricFlow commands are embedded in the dbt Cloud CLI. This means you can immediately run them once you install the dbt Cloud CLI and don't need to install MetricFlow separately. +- MetricFlow [commands](#metricflow-commands) are embedded in the dbt Cloud CLI. This means you can immediately run them once you install the dbt Cloud CLI and don't need to install MetricFlow separately. - You don't need to manage versioning — your dbt Cloud account will automatically manage the versioning for you. @@ -36,21 +36,17 @@ Using MetricFlow with dbt Cloud means you won't need to manage versioning &mdash You can create metrics using MetricFlow in the dbt Cloud IDE. However, support for running MetricFlow commands in the IDE will be available soon. ::: - - +:::tip Use dbt Cloud CLI for semantic layer development -:::info Use dbt Cloud CLI for semantic layer development - -Use the dbt Cloud CLI for the experience in defining and querying metrics in your dbt project on dbt Cloud or dbt Core with MetricFlow. +You can use the dbt Cloud CLI for the experience in defining and querying metrics in your dbt project. A benefit to using the dbt Cloud is that you won't need to manage versioning — your dbt Cloud account will automatically manage the versioning. ::: - You can install [MetricFlow](https://github.com/dbt-labs/metricflow#getting-started) from [PyPI](https://pypi.org/project/dbt-metricflow/). You need to use `pip` to install MetricFlow on Windows or Linux operating systems: 1. Create or activate your virtual environment `python -m venv venv` @@ -70,16 +66,16 @@ Something to note, MetricFlow `mf` commands return an error if you have a Metafo MetricFlow provides the following commands to retrieve metadata and query metrics. - + -Use the `dbt sl` prefix before the command name to execute them in dbt Cloud. For example, to list all metrics, run `dbt sl list metrics`. +You can use the `dbt sl` prefix before the command name to execute them in the dbt Cloud CLI. For example, to list all metrics, run `dbt sl list metrics`. - [`list`](#list) — Retrieves metadata values. - [`list metrics`](#list-metrics) — Lists metrics with dimensions. - [`list dimensions`](#list) — Lists unique dimensions for metrics. - [`list dimension-values`](#list-dimension-values) — List dimensions with metrics. - [`list entities`](#list-entities) — Lists all unique entities. -- [`query`](#query) — Query metrics and dimensions you want to see in the command line interface. Refer to [query examples](#query-examples) to help you get started. +- [`query`](#query) — Query metrics, saved queries, and dimensions you want to see in the command line interface. Refer to [query examples](#query-examples) to help you get started. + ## Querying the API for metric values To query metric values, here are the following parameters that are available. Your query must have _either_ a `metric` **or** a `group_by` parameter to be valid. -| Parameter | Description | Example | +| Parameter |
Description
|
Example
| | --------- | -----------| ------------ | | `metrics` | The metric name as defined in your dbt metric configuration | `metrics=['revenue']` | | `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']` | From f588dca2f7d96e3f264d4bbfaba9d065752816b2 Mon Sep 17 00:00:00 2001 From: mirnawong1 Date: Tue, 30 Jan 2024 10:34:30 +0000 Subject: [PATCH 5/5] tweak --- website/docs/docs/dbt-cloud-apis/sl-jdbc.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/dbt-cloud-apis/sl-jdbc.md b/website/docs/docs/dbt-cloud-apis/sl-jdbc.md index 7ef7805bca4..4727fcdbd21 100644 --- a/website/docs/docs/dbt-cloud-apis/sl-jdbc.md +++ b/website/docs/docs/dbt-cloud-apis/sl-jdbc.md @@ -62,7 +62,7 @@ jdbc:arrow-flight-sql://semantic-layer.cloud.getdbt.com:443?&environmentId=20233 The Semantic Layer JDBC API has built-in metadata calls which can provide a user with information about their metrics and dimensions. -The following toggles provide fetching examples and metadata commands: +Expand the following toggles for examples and metadata commands: