Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SQL実践入門night_LT資料_YASU11552288
Search
Anntoque
January 24, 2018
Programming
570
0
Share
SQL実践入門night_LT資料_YASU11552288
Anntoque
January 24, 2018
More Decks by Anntoque
See All by Anntoque
【試されDATA SAPPORO #1】データ基盤を「育てる」コミュニケーション
anntoque
0
14
【Sapporo Data Pioneers #1 】データのライフサイクルとSapporo Data Pioneersの思いについて
anntoque
1
620
【istyle Data Talk #01】越境できるデータの組織・人材を目指して/ istyle data talk 01 Data Organization
anntoque
1
1.1k
what Azure Synapse
anntoque
0
3.2k
REDASH JOURNEY
anntoque
0
1.5k
データドリブンを提供するサービス Brand Officialのアーキテクチャ / brand official architecture
anntoque
0
1.7k
理想の自分を忘れないために Slack and LINE bot を作った話 / Make Slack API and LINE bot to not forget ideal myself
anntoque
0
930
redash運用アンチパターン
anntoque
0
3.5k
Other Decks in Programming
See All in Programming
20260514_its_the_context_window_stupid.pdf
heita
0
1.1k
WebAssembly を読み込むベストプラクティス 2026年春版 / Best Practices for Loading WebAssembly (Spring 2026)
petamoriken
5
1.1k
関係性から理解する"同一性"の型用語たち
pvcresin
2
250
実践ハーネスエンジニアリング:ステアリングループを実例から読み解く / Practical Harness Engineering: Understanding Steering Loops Through Real-World Examples
nrslib
5
5.7k
Modding RubyKaigi for Myself
yui_knk
0
300
Spec-Driven Development with AI-Agents: From High-Level Requirements to Working Software
antonarhipov
1
180
新規プロダクトを高速で生み出すハーネスエンジニアリング
seanchas116
3
210
Cloudflare で始める Data Platform
ta93abe
0
200
tsserverとは何だったのか_これからどうなるのか
nowaki28
1
240
ふにゃっとしない名前の付け方 〜哲学で茹で上げる、コシのあるソフトウェア設計〜
shimomura
0
120
【ディップ|26年新卒研修資料】TDD実装演習
dip_tech
PRO
0
260
UaaL×Androidアプリのメモリ計測 — Memory Profilerの先へ
rio432
0
160
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Ethics towards AI in product and experience design
skipperchong
2
280
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
Everyday Curiosity
cassininazir
0
210
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Fireside Chat
paigeccino
42
3.9k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
The untapped power of vector embeddings
frankvandijk
2
1.7k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
200
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
550
How to Ace a Technical Interview
jacobian
281
24k
Transcript
SELECT * FROM presto_good_point LIMIT 2 @YASU11552288
LT初めてマンです - 山本 泰毅 (Yamamoto Yasutaka) - 株式会社アイスタイル - データエンジニア
* ビッグデータ分析基盤の構築・運用 * クエラー
DBの選択肢がたくさんの時代 弊社に関わるサービスの DB一覧 RDB - Oracle, SQL server, MySQL, MariaDB,
PostgreSQL etc. NoSQL - Hadoop, BigQuery etc.
異機種のDBをつなげて、SELECTしたいけど… ①DBの機能 - SQL ServerのOpen Query - 1つのSQLの中に複数の記法が混在 - MariaDBのconnect
storage engine - 対応機種が少ない ③VLOOKUP ②クラウドにバッチで全突っ込み - リアルタイム性がない -
Prestoを使うと可読性の高いSQLでつなげれる Prestoとは - 分散型のSQLクエリエンジン (https://prestodb.io/) - インメモリでサクサク - zhicwu/presto -
Docker Hub ※ そのままdocker runして実行すると、 ワーカー名に関するエラーが出るので変更必要 クライアント (BIツール、アナリストなど) SQL etc.
接続するDBの設定をして、SQLを書くまでの流れ STEP 1 カタログに接続情報を書き込む $ cat /export/presto/data/etc/catalog/sample.properties connector.name=sqlserver connection-url=jdbc:sqlserver://hostname;databaseName=sampledb connection-user=xxxx
connection-password=xxxx STEP 2 SQLを実行 SELECT * FROM catalog_name.database_name.table_name mssql JOIN other_catalog_name.database_name.table_name mysql ON msslq.id = mysql.id
本題!map_aggで縦横変換しようとすると… - map_aggとは? - MapReduce向けに実装されている関数 (Hive etc.) - 縦横変換とは -
ピボット - SUM(CASE WHEN hoge = 1 THEN 1 ELSE 0 END) AS hoge1_count SUM(CASE WHEN hoge = 2 THEN 1 ELSE 0 END) AS hoge2_count - データに対しても投げれるのだが … - keyがNULLだとエラー出るので、無難に CASE WHENしとくのが吉でした
アイスタイルはデータエンジニア募集中!