SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
普通に使える?BigQuery
#bq_sushi_fukuoka
宮田 和三郎
2018/10/19
念願のbq_sushi@福岡
持ち時間は30分
2
30分で無から1,000億件のレコードを生成し、1,000億件
のレコードにフルスキャンでクエリを(自腹で)投げてみま
す。
とりあえず、超高速性能の再確認
3
小売業(会員制/実店舗)の売上データを想定
1,096
× 100
× 1,000
× 1,000
日(3年)
店舗
人(顧客数)
商品数
109,600,000,000 レコード
4
小売業(会員制/実店舗)の売上データを想定
1,096
× 100
× 1,000
× 1,000
日(3年)
店舗
人(顧客数)
商品数
109,600,000,000 レコード
SQL1
SQL2
SQL3
5
SQL1
#standardSQL
CREATE OR REPLACE TABLE
demo.bigdata_temp01
AS
WITH t1 AS (
SELECT days FROM UNNEST(generate_date_array('2018-01-01', '2020-12-31')) as days
), t2 AS (
SELECT CONCAT("店舗",format("%04d", n)) as tenpo FROM UNNEST(GENERATE_ARRAY(1, 100)) AS n
)
SELECT
days,tenpo
FROM
t1,t2
;
CREATE SELECTでテーブル作成
WITHが使用可能
generate_XXで配列作成し、UNNESTで各要素を1行に変換
6
SQL2
#standardSQL
CREATE OR REPLACE TABLE
demo.bigdata_temp02
AS
WITH t3 AS (
SELECT CONCAT("顧客",format("%04d", n)) as customer FROM UNNEST(GENERATE_ARRAY(1, 1000))
AS n
)
SELECT
days,tenpo,customer
FROM
demo.bigdata_temp01,t3
;
7
SQL3
#standardSQL
CREATE OR REPLACE TABLE
demo.bigdata
AS
WITH t4 AS (
SELECT CONCAT("商品",format("%04d", n)) as syohin FROM UNNEST(GENERATE_ARRAY(1, 1000)) AS
n
)
SELECT
days,tenpo,customer,syohin,CAST(rand() * 1000 AS INT64) uriage
FROM
demo.bigdata_temp02,t4
;
ランダムに売上1,000億件分のデータ生成
8
9
普通とは何?という話ですが、ここでは、一般的によく使
用されているRDBMS(SQL)を使用した事があれば、特
別なスキルがなくともBigQueryを使用できるようになっ
たという事をお話をしたいと思います。
ここから本題
10
所属:カホエンタープライズ
◆自己紹介
仕事:企業におけるデータ活用支援
名前:宮田 和三郎
経歴:主にデータ分析周り(エンジニア/PM/コンサル)
  :DWH/ETL/データプレパレーション/BI/可視化/
11
これは速い。速すぎる。Googleすげー。
初めてBigQueryを触り始めた2015年
しかし、Googleの謎技術、特殊なスキルがないと使えな
いのでは><
◆BQとの出会い
億単位のレコード数を全ナメして数秒
12
◆やりたかった事
13
SQL
SQL
SQL
LOAD
LOAD
BigQuery上でSQLを使ってデータのクレンジングや、そこそこ
複雑(計算結果を元に計算を行うよう)な計算
ここがBigQuery
● DELETE,UPDATE出来ない問題
● 小数点計算で誤差発生問題
● 全てフルスキャン問題
● 海外リージョン問題
● SQLでCreate、Dropが出来ない問題
◆2015年当時の課題
14
◆DELETE,UPDATE出来ない問題
SELECTも微妙に知っているSQLと違う。
INSERTやDELETEやUPDATE出来ない。
15
→日付単位でテーブルを作成して、処理を行うたびに毎回テー
ブル再作成していた。
◆解決
2016年:標準SQL(DML)対応
※SQL 2011に準拠(実行回数など制限あり)
16
参考:SQLおじさん(自称)がBigQueryのStandard SQLを使ってみた
◆小数点計算で誤差発生問題
浮動小数点数型(FLOAT)しかないので少数含む数
字の正確な演算を行えない。
17
→一度整数にして計算した後、少数に戻す。
→誤差を許容する(諦める)。
◆解決
2018年:NUMERIC型対応
18
◆全てフルスキャン問題
インデックス、パーティションがない。
フルスキャンとなってしまうので、不要な範囲までス
キャンしてしまいコスト増
→日付別にテーブルを作成し、複数テーブルに対してのク
エリ(TABLE_DATE_RANGE関数)で対応
19
◆解決
2016年:取り込み時間でのPARTITION TABLE
2018年:TIMESTAMP OR DATE型のカラムを使用
    したPARTITION TABLE
2018年:CLUSTERED TABLES(Beta)
20
◆海外リージョン問題
海外にデータを置く事がセキュリティポリシー上許
されない事がある。
21
◆解決
2018年:東京リージョン開設
22
◆SQLでCreate、Dropが出来ない問題
テーブルの作成に既存資源DDL(Create Table 
SQL)の活用が出来ない。
23
◆解決
2018年:DDL対応
例)Create Viewの場合
●CREATE VIEW - 新しいビューを作成します。
●CREATE VIEW IF NOT EXISTS - 指定したデータセット内にそのビューが存在しない場合にのみ作成します。
●CREATE OR REPLACE VIEW - 指定したデータセット内にビューを作成し、同じ名前のビューが存在する場合は置
き換えます。
24
2018年 一気に全てが解決
25
ここで1,000億レコード出来ているか確認
26
#standardSQL
SELECT * FROM demo.__TABLES__;
1,000億レコードにクエリ実行!
#standardSQL
SELECT
tenpo
,sum(uriage)
FROM
demo.bigdata
WHERE
extract(month from days) = 3
GROUP BY
1
;
27
新機能(Beta版)の数々
● Scheduling Queries
● BigQuery GIS
● BigQuery ML
28
祝GA!BigQuery周辺サービス
29
● Cloud Composer
● Cloud Dataprep by Trifacta
● Google Data Studio
Enjoy BigQuery!
30

Contenu connexe

Dernier

NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NTT DATA Technology & Innovation
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルCRI Japan, Inc.
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)Hiroshi Tomioka
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイスCRI Japan, Inc.
 

Dernier (7)

NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

普通に使える?BigQuery