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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Anntoque
January 24, 2018
Programming
580
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SQL実践入門night_LT資料_YASU11552288
Anntoque
January 24, 2018
More Decks by Anntoque
See All by Anntoque
【試されDATA SAPPORO #1】データ基盤を「育てる」コミュニケーション
anntoque
0
18
【Sapporo Data Pioneers #1 】データのライフサイクルとSapporo Data Pioneersの思いについて
anntoque
1
630
【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
940
redash運用アンチパターン
anntoque
0
3.5k
Other Decks in Programming
See All in Programming
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
210
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
0
200
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
19
6.4k
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
150
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
250
Lessons from Spec-Driven Development
simas
PRO
0
150
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
130
A2UI という光を覗いてみる
satohjohn
1
120
運用エージェントは "作る" から "育てる" へ - 記憶と自己進化の3層設計パターン / self-evolving-agents-three-layer-agent-design
gawa
12
3.6k
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
230
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
4.9k
OSもどきOS
arkw
0
480
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
55
12k
A Tale of Four Properties
chriscoyier
163
24k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
200
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
Writing Fast Ruby
sferik
630
63k
Agile that works and the tools we love
rasmusluckow
331
21k
Producing Creativity
orderedlist
PRO
348
40k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
200
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
610
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
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しとくのが吉でした
アイスタイルはデータエンジニア募集中!