Google Cloud Google Cloud Platform Google Cloud cung cấp các dịch vụ đám mây bao gồm điện toán, lưu trữ dữ liệu, phân tích dữ liệu và học máy & Google Cloud Big Data and ML Products
Trang 1Trường ĐH Khoa Học Tự Nhiên Tp Hồ Chí Minh
TRUNG TÂM TIN HỌC
SQL FOR DATA ANALYTICS
Bài 2: Giới thiệu Google Big Query
https://csc.edu.vn/data-science-machine-learning/SQL-for-Data-Analytics_ 244
oO} Google
Trang 2Noi dung
1 Google Cloud
2 Google BigQuery
3 Các môi trường làm việc
4 Google Cloud Console
aia GOOGLE BIGQUERY ANALYTICS
Trang 3Google Cloud (Google Cloud Platform) la gi?
Google Cloud (GC), được cung cấp
bởi Google, là một bộ dịch vụ điện
toán đám mây chạy trên cùng cơ sở
Trang 4Google Cloud (Google Cloud Platform)
Google Cloud cung cấp các dịch vụ
đám mây bao gồm điện toán, lưu trữ
dữ liệu, phân tích dữ liệu và học máy
&
Google Cloud
Big Data and ML Products
Security
aia GOOGLE BIGQUERY ANALYTICS
Trang 5Google Cloud (Google Cloud Platform)
Một số dịch vụ chính:
* Big Data
- BigQuery: là một data warehouse cho phép doanh nghiệp quản
lý và phân tích dữ liệu (query) lên đên hàng petabytes
* AI (Artificial Intelligence) trên đám mây
- Cloud AutoML: dich vu huan luyén va triển khai các mô hình
học máy tùy chỉnh
* Lưu trữ dữ liệu
- Cloud Storage: lưu trữ dữ liệu có cấu trúc và phi cầu trúc
- Cloud SQL: CSDL dưới dạng dịch vụ dựa trên MySQL và
PostgreSQL
Trang 6Google Cloud (Google Cloud Platform)
- Cloud lIdentity: chứng thực người dùng đăng nhập
- Cloud IAM: quản lý người dùng truy cập (quyên hạn người
dùng)
Trang 7Google Cloud (Google Cloud Platform)
UTai sao phải phân tích (query) di liệu
tren Google Cloud:
eChi phi thiét bị lưu trữ rẻ
e Người phân tích quan tâm đến truy van
(không quan tâm đến cơ sở hạ tầng)
eCó thể mở rộng dữ liệu với dung lượng rất
lon (CPUs, RAM, .)
e Chỉ trả tiền khi có sử dụng
@)
aia GOOGLE BIGQUERY ANALYTICS
Trang 8Noi dung
1 Google Cloud
2 Google BigQuery
3 Các môi trường làm việc
4 Google Cloud Console
aia GOOGLE BIGQUERY ANALYTICS
Trang 9BigQuery la gi?
UBigQuery la kho dữ liệu doanh nghiệp
được quản lý hoàn toàn, giúp người
dùng quản lý và phân tích dữ liệu
(bằng ngôn ngữ SQL)
TBigQuery cung cấp các tính năng
được tích hợp sẵn như học máy,
phân tích không gian địa lý và thông
Trang 10BigQuery la gi?
Kiến trúc serverless của BigQuery cho
phép người dùng sử dụng các truy vẫn
SQL để trả lời các câu hỏi “lớn nhất” của
tổ chức mà không cần quản lý cơ sở hạ
tầng
1 BigQuery tối đa hóa tính linh hoạt bằng
cách tách công cụ tính toán phân tích dữ liệu ra khỏi các lựa chọn lưu trữ
Trang 11BigQuery la gi?
O BigQuery duoc téi wu héa dé chay cac truy
vẫn phân tích trên các tập dữ liệu lớn
[Nó có thê thực hiện các truy vẫn trên
terabyte (ngàn tỷ) dữ liệu trong vài giây và petabyte (triệu tỷ) trong vài phút
Hiệu suất này cho phép phân tích các tập
dữ liệu lớn rất hiệu quả và nhận được
@)
Trang 12BigQuery la gi?
O Tom lại, BigQuery là một hệ thống OLAP
Độ trễ truy vẫn cao và do đó sử dụng tốt nhất cho BigQuery là chạy các truy vấn có
khối lượng công việc lớn, chẳng hạn như
các công việc lưu trữ và lập báo cáo
Lưu ý: Thiết kế của BigQuery không
khuyến khích các truy vấn kiểu OLTP
Trang 13z Transform Prepare, clean, and transform BigQuery Analysis (SQL)
2 Store Create, save, and store datasets Cloud Storage (buckets)
BigQuery Storage (tables)
4 Analyze Derive insights from data BigQuery Analysis (SQL)
5 Visualize Explore and present data Google Data Studio
Trang 14Noi dung
1 Google Cloud
2 Google BigQuery
3 Các môi trường làm việc
4 Google Cloud Console
Trang 15Các môi trường làm việc (Big Data Tools)
Google Cloud Console UBigQuery command-line tool
UClient Libraries
©)
Trang 16Tao tai khoan Goole Cloud
Cách 1: tạo tài khoản Google Cloud
và đăng nhập với tài khoản này (cần
có thẻ thanh toán)
Cách 2: đăng nhập với tài khoản
Google mail và sử dụng SANDBOX
(có giới hạn quyền sử dụng)
@)
Trang 17Cách 1: Tạo tài khoản Google Cloud
Get $300 in free credits and free usage of 20+ products ©
Dream, build, and
transform with
Google Cloud
Build apps faster, make smarter business decisions, and
connect people anywhere
Get started for free Contact sales
Meet the businesses using Google Cloud to drive change from within
What's new For developers
EVENT 2-MINUTE QUIZ REPORT 7-
Save the date for Google Cloud Next '22: How data-driven is your company Rank your digital transformation against `
October 11-13 culture? global leaders
Trang 18og
rH]
® Try Google Cloud for free
Step 1 of 2 Account Information
Dung Nguyen Tien
ntdung@csc.hcmus.edu.vn
el Good news! You're eligible for an additional $100.00 in Free Trial
credits for a total of $400.00 You'll receive these credits within 24
hours of completing signup
Oo have read and agree to the Google Cloud Platform Terms of
Service, Supplemental Free Trial Terms of Service, and the terms of
service of any applicable services and APIs
Required to continue
GOOGLE BIGQUERY ANALYTICS
Access to all Cloud Platform Products
Get everything you need to build and run your apps,
websites and services, including Firebase and the
Google Maps API
$300 credit for free
Put Google Cloud to work with $300 in credit to spend over the next 90 days
No autocharge after free trial ends
We ask you for your credit card to make sure you are not a robot You won't be charged unless you
manually upgrade to a paid account
18
Trang 19Tạo tài khoản Google Cloud và đăng nhập
Step 2 of 2 Payment Information Verification
Your payment information helps us reduce fraud and abuse You won't be charged unless you turn on automatic billing
Trang 20Giới thiệu Google Cloud Console
Đăng nhập
https://console.cloud.google.com
eDang nhap voi tai khoan email
e Chọn chức năng BigQuery trong thực đơn
bên trái
https://cloud.google.com/bigquery/docs/quickstarts
Trang 21Gioi thiéu Google Cloud Console
UProjects: cac hoat dong nguoi dung
eNgười dùng có thể tạo nhiéu Project
e Một Project có thể tạo nhiều (dataset)
CIResources: các tài nguyên
e Cloud Storage: lưu dữ liệu trên các bucket
e Big Query: lưu tables và truy vấn dữ liệu
E3 1Billing: tính tiện sử dụng tài nguyên „
Trang 22Gioi thiéu Google Cloud Console
E] baseball
[] bitcoin_blockchain [] blackhole_database E] bls
Trang 23Gioi thiéu Google Cloud Console
UuDataset: austin _bikeshare
El austin_bikeshare x X a @ 8 -›
Dataset ID bigquery-public-data.austin_bikeshare
Created May 17, 2017, 2:25:37 AM UTC+7
Default table expiration Never
Last modified Sep 20, 2022, 2:42:17 PM UTC+7
Trang 24Giới thiệu Google Cloud Console
fg bikeshare_stations ~ X n Gl “œm
E— bikeshare_stations Q QUERY + +2 SHARE 1 copy E]l SNAPSHOT DELETE đi EXPORT +
SCHEMA DETAILS PREVIEW LINEAGE
‘= Filter Enter property name or value e L1 Field name Type Mode Collation Default Value Policy Tags @ Description
L1 station_id INTEGER NULLABLE
1" stus STRING NULLABLE
OO addœress STRING NULLABLE
L1 alternate_name STRING NULLABLE
L1 city_asset_number INTEGER NULLABLE
oO property_type STRING NULLABLE
L] number of docks INTEGER NULLABLE
oO power_type STRING NULLABLE
oO footprint_length INTEGER NULLABLE
VIEW ROW ACCESS POLICIES
II
©)
Trang 25Giới thiệu Google Cloud Console
li bikeshare_stations Q QUERY x +2 SHARE lũ coPY E] SNAPSHOT @ DELETE it EXPORT +
SCHEMA DETAILS PREVIEW LINEAGE
i 2538 Bullock Museum @ Congress & closed 1881 Congress Ave null
2 2541 State Capitol @ 14th & Colorado closed 206 W 14th St null
3 2545 ACC - Rio Grande & 12th closed 700 W 12th St null
4 2546 ACC - West & 12th Street closed 1231 West Ave null
5 2564 5th & San Marcos closed 991 East Sth null
6 2576 Rainey @ River St closed 64 Rainey St null
Th 2712 Toomey Rd @ South Lamar closed 1301 Toomey Road null
8 3381 East 7th & Pleasant Valley closed 2772 E 7th null
9 1002 6th & Navasota St closed 1308 W 6th St null
10 1003 8th & Guadalupe closed 800 Guadalupe St null
11 1004 Red River & LBJ Library closed 2322 Red River Street null
12 1005 State Parking Garage @ Brazos closed 1789 Brazos St null
13 1006 Zilker Park West closed Barton Springs Rd null
15 1008 Nueces @ 3rd closed 311 Nueces null
1
pa Results per page: 50 ¥ 1 - 50 of 102 K< < > >I
Trang 26Giới thiệu Google Cloud Console
TTable: bikeshare_stations —Viết Query
w bigquery-public-data * : | =“
=> External connections
> [EE] america_health_rankings yy $ L L]
> [] austin_311 W% 3 L w_ El] austin bikeshare W% ‡ L]
Trang 27Giới thiệ u Google Cloud Console
3 FROM “bigquery-public-data.austin_bikeshare.bikeshare_stations” LIMIT 1886 ;|
Press Alt+F1 for Accessibility Optior
Query results i SAVE RESULTS + fi EXPLORE DATA + Š
JOB INFORMATION RESULTS JSON EXECUTION DETAILS EXECUTION GRAPH
wy, station_id a name Ẻ status Z address Z alternate_name Z
1 2538 Bullock Museum @ Congress & closed 1881 Congress Ave null
2 2541 State Capitol @ 14th & Colorado closed 206 W 14th St null
3 2545 ACC-Rio Grande & 12th closed 700 W 12th St null
4 2546 ACC - West & 12th Street closed 1231 West Ave null
5 2564 Sth & San Marcos closed 991 East Sth null
fi 2712 Toomey Rd @ South Lamar closed 1301 Toomey Road null
8 3381 East 7th & Pleasant Valley closed 2772 E 7th null
5 1002 6th & Navasota St closed 1308 W 6th St null
10 1003 8th & Guadalupe closed 800 Guadalupe St null
11 1004 Red River & LB.J Library closed 2322 Red River Street null
i
ms Results per page: 50 v 1 — 50 of 102 l< < > >I
Trang 28Welcome to Cloud Shell! Type “help” to get started
Your Cloud Platform project in this session is set to
ntdung@cloudshell: Es
UCho thuc hién lệnh:
bq query nouse_legacy_sq| \
"SELECT station_id, name, status
FROM `bigquery-public-data.austin_ bikeshare.bikeshare_ stations`
LIMIT 1000°
https://cloud.google.com/bigquery/docs/bq-command-line-tool
Trang 29
Kết quả câu truy van
Bullock Museum @ Congress & MLK
State Capitol @ 14th & Colorado
AcC - Rio Grande & 12th
AcC - West & 12th Street Sth & San Marcos
Rainey @ River St Toomey Rd @ South Lamar
East 7th & Pleasant Valley 6th & Navasota St
8th & Guadalupe
Trang 30Gioi thiéu Client Libraries
UPython — Jupyter notebook
https://cloud.google.com/bigquery/docs/quickstarts/
quickstart-client-libraries
Trang 31Noi dung
1 Google Cloud
2 Google BigQuery
3 Các môi trường làm việc
4 Google Cloud Console
Trang 32Google Cloud Console - Tao Project
Thực đơn IAM & Admin, chon Manage
Trang 33Google Cloud Console - Tao Project
UClick CREATE PROJECT
New Project
delete projects Learn more
MANAGE QUOTAS
Project name *
project-ntdung-2023-demo 8 |
Trang 34Google Cloud Console - Tao Dataset
UThuwc don Google Cloud Console,
chon BigQuery, chon Project
UThuc don Project, chon Create
Trang 35Google Cloud Console - Tao Dataset
Default table expiration
([] Enable table expiration @
Default maximum table age Days
Trang 36Google Cloud Console - Tao Table
UThuc don Dataset, chon Create table
Trang 37Google Cloud Console - Tao Table
SCHEMA DETAILS PREVIEW
= Filter Enter property name or value
LINEAGE 22)
Mode
NULLABLE NULLABLE NULLABLE NULLABLE NULLABLE NULLABLE NULLABLE NULLABLE NULLABLE NULLABLE
Collation Default Value Policy Tags @ Description
37
Trang 38Google Cloud Console - Tao Table
OPREVIEW
SCHEMA DETAILS PREVIEW LINEAGE B202)
Row A Id A Year Z City Z Sport Discipline
1 1 1896 Athens Aquatics Swimming
2 4 1896 Athens Aquatics Swimming
3 7 1896 Athens Aquatics Swimming
4 10 1896 Athens Aquatics Swimming
5 14 1896 Athens Athletics Athletics
6 16 1896 Athens Athletics Athletics
7 19 1896 Athens Athletics Athletics
8 22 1896 Athens Athletics Athletics
9 25 1896 Athens Athletics Athletics
10 28 1896 Athens Athletics Athletics
11 30 1896 Athens Athletics Athletics
12 34 1896 Athens Athletics Athletics
13 37 1896 Athens Athletics Athletics
14 41 1896 Athens Athletics Athletics
15 + 1896 Athens Athletics Athletics
GOOGLE BIGQUERY ANALYTICS
Athlete
HAJOS, Alfred
MALOKINIS, loannis
HAJOS, Alfred NEUMANN, Paul BURKE, Thomas
CURTIS, Thomas
50 v
FLACK, Edwin BURKE, Thomas
FLACK, Edwin
GARRETT, Robert
CLARK, Ellery CLARK, Ellery
>I 38
Trang 39Google Cloud Console - Truy van
CAO, Yuan
ZHANG, Yanquan
LUO, Yutong
QIN, Kai MELLOULI, 0ussama
CHN
TUN USA RSA USA GOOGLE BIGQUERY ANALYTICS
Sport Aquatics
Aquatics
Aquatics Aquatics Aquatics
Aquatics
Aquatics Aquatics
Diving
Diving
Marathon swimming Swimming
Swimming Swimming
Medal
Gold Gold
Gold Gold
Gold
Gold Gold Gold
Gold
Gold
39
Trang 40COPY/ EXPORT/ SAVE QUERY RESULTS
Trang 41COPY/ EXPORT/ SAVE QUERY RESULTS
UCOPY TABLE
Source
Project name Dataset Table name
project-ntdung-2023-demo my_dataset medals
Unicode letters, marks, numbers, connectors, dashes or spaces allowed The job will create
the specified destination table if needed
GOOGLE BIGQUERY ANALYTICS
0)
41
Trang 42COPY/ EXPORT/ SAVE QUERY RESULTS
OEXPORT TABLE
eChon table muén export
eChọn chức năng EXPORT
= Explore with Sheets (Google Drive)
= Export to GCS (Google Cloud Storage)
©)
Trang 43COPY/ EXPORT/ SAVE QUERY RESULTS
USAVE QUERY RESULTS
JSONL (newline delimited)
Save up to 1GB as newline delimited JSON to Google Drive
Copy up to 1MB to the clipboard
Trang 44COPY/ EXPORT/ SAVE QUERY RESULTS
OSAVE QUERY ~ Iwu cau truy van
Save query
Save view
= Save query: lwu cau truy van trong tap tin sql
= Save view: tao VIEW (virtual table) tly cau truy
van
©)