@@ -6,76 +6,32 @@ subCategory: Advanced
66menuOrder : 35
77---
88
9- < InfoBox >
9+ You can leverage Cube on top of dbt models by pointing cubes to dbt models in your database.
1010
11- This functionality only works with models written in JavaScript, not YAML.
11+ < CodeTabs >
1212
13- </InfoBox >
14-
15- Cube's metrics layer is able to read metrics definitions from [ dbt] [ dbt ] via the
16- [ Metadata API] [ dbt-docs-metadata-api ] and translate them into an equivalent Cube
17- data model.
18-
19- ## Connect dbt Core to Cube
20-
21- This can be done through reading the ` dbt-project.yml ` file.
22-
23- ``` javascript
24- import dbt from ' @cubejs-backend/dbt-schema-extension' ;
25-
26- asyncModule (async () => {
27- // `/dbt` is the path to a folder containing `dbt-project.yml`
28- await dbt .loadMetricCubesFromDbtProject (' /dbt' );
29- });
30- ```
31-
32- ## Connect dbt Cloud to Cube
33-
34- Create a ` config.js ` file as a sibling to the ` model/ ` folder in your Cube
35- project:
36-
37- ``` javascript
38- exports .dbtJobId = 65806 ;
39- exports .dbtApiKey = ' YOUR_KEY_HERE' ;
13+ ``` yaml
14+ cubes :
15+ - name : orders
16+ - sql_table : my_dbt_schema.my_dbt_orders_model
4017` ` `
4118
42- Create a file called ` dbt.js ` in the ` model/ ` folder and enter the following
43- code snippet:
44-
4519` ` ` javascript
46- import dbt from ' @cubejs-backend/dbt-schema-extension' ;
47- import { dbtJobId , dbtApiKey } from ' ../config' ;
48-
49- asyncModule (async () => {
50- await dbt .loadMetricCubesFromDbtCloud (dbtJobId, dbtApiKey);
20+ cube(`orders`, {
21+ sql_table : ` my_dbt_schema.my_dbt_orders_model`
5122});
5223```
5324
54- You can then define cubes under the above snippet:
25+ </ CodeTabs >
5526
56- ``` javascript
57- import dbt from ' @cubejs-backend/dbt-schema-extension' ;
58- import { dbtJobId , dbtApiKey } from ' ../config' ;
27+ ## Using dbt_metrics
5928
60- asyncModule (async () => {
61- await dbt .loadMetricCubesFromDbtCloud (dbtJobId, dbtApiKey);
62- });
29+ <WarningBox >
6330
64- cube (' GithubCommitStatsCommitsCached' , {
65- extends: GithubCommitStatsCommits,
31+ Previously, Cube provided the ` @cubejs-backend/dbt-schema-extension ` package to read metric definitions from dbt.
32+ Due to the [ change in direction] [ dbt-deprecation ] at dbt, we have deprecated this package as well.
33+ When a new ` dbt_metrics ` package becomes available, we will update and reintroduce our integration.
6634
67- preAggregations: {
68- main: {
69- measures: [commitsCount],
70- dimensions: [authorDomain, authorName],
71- timeDimension: timestamp,
72- granularity: ' day' ,
73- partitionGranularity: ' year' ,
74- },
75- },
76- });
77- ```
35+ </WarningBox >
7836
79- [ dbt ] : https://www.getdbt.com/
80- [ dbt-docs-metadata-api] :
81- https://docs.getdbt.com/docs/dbt-cloud-apis/metadata-api
37+ [ dbt-deprecation ] : https://docs.getdbt.com/blog/deprecating-dbt-metrics
0 commit comments