The dbt converter is a CLI tool to convert code for usage in a dbt Project. Currently, this tool is able help Upgrade to dbt v1.6 spec and Migrate from LookML.
pip install dbt-metrics-converter
This simplifies the process of migrating from the metrics spec supported in dbt v1.5 and earlier to the metrics specification supported in dbt ≥v1.6.
- Navigate to the root of your dbt project.
pip install dbt-metrics-converter
. Note that the converter requires dbt-core==1.5. You may need to update the version range for the dbt_metrics package.- Run
dbtc convert-metrics
. The converter assumes you are at the root of your dbt project. Optionally, you can pass the project path--dbt-project-path path/to/dbt_project
. NOTE: All metrics must have a timestamp for the upgrade to run. If your metrics do not have a timestamp, add one before running the converter. - Semantic models and metrics files will be created in the
semantic_models
andmetrics
directories. Move these folders into your model path. - Delete the
metrics
package, move the old metrics configs out of your model path, or delete them.
- Upgrade to dbt v1.6, and
pip install dbt-metricflow
- Remove the old metrics package from your
dbt_packages
and rundbt clean && dbt deps
. - Run
dbt parse
to generate a semantic manifest - View the metrics in your dbt project by running
mf list metrics
- Run
mf validate-configs —skip-dw
to validate metrics configs. - To run a test query, run
mf query --metrics <metric_name>
Refer to Querying the API for metric metadata to access the built-in metadata calls to query metrics and dimensions using the dbt Semantic Layer API.
- Some packages, like fivetran/ad_reporting have metrics defined in them using the v1.5 spec, this may cause an error if you try to run your project after upgrading to v1.6
- Derived metrics are not supported. These will need to be ported manually.
- Make sure to delete any calls of
metrics.calculate
ormetrics.develop
after you've run the conversion script they won’t work without the dbt_metrics package - Dimension references in filters require you to reference the primary entity i.e {{Dimension('primary_entity__dimension_name')}} However, primary entities we're not part of the old metrics spec so will need to be specified manually. You can learn about how to add entities to semantic models here
- Non-standard metric methods abbreviations will cause the script to fail. In particular, abbreviating
average
asavg
will cause the following output at the console:
Performance info: target/perf_info.json
'avg'
- Currently supported
method -> measure
types:count
count_distinct
sum
average
min
max
median
If you are using the dbt-databricks
connector in your project, you will need to temporarily change to the dbt-spark
connector, in order to resolve some incompatible dependency version conflicts.
Refer to the dbt-spark
adapter documentation for more info.
In order to complete that conversion, you will need to:
- Open your
~/.dbt/profiles.yml
file. - Under each adapter:
- Change
type: databricks
totype:spark
- On the line after
type
add a key:method: odbc
Your final config for each adapter should look like this:
your_profile_name:
target: dev
outputs:
dev:
type: spark
method: odbc
driver: [path/to/driver]
schema: [database/schema name]
host: [yourorg.sparkhost.com]
organization: [org id] # Azure Databricks only
token: [abc123]
# one of:
endpoint: [endpoint id]
cluster: [cluster id]
# optional
port: [port] # default 443
user: [user]
server_side_parameters:
"spark.driver.memory": "4g"
- Once your conversion is complete, we recommend changing back to the
dbt-databricks
adapter, including reverting all changes to~/.dbt/profiles.yml
.
Use these instructions to migrate from LookML to the dbt Semantic Layer. Currently, this tool can only help with the migration and leaves many manual steps to the user to complete themselves.
- Navigate to the root of your LookML project.
pip install dbt-metrics-converter
. Note that the converter requires dbt-core==1.5.- Run
dbtc convert-lookml
. The converter assumes you are at the root of your LookML project. Optionally, you can pass the project path--lookml-project-path path/to/dbt_project
. - Semantic models and metrics files will be created in the
semantic_models
directory.