
dbt Core 1.9で動いていた既存リポジトリをdbt Fusion × dbt公式VS Code拡張機能で動かしてみた
さがらです。
5月末に発表されたdbt Fusionについて、dbt Core 1.9で動いていた既存リポジトリをdbt Fusion × dbt公式VS Code拡張機能で動かしてみました。その内容について本記事でまとめてみます。
※dbt Fusionは2025/7/8時点、Beta機能となりますのでご注意ください。
やること
以下のdbt Cloudで動いていたリポジトリのコミットハッシュ「d1b0f46」時点の内容を元に、ローカルでクローンしてdbt Fusionを試してみます。
※dbt Cloudで動かしていたリポジトリのため、ローカルにクローン後にprofiles.yml
を追加・編集しています。この手順については割愛します。
参考ドキュメント・ブログ
dbt Fusionへのアップデートに関しては以下のドキュメントに記載がありますので、この内容を参考に進めていきます。
dbt FusionはまだBeta版ですので、どの機能・コマンドが対応しているかは以下のドキュメントから確認が必要です。2025/7/8時点では個人的に以下の点が気になりました。
- Exposuresが未対応
dbt clone
コマンドが未対応- microbatchのIncremental Strategyに未対応
- custom materializationsに未対応
- contractsなどのModel governance機能に未対応
- dbt docs generateによる静的HTMLサイトのドキュメント生成に未対応(GAまでにサポート予定)
- SQLFluffによるリンティングに未対応(将来的にはリンティング自体をFusionに組み込む予定とのこと)
- Semantic Layerの開発及び
saved_query
に未対応
また、先行して検証された方のブログも以下に記載しておきます。
検証環境
- OS
- Ubuntu 24.04 LTS (WSL2で動作)
- Python関係
- uvでPython関係のバージョン・パッケージ管理
- Python 3.12
- 接続先
- Snowflake
dbt Core 1.10でエラー・警告がないか確認し対処
こちらのドキュメントにもあるように、dbt Fusionへのアップデート前にdbt Core 1.10までのすべての非推奨項目を解消しておく必要があるため、dbt Core 1.10にアップデート後にdbt parse
を実行してみます。
私の場合は下記の結果となりました。以下にそれぞれの警告の対策を記します。
dbt parse
06:58:10 Running with dbt=1.10.3
06:58:10 Registered adapter: snowflake=1.9.4
06:58:10 Unable to do partial parsing because saved manifest not found. Starting full parse.
06:58:12 [WARNING][PropertyMovedToConfigDeprecation]: Deprecated functionality
Found `freshness` as a top-level property of `ecom` in file
`models/staging/__sources.yml`. The `freshness` top-level property should be
moved into the `config` of `ecom`.
06:58:12 [WARNING]: Time spines without YAML configuration are in the process of
deprecation. Please add YAML configuration for your 'metricflow_time_spine'
model. See documentation on MetricFlow time spines:
https://docs.getdbt.com/docs/build/metricflow-time-spine and behavior change
documentation:
https://docs.getdbt.com/reference/global-configs/behavior-changes.
06:58:12 Performance info: /home/sagara/develop/jaffle-shop-japanese/target/perf_info.json
06:58:13 [WARNING][DeprecationsSummary]: Deprecated functionality
Summary of encountered deprecations:
- PropertyMovedToConfigDeprecation: 1 occurrence
- MFTimespineWithoutYamlConfigurationDeprecation: 1 occurrence
To see all deprecation instances instead of just the first occurrence of each,
run command again with the `--show-all-deprecations` flag. You may also need to
run with `--no-partial-parse` as some deprecations are only encountered during
parsing.
PropertyMovedToConfigDeprecation
この対策としては、「freshness:
をconfig
ブロックの中に移す」必要があります。
- Before
version: 2
sources:
- name: ecom
schema: raw
description: E-commerce data for the Jaffle Shop
freshness:
warn_after:
count: 24
period: hour
- After
version: 2
sources:
- name: ecom
schema: raw
description: E-commerce data for the Jaffle Shop
config:
freshness:
warn_after:
count: 24
period: hour
MFTimespineWithoutYamlConfigurationDeprecation
この対策としては、MetricFlowのtime spineについて、sqlファイルだけでなくyamlファイルでメタデータを付与する必要があります。
-
Before:sqlファイルだけで定義(
jaffle-shop-japanese/models/marts/metricflow_time_spine.sql
) -
After:sqlファイルに加えて、yamlファイルも追加で作成(
jaffle-shop-japanese/models/marts/metricflow_time_spine.yml
)
version: 2
models:
- name: metricflow_time_spine
description: "Canonical daily time spine for MetricFlow demos"
config:
materialized: table
time_spine:
standard_granularity_column: date_day
columns:
- name: date_day
description: "Calendar date at day grain"
granularity: day
エラー・警告が出なくなったかを確認
上記の対策を行った後、dbt parse --no-partial-parse
を実行します。--no-partial-parse
を入れることで差分parseとならず、project全体に対して再度parse処理を行うことが出来ます。
下記のように表示されれば、エラー・警告がなくなったということになります!
$ dbt parse --no-partial-parse
08:19:19 Running with dbt=1.10.3
08:19:19 Registered adapter: snowflake=1.9.4
08:19:22 Performance info: /home/sagara/develop/jaffle-shop-japanese/target/perf_info.json
dbt Fusionのインストール
以下のコマンドを実行して、dbt Fusionをインストールします。うまく行けば下図のように表示されると思います。
curl -fsSL https://public.cdn.getdbt.com/fs/install/install.sh | sh -s -- --update
シェルをリロードしてdbtf
を実行して、下図のように表示されればインストールは無事に完了です!
source ~/.bashrc
dbtf
$ dbtf
dbt-fusion 2.0.0-beta.34: A fast and enriched dbt compiler and runner
Usage: dbt [OPTIONS] <COMMAND>
Commands:
init Initialize a new dbt project
deps Install package dependencies
parse Parse models
list List selected nodes
ls List selected nodes (alias for list)
compile Compile models
run Run models
run-operation Run the named macro with any supplied arguments
test Test models
seed Seed models
snapshot Run snapshot models
show Show a preview of the selected nodes
build Build seeds, models and tests
clean Remove target directories
source Run sources subcommands
system dbt installation configuration
man Create reference documentation
debug Profile connection debugging
help Print this message or the help of the given subcommand(s)
Options:
-t, --target <TARGET>
The target to execute [env: DBT_TARGET=]
--project-dir <PROJECT_DIR>
The directory to load the dbt project from [env: DBT_PROJECT_DIR=]
--profile <PROFILE>
The profile to use [env: DBT_PROFILE=]
--profiles-dir <PROFILES_DIR>
The directory to load the profiles from [env: DBT_PROFILES_DIR=]
--packages-install-path <PACKAGES_INSTALL_PATH>
The directory to install packages [env: DBT_PACKAGES_INSTALL_PATH=]
--target-path <TARGET_PATH>
The output directory for all produced assets [env: DBT_TARGET_PATH=]
--vars <VARS>
Supply var bindings in yml format e.g. '{key: value}' or as separate key: value pairs
-s, --select <SELECT>...
Select nodes to run
--exclude <EXCLUDE>...
Select nodes to exclude
--selector <SELECTOR>
The name of the yml defined selector to use
--indirect-selection <INDIRECT_SELECTION>
Choose which tests to select adjacent to resources: eager (most inclusive), cautious (most exclusive), buildable (inbetween) or empty [env: DBT_INDIRECT_SELECTION=]
-q, --quiet
Suppress all non-error logging to stdout. Does not affect {{ print() }} macro calls [env: DBT_QUIET=]
--threads <THREADS>
The number of threads to use [Run with --threads 0 to use max_cpu [default: max_cpu]]
--single-threaded
Overrides threads [env: DBT_SINGLE_THREADED=]
--write-json
Write JSON artifacts to disk [env: DBT_WRITE_JSON=]. Use --no-write-json to suppress writing JSON artifacts [env: DBT_WRITE_JSON=]
--defer
[env: DBT_DEFER=]
--state <STATE>
Unless overridden, use this state directory for both state comparison and deferral [env: DBT_STATE=]
--log-path <LOG_PATH>
Set 'log-path' for the current run, overriding 'DBT_LOG_PATH' [env: DBT_LOG_PATH=]
--log-format <LOG_FORMAT>
Set logging format; use --log-format-file to override [env: DBT_LOG_FORMAT=] [default: text] [possible values: text, json, fancy]
--log-format-file <LOG_FORMAT_FILE>
Set log file format, overriding the default and --log-format setting [env: DBT_LOG_FORMAT_FILE=] [possible values: text, json, fancy]
--log-level <LOG_LEVEL>
Set minimum severity for console/log file; use --log-level-file to set log file severity separately [env: DBT_LOG_LEVEL=]
--log-level-file <LOG_LEVEL_FILE>
Set minimum log file severity, overriding the default and --log-level setting [env: DBT_LOG_LEVEL_FILE=]
--send-anonymous-usage-stats
[env: DBT_SEND_ANONYMOUS_USAGE_STATS=]
--show [<SHOW>...]
Show produced artifacts [default: 'progress']
[possible values: progress, progressrun, progressparse, progressrender, progressanalyze, inputfiles, manifest, schedule, nodes, instructions, sourcedschemas, schema, data, stats, lineage, all, none, rawlineage, taskgraph]
-h, --help
Print help
-V, --version
Print version
Use `dbt <COMMAND> --help` to learn more about the options for each command.
試しに、dbtf debug
コマンドを実行すると下記のように表示されました。(一部マスキングしています。)
$ dbtf debug
dbt-fusion 2.0.0-beta.34
Loading ~/.dbt/profiles.yml
Debugging profile: dev
Debugging dbt version: 2.0.0-beta.34
Debugging platform: linux x86_64 (unix)
Debugging adapter type: snowflake (remote)
Debugging dependencies:
git: OK
Debugging connection:
"role": "sagara_admin_role",
"schema": "dbt_ssagara",
"account": "xxxxxxxxxx.ap-northeast-1.aws",
"warehouse": "sagara_dbt_dev_wh",
"database": "sagara_jaffle_shop_japanese",
"user": "xxxxxxxxx"
Debugging connection test: OK
Debugged All checks passed!
Finished 'debug' target 'dev' in 2s 125ms 455us 684ns
dbt Fusionに対応したdbt Labs公式のVS Code拡張機能をインストール
dbt Fusionのリリースに合わせて公式からもVS Codeの拡張機能が提供されていますので、インストールしてみます。
VS Codeを開き、dbt
など検索を行い、下図の拡張機能をインストールします。
インストールすると、右下に下図のポップアップが出てくるため、Register Now
で対応します。この後に一度VS Codeを再起動すれば、拡張機能のインストールも完了です。
VS Code拡張機能を使って出来ることを確認してみる
公式のVS Code拡張機能を使って出来ることを確認してみます。
※すべての機能は紹介しません、詳細はVS Code拡張機能の公式ページをご確認ください。
モデルレベルのリネージ
任意のモデルを開くと、モデルレベルのリネージを表示できます。
右下のアイコンを変更することで、Resource typeを表示するか、Materializationを表示するか、切り替える事が可能です。
カラムレベルのリネージ
エディター上で右クリックを行いShow Column Lineage
を押し、任意のカラムを選択します。
すると、カラムレベルのリネージが表示されました!Rename
やTransformation
が行われているかどうかがわかるのもすごいですね…!
また、エディター上で右クリックを行いShow Column Lineage
を押したあとに*
を選択すると、開いているモデルの全カラムについて、カラムレベルのリネージが表示されます。
入力候補の自動補完
エディター上で入力を進めると、想定されるカラム名の候補が自動で表示されます。
orders.
のようにテーブル名までをいれると、orders
に含まれるカラムだけが候補として表示されます。
DWH/DBにクエリを発行せずにクエリエラーを検知
例えば、テーブル名を存在しないorder
に変更してみると、下図のようにエラーを自動で検知してくれます。
テーブルやカラムの定義元へのリンク
例えば、ref関数で定義しているところに右クリックを押して定義へ移動
を押すと、対象のModelファイルの定義にリンクします。
また、カラム名に対してこの定義へ移動
を行うと、そのカラムが定義されている箇所がselect *
であってもリンクします!これは凄い…
モデル名やカラム名を変更した際に自動で影響があるファイルの修正(リファクタリング)
例えば、stg_customers.sql
でカラム名をcustomer_id_id
と変更したいと考えます。右クリックを押し、シンボルの名前変更
を選択します。
その後、カラム名をcustomer_id_id
と入力し、Enterを押します。
すると、後続のcustomers.sql
において、customer_id
を参照するところがcustomer_id_id
に変更されていました!
CTEのプレビュー
SQLエディター上にあるPreview CTE
を押すと、そのCTEについてクエリを実行して結果を見ることが出来ます。
最後に
dbt Core 1.9で動いていた既存リポジトリをdbt Fusion × dbt公式VS Code拡張機能で動かしてみました。
想像以上にdbt Fusionの動作が早く、クエリエラーの自動検知、事前情報として得ていたカラムレベルリネージ、CTEのプレビュー、などの機能も違和感なく使うことができました。特に、「右クリックを押して定義へ移動
」と自動リファクタリング機能に驚きましたね…これは本当に便利ですね。
一方で、dbt FusionはまだBeta版で使用できない機能も多くありますので、その点だけご注意ください。ただ、Beta版でここまでの魅力を感じるdbt Fusionの今後が更に楽しみになりました!!