Skip to content

Commit

Permalink
add new command (#5855)
Browse files Browse the repository at this point in the history
add info on new command (`dbt sl export-all`) which allows you to run
exports for multiple saved queries.

slack thread here:
https://dbt-labs.slack.com/archives/C051TUB7S9W/p1721667623352519

---------

Co-authored-by: Matt Shaver <[email protected]>
  • Loading branch information
mirnawong1 and matthewshaver authored Jul 30, 2024
1 parent 228eb94 commit 311bf14
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 7 deletions.
29 changes: 26 additions & 3 deletions website/docs/docs/build/metricflow-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ MetricFlow provides the following commands to retrieve metadata and query metric
<Tabs>
<TabItem value="cloud" label="Commands for dbt Cloud CLI">

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`.
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`. For a complete list of the MetricFlow commands and flags, run the `dbt sl --help` command in your terminal.

- [`list`](#list) &mdash; Retrieves metadata values.
- [`list metrics`](#list-metrics) &mdash; Lists metrics with dimensions.
Expand All @@ -76,6 +76,9 @@ You can use the `dbt sl` prefix before the command name to execute them in the d
- [`list entities`](#list-entities) &mdash; Lists all unique entities.
- [`list saved queries`](#list-saved-queries) &mdash; Lists available saved queries. Use the `--show-exports` flag to display each export listed under a saved query.
- [`query`](#query) &mdash; 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.
- [`export`](#export) &mdash; Runs exports for a singular saved query for testing and generating exports in your development environment. You can also use the `--select` flag to specify particular exports from a saved query.
- [`export-all`](#export-all) &mdash; Runs exports for multiple saved queries at once, saving time and effort.


<!--below commands aren't supported in dbt cloud yet
- [`validate-configs`](#validate-configs) &mdash; Validates semantic model configurations.
Expand Down Expand Up @@ -152,7 +155,7 @@ Options:
--help Show this message and exit.
```

## List dimension-values
### List dimension-values

This command lists all dimension values with the corresponding metric:

Expand Down Expand Up @@ -385,7 +388,6 @@ mf query --metrics order_total --group-by metric_time,is_food_order # In dbt Cor
</TabItem>
<TabItem value="eg3" label="Order/limit">
You can add order and limit functions to filter and present the data in a readable format. The following query limits the data set to 10 records and orders them by `metric_time`, descending. Note that using the `-` prefix will sort the query in descending order. Without the `-` prefix sorts the query in ascending order.
Expand Down Expand Up @@ -580,6 +582,27 @@ dbt sl query --metrics revenue --group-by metric_time__month # In dbt Cloud
mf query --metrics revenue --group-by metric_time__month # In dbt Core
```
### Export
Run [exports for a specific saved query](/docs/use-dbt-semantic-layer/exports#exports-for-single-saved-query). Use this command to test and generate exports in your development environment. You can also use the `--select` flag to specify particular exports from a saved query. Refer to [exports in development](/docs/use-dbt-semantic-layer/exports#exports-in-development) for more info.
Export is available in dbt Cloud.
```bash
dbt sl export
```
### Export-all
Run [exports for multiple saved queries](/docs/use-dbt-semantic-layer/exports#exports-for-multiple-saved-queries) at once. This command provides a convenient way to manage and execute exports for several queries simultaneously, saving time and effort. Refer to [exports in development](/docs/use-dbt-semantic-layer/exports#exports-in-development) for more info.
Export is available in dbt Cloud.
```bash
dbt sl export-all
```
## FAQs
<detailsToggle alt_header="How can I add a dimension filter to a where filter?">
Expand Down
39 changes: 35 additions & 4 deletions website/docs/docs/use-dbt-semantic-layer/exports.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,17 @@ There are two ways to run an export:

## Exports in development

You can run an export in your development environment using your development credentials if you want to test the output of the export before production. You can use the following command to run exports in the dbt Cloud CLI:
You can run an export in your development environment using your development credentials if you want to test the output of the export before production.

This section explains the different commands and options available to run exports in development.

- Use the [`dbt sl export` command](#exports-for-single-saved-query) to test and generate exports in your development environment for a singular saved query. You can also use the `--select` flag to specify particular exports from a saved query.

- Use the [`dbt sl export-all` command](#exports-for-multiple-saved-queries) to run exports for multiple saved queries at once. This command provides a convenient way to manage and execute exports for several queries simultaneously, saving time and effort.

### Exports for single saved query

Use the following command to run exports in the dbt Cloud CLI:

```bash
dbt sl export
Expand All @@ -78,13 +88,11 @@ The following table lists the options for `dbt sl export` command, using the `--

You can also run any export defined for the saved query and write the table or view in your development environment. Refer to the following command example and output:

#### Example

```bash
dbt sl export --saved-query sq_name
```

#### Output
The output would look something like this:

```bash
Polling for export status - query_id: 2c1W6M6qGklo1LR4QqzsH7ASGFs..
Expand Down Expand Up @@ -119,6 +127,29 @@ dbt sl export --saved-query sq_number1 --export-as table --alias new_export
```
</details>

### Exports for multiple saved queries

Use the command, `dbt sl export-all`, to run exports for multiple saved queries at once. This is different from the `dbt sl export` command, which only runs exports for a singular saved query. For example, to run exports for multiple saved queries, you can use:

```bash
dbt sl export-all
```

The output would look something like this:

```bash
Exports completed:
- Created TABLE at `DBT_SL_TEST.new_customer_orders`
- Created VIEW at `DBT_SL_TEST.new_customer_orders_export_alias`
- Created TABLE at `DBT_SL_TEST.order_data_key_metrics`
- Created TABLE at `DBT_SL_TEST.weekly_revenue`

Polling completed
```

The command `dbt sl export-all` provides the flexibility to manage multiple exports in a single command.


## Exports in production

Enabling and executing exports in dbt Cloud optimizes data workflows and ensures real-time data access. It enhances efficiency and governance for smarter decisions.
Expand Down

0 comments on commit 311bf14

Please sign in to comment.