Skip to content

Commit

Permalink
Merge branch 'current' into MUL-1181-docs-update-migration-guide-docu…
Browse files Browse the repository at this point in the history
…mentation-to-reflect-approval-mechanism
  • Loading branch information
matthewshaver authored Oct 23, 2024
2 parents 9904371 + b044d52 commit 4f97721
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
8 changes: 4 additions & 4 deletions website/docs/docs/build/measures.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ semantic_models:
description: A record of every transaction that takes place. Carts are considered multiple transactions for each SKU.
model: ref('schema.transactions')
defaults:
agg_time_dimension: metric_time
agg_time_dimension: transaction_date
# --- entities ---
entities:
Expand Down Expand Up @@ -167,7 +167,7 @@ semantic_models:
# --- dimensions ---
dimensions:
- name: metric_time
- name: transaction_date
type: time
expr: date_trunc('day', ts) # expr refers to underlying column ts
type_params:
Expand Down Expand Up @@ -204,15 +204,15 @@ semantic_models:
description: A subscription table with one row per date for each active user and their subscription plans.
model: ref('your_schema.subscription_table')
defaults:
agg_time_dimension: metric_time
agg_time_dimension: subscription_date
entities:
- name: user_id
type: foreign
primary_entity: subscription_table
dimensions:
- name: metric_time
- name: subscription_date
type: time
expr: date_transaction
type_params:
Expand Down
12 changes: 12 additions & 0 deletions website/docs/docs/build/metricflow-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,22 @@ For dbt Cloud CLI users, MetricFlow commands are embedded in the dbt Cloud CLI,

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:

<VersionBlock lastVersion="1.7">

1. Create or activate your virtual environment `python -m venv venv`
2. Run `pip install dbt-metricflow`
* You can install MetricFlow using PyPI as an extension of your dbt adapter in the command line. To install the adapter, run `python -m pip install "dbt-metricflow[your_adapter_name]"` and add the adapter name at the end of the command. For example, for a Snowflake adapter run `python -m pip install "dbt-metricflow[snowflake]"`

</VersionBlock>

<VersionBlock firstVersion="1.8">

1. Create or activate your virtual environment `python -m venv venv`
2. Run `pip install dbt-metricflow`
* You can install MetricFlow using PyPI as an extension of your dbt adapter in the command line. To install the adapter, run `python -m pip install "dbt-metricflow[adapter_package_name]"` and add the adapter name at the end of the command. For example, for a Snowflake adapter run `python -m pip install "dbt-metricflow[dbt-snowflake]"`

</VersionBlock>

**Note**, you'll need to manage versioning between dbt Core, your adapter, and MetricFlow.

Something to note, MetricFlow `mf` commands return an error if you have a Metafont latex package installed. To run `mf` commands, uninstall the package.
Expand Down
15 changes: 14 additions & 1 deletion website/docs/docs/build/metricflow-time-spine.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,22 @@ For example, if you use a custom calendar in your organization, such as a fiscal

- This is useful for calculating metrics based on a custom calendar, such as fiscal quarters or weeks.
- Use the `custom_granularities` key to define a non-standard time period for querying data, such as a `retail_month` or `fiscal_week`, instead of standard options like `day`, `month`, or `year`.
- Ensure the the `standard_granularity_column` is a date time type.
- This feature provides more control over how time-based metrics are calculated.

<Expandable alt_header="Data types and time zone considerations">

When working with custom calendars in MetricFlow, it's important to ensure:

- Consistent data types &mdash; Both your dimension column and the time spine column should use the same data type to allow accurate comparisons. Functions like `DATE_TRUNC` don't change the data type of the input in some databases (like Snowflake). Using different data types can lead to mismatches and inaccurate results.

We recommend using `DATETIME` or `TIMESTAMP` data types for your time dimensions and time spine, as they support all granularities. The `DATE` data type may not support smaller granularities like hours or minutes.

- Time zones &mdash; MetricFlow currently doesn't perform any timezone manipulation. When working with timezone-aware data, inconsistent time zones may lead to unexpected results during aggregations and comparisons.

For example, if your time spine column is `TIMESTAMP` type and your dimension column is `DATE` type, comparisons between these columns might not work as intended. To fix this, convert your `DATE` column to `TIMESTAMP`, or make sure both columns are the same data type.

</Expandable>

### Add custom granularities

To add custom granularities, the Semantic Layer supports custom calendar configurations that allow users to query data using non-standard time periods like `fiscal_year` or `retail_month`. You can define these custom granularities (all lowercased) by modifying your model's YAML configuration like this:
Expand Down

0 comments on commit 4f97721

Please sign in to comment.