Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Modern Data Stack初心者がSnowflake DCRの構築をした話
Search
Makoto Shinohara
November 12, 2023
Technology
540
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Modern Data Stack初心者がSnowflake DCRの構築をした話
Makoto Shinohara
November 12, 2023
More Decks by Makoto Shinohara
See All by Makoto Shinohara
ドキュメントサイト生成フレームワークのすゝめ
synohara
0
150
Event-table Service Metricsについてまとめてみた
synohara
0
160
Snowake DCRをTerraformで構築したお話/Snowake DCRの未来
synohara
0
220
Other Decks in Technology
See All in Technology
Metadata - Section 1: HTML Basics
mohab1
0
120
Benchmarking Disaggregated Serving on vLLM + Dynamo with a Real Coding-Agent Workload
nttcom
1
200
会社紹介資料 / Sansan Company Profile
sansan33
PRO
31
430k
Kiro Crewをはじめよう
kizawa2020
1
160
DBについての基礎説明(MySQL編) - コロプラ 2026年度 新卒研修
colopl
0
130
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
190
パッチ更新でterraform initが落ちた日
grimoh
1
140
事業成長とデータ活用を止めないためのマネジメントへ挑戦
hiracky16
0
400
脆弱性診断って、何をしているの? 〜弱点を見つけて、会社の改善につなげるまで〜
keeg
0
930
CTO Night|NotionのAIエージェントとFDE
kzkhykw1991
0
230
Classmethod Company Deck
satoshi7
1
730
AIにシークレットを見せない、WSL2で安全な開発環境
yazm
0
310
Featured
See All Featured
So, you think you're a good person
axbom
PRO
2
2.2k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
760
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
270
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
310
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
Are puppies a ranking factor?
jonoalderson
2
4.1k
Transcript
2023/11/10 Modern Data Stack初心者が Snowflake DCRの構築をした話 KDDIアジャイル開発センター 開発4部 篠原 誠
自己紹介 KDDIアジャイル開発センター株式会社 データエンジニア 篠原 誠 KDDI株式会社入社後、KDDIアジャイル開発センター株式会社に出向 チャットボット開発や統計化位置情報分析基盤開発、KDDI研究所での対話AIプロジェクト参加などを経て、 現在はデータエンジニアとしてデータクリーンルームの開発に従事 KDDI Agile Development Center
Corporation KDDIアジャイル開発センター 開発4部 1
データクリーンルーム(DCR)とは 個人情報を含んでいるデータを中身の情報は見せずに結合して掛け合わせ分析を行うことができる技術及び それが実現できる環境 SnowflakeのDCRではSnowflakeの各種機能(Data Sharing, Stream/Task, Stored Procedure, Row Access
Policy etc…)を組み合わせて 許可ベースのクエリ実行フレームワークとして実現している KDDI Agile Development Center Corporation KDDIアジャイル開発センター 開発4部 2
Modern Data StackでDCR構築! KDDI Agile Development Center Corporation KDDIアジャイル開発センター 開発4部 3
技術スタック Data Cloud Snowflake Workflow Orchestration Snowflake Task Github Actions
主にdbtの呼び出しに使用 CI/CD Github Actions Transform/Data Modeling dbt Core IaC Terraform KDDI Agile Development Center Corporation KDDIアジャイル開発センター 開発4部 4
Workflow Orchestration データパイプラインの流れ 源泉データは別のSnowflakeアカウントからSecure Data Sharingを利用してシェア 自アカウント内へテーブルの内容をコピー → Snowflake Task
そのテーブルの内容をdbtで加工 → dbt Core on Github Actions (いい感じの絵をAIに作ってもらおうとしたけど失敗) KDDI Agile Development Center Corporation KDDIアジャイル開発センター 開発4部 5
DCR構築へのTerraformの活用 DCR構築を効率化するためにDCR構築の一連の処理をTerraformのModuleにまとめています 1 module "provider_init" { 2 source = "modules/provider_init"
3 ... 4 } 5 module "consumer_init" { 6 source = "modules/consumer_init" 7 ... 8 depends_on = [ 9 module.provider_init 10 ] 11 } 12 module "provider_enable_consumer" { 13 source = "modules/provider_enable_consumer" 14 ... 15 depends_on = [ 16 module.provider_init, 17 module.consumer_init 18 ] 19 } KDDI Agile Development Center Corporation KDDIアジャイル開発センター 開発4部 6
Terraformでクエリテンプレートの管理 DCRではクエリテンプレートをテーブルに登録してそれを使用する テンプレートの登録をSQLで実行すると大変 & 事故の元 Terraformで管理することにした KDDI Agile Development Center
Corporation KDDIアジャイル開発センター 開発4部 7
Terraformでクエリテンプレートの管理 クエリテンプレートの登録を行うSQLファイルを用意 INSERT INTO ${db_name}.TEMPLATES.DCR_TEMPLATES ( party_account, template_name, template, dimensions,
template_type ) VALUES ( '${consumer_acct}', '${template_name}', $$${template}$$, '${dimentions}', 'SQL' ); KDDI Agile Development Center Corporation KDDIアジャイル開発センター 開発4部 8
Terraformでクエリテンプレートの管理 yamlファイルにクエリテンプレートの設定を記述 1 templates: 2 - template_name: customer_overlap 3 template:
| 4 select 5 {% if dimensions %} 6 identifier({{ dimensions[0] }}) 7 {% for dim in dimensions[1:] %} 8 , identifier({{ dim }}) 9 {% endfor %} 10 , {% endif %} 11 count(distinct p.email) as overlap 12 from 13 {{ app_data | sqlsafe }}.cleanroom.provider_customers_vw p, 14 {{ consumer_db | sqlsafe }}.{{ consumer_schema | sqlsafe }}.{{ consumer_table | sqlsafe }} at(time 15 where 16 c.{{ consumer_join_field | sqlsafe }} = p.email 17 ... 18 allowed_columns: 19 - c.petsc.zip 20 - p.status 21 - p.age_band 22 template_type: SQL KDDI Agile Development Center Corporation KDDIアジャイル開発センター 開発4部 9
Terraformでクエリテンプレートの管理 Terraformで読み込む resource "snowsql_exec" "templates" { for_each = { for
i in local.templates : i.template_name => i } create { statements = templatefile("${path.root}/tftpls/insert_templates.sql.tftpl", { db_name = var.source_database_name consumer_acct = var.consumer_account_locator, template_name = each.value.template_name, template = each.value.template, dimentions = join("|", flatten(each.value.allowed_columns)) }) } delete { statements = "DELETE FROM ${var.source_database_name}.TEMPLATES.DCR_TEMPLATES WHERE TEMPLATE_NAME = '${each.value.t } } KDDI Agile Development Center Corporation KDDIアジャイル開発センター 開発4部 10
まとめ Modern Data Stackを駆使してDCRの構築に挑戦しました Terraformを活用して基盤構築を効率化 DCRの構築 クエリテンプレートの管理 Modern Data Stackを活用したDCRの構築は様々な技術を組み合わせた総合格闘技戦
今後もSnowflakeの進化に注目していきます! KDDI Agile Development Center Corporation KDDIアジャイル開発センター 開発4部 11
None