provides the `%%dbt` cell magic for creating models and analyses and `%dbtconfig` to configure the _dbt project dir_ and _dbt profiles dir_
clear_cache
(project_dir
=None
)
Removes all existing nbdbt cache entries
config_dbt
(line
)
::
%config_dbt [-d PROFILE] [-p PROJECT] [-n NOTEBOOK] [-l LIMIT]
optional arguments:
-d PROFILE, --profile PROFILE
If provided, override the dbt profiles directory
(default: '~/.dbt')
-p PROJECT, --project PROJECT
Set the dbt project directory
-n NOTEBOOK, --notebook NOTEBOOK
Set the notebook path
-l LIMIT, --limit LIMIT
Set the default sql row limit
DbtMagicObject
(raw_sql
:str
, file
:str
, limit
:int
, project_dir
:Union
[str
, Path
, NoneType
]=None
, notebook_name
:Optional
[str
]=None
, profile_dir
:Union
[str
, Path
, NoneType
]=None
)
|
Type |
Default |
Details |
raw_sql |
str |
|
sql string |
file |
str |
|
path to sql file (relative to dbt project dir) |
limit |
int |
|
limit row default |
project_dir |
typing.Union[str, pathlib.Path, NoneType] |
None |
dbt project dir |
notebook_name |
typing.Union[str, NoneType] |
None |
name of notebook |
profile_dir |
typing.Union[str, pathlib.Path, NoneType] |
None |
dbt profiles dir |
DbtMagicObject.ref
(limit
=-1
)
write_dbt
(line
, cell
)
::
%write_dbt [-a ASSIGN] [-p PROJECT] [-n NOTEBOOK] [-l LIMIT] file
positional arguments:
file file path to write to
optional arguments:
-a ASSIGN, --assign ASSIGN
If provided, save the output to this variable instead
of displaying it.
-p PROJECT, --project PROJECT
dbt project directory
-n NOTEBOOK, --notebook NOTEBOOK
notebook source file
-l LIMIT, --limit LIMIT
sql limit default
<__main__.DbtMagicObject at 0x7efe6b4cb190>
The ref
method on DbtMagicObject
allows us to run the query and save the results into a dataframe.
|
table_catalog |
table_schema |
table_name |
column_name |
ordinal_position |
is_nullable |
data_type |
is_generated |
generation_expression |
is_stored |
is_hidden |
is_updatable |
is_system_defined |
is_partitioning_column |
clustering_ordinal_position |
collation_name |
0 |
sample-dbt-learn-project |
jaffle_shop |
my_third_model |
id |
1 |
YES |
INT64 |
NEVER |
None |
None |
NO |
None |
NO |
NO |
NaN |
NULL |
|
table_catalog |
table_schema |
table_name |
column_name |
ordinal_position |
is_nullable |
data_type |
is_generated |
generation_expression |
is_stored |
is_hidden |
is_updatable |
is_system_defined |
is_partitioning_column |
clustering_ordinal_position |
collation_name |
0 |
bigquery-public-data |
ml_datasets |
iris |
sepal_length |
1 |
YES |
FLOAT64 |
NEVER |
None |
None |
NO |
None |
NO |
NO |
NaN |
NULL |
1 |
bigquery-public-data |
ml_datasets |
iris |
sepal_width |
2 |
YES |
FLOAT64 |
NEVER |
None |
None |
NO |
None |
NO |
NO |
NaN |
NULL |
2 |
bigquery-public-data |
ml_datasets |
iris |
petal_length |
3 |
YES |
FLOAT64 |
NEVER |
None |
None |
NO |
None |
NO |
NO |
NaN |
NULL |
3 |
bigquery-public-data |
ml_datasets |
iris |
petal_width |
4 |
YES |
FLOAT64 |
NEVER |
None |
None |
NO |
None |
NO |
NO |
NaN |
NULL |
4 |
bigquery-public-data |
ml_datasets |
iris |
species |
5 |
YES |
STRING |
NEVER |
None |
None |
NO |
None |
NO |
NO |
NaN |
NULL |