Scale your database traffic with Read & Write split using MySQL Router
Workshop 20140522 BigQuery Implementation
1. MiTAC MiCloud - Google Cloud Platform Partner @ APAC2014Q2 BigQuery Workshop
Google BigQuery
Big data with SQL like query feature, but fast...
Google BigQueryGoogle BigQuery
http://goo.gl/XZmqgN
3. BigQuery它是...
● TB level data analysis
● Fast mining response
● SQL like query language
● Multi-dataset interactive
support
● Cheap and pay by use
● Offline job support
19. Query syntax
● SELECT
● WITHIN
● FROM
● FLATTEN
● JOIN
● WHERE
● GROUP BY
● HAVING
● ORDER BY
● LIMIT
Query support
Supported functions and operators
● Aggregate functions
● Arithmetic operators
● Bitwise operators
● Casting functions
● Comparison functions
● Date and time functions
● IP functions
● JSON functions
● Logical operators
● Mathematical functions
● Regular expression functions
● String functions
● Table wildcard functions
● URL functions
● Window functions
● Other functions
20. select charge_unit,charge_desc,one_charge from testbq.test
Select
+-----------------+----------------+--------------------+
| charge_unit | charge_desc | one_charge |
+-----------------+----------------+--------------------+
| M | 按月計費 |0 |
| D | 按日計費 |0 |
| HH | 小時計費 |0 |
| T | 分計費 |0 |
| SS | 按次計費 |1 |
+-----------------+----------------+--------------------+
21. SELECT a.order_id,a.sales,b.begin_use_date
FROM testbq.order_master a LEFT JOIN testbq.order_detail b
ON a.order_id = b.order_id
Join
+-----------------+----------------+-----------------------------+
| a_order_id | a_sales | b_begin_use_date |
+-----------------+----------------+-----------------------------+
| OM2003 | D589 | 2011-11-01 17:43:00 UTC |
| OM2004 | D589 | 2011-11-01 09:43:00 UTC |
| OM2005 | D589 | 2011-11-01 17:55:00 UTC |
| OM2006 | D589 | 2011-11-01 17:54:00 UTC |
| OM2007 | D589 | 2011-11-03 16:31:00 UTC |
+-----------------+----------------+-----------------------------+
22. SELECT
fullName,
age,
gender,
citiesLived.place
FROM (FLATTEN([dataset.tableId], children))
WHERE
(citiesLived.yearsLived > 1995) AND
(children.age > 3)
GROUP BY fullName, age, gender, citiesLived.place
Flatten
+------------+-----+--------+--------------------+
| fullName | age | gender | citiesLived_place |
+------------+-----+--------+--------------------+
| John Doe | 22 | Male | Stockholm |
| Mike Jones | 35 | Male | Los Angeles |
| Mike Jones | 35 | Male | Washington DC |
| Mike Jones | 35 | Male | Portland |
| Mike Jones | 35 | Male | Austin |
+------------+-----+--------+---------------------+
24. SELECT
TOP (FORMAT_UTC_USEC(timestamp * 1000000), 5)
AS top_revision_time,
COUNT (*) AS revision_count
FROM
[publicdata:samples.wikipedia];
+----------------------------+----------------+
| top_revision_time | revision_count |
+----------------------------+----------------+
| 2002-02-25 15:51:15.000000 | 20971 |
| 2002-02-25 15:43:11.000000 | 15955 |
| 2010-01-14 15:52:34.000000 | 3 |
| 2009-12-31 19:29:19.000000 | 3 |
| 2009-12-28 18:55:12.000000 | 3 |
+----------------------------+----------------+
Time Function
25. SELECT
DOMAIN(repository_homepage) AS user_domain,
COUNT(*) AS activity_count
FROM
[publicdata:samples.github_timeline]
GROUP BY
user_domain
HAVING
user_domain IS NOT NULL AND user_domain != ''
ORDER BY
activity_count DESC
LIMIT 5;
IP Function
+-----------------+----------------+
| user_domain | activity_count |
+-----------------+----------------+
| github.com | 281879 |
| google.com | 34769 |
| khanacademy.org | 17316 |
| sourceforge.net | 15103 |
| mozilla.org | 14091 |
+-----------------+----------------+