Friday, September 7, 2012

How to read data from Google BigTables using Google BigQuery?

This post is in continuation towards our learning Google BigQuery. In last few posts we covered What is Google BigQuery and how to create dataset and BigTables. In this post we will learn how we can read data from Google BigTables using Google BigQuery?

With Google BigQuery we can write SQL-like statement to read data from Google BigTables. We can use the SELECT statement just like we use it to read data from SQL or Oracle tables. In last post we created a sample big table Employee_DS_BQ and stored employee data into it. To read this data using Google Browser Tool, we need to navigate to the Google BigQuery page. We need to click on Compose Query button.

To read data from employee table, we need to write query as following:

SELECT empName, empAge, empActive FROM [Employee_DS_BQ.myTable001].

If we want to limit our query resultset to n rows, we can use LIMIT clause. After writing query we need to click on RUN Query.

We can filter our query result set and apply condition using WHERE clause with Google BigQuery. In following example, I wanted to read data of employees where age is less than 25 so I applied WHERE clause in the query.

Google BigQuery provides Aggregrate functions, string functions, Bitwise functions, Comparison functions just like SQL Server or Oracle has provided with their products. We can JOIN two tables and apply Group by and Having clause into it. For Google BigQuery reference you can visit https://developers.google.com/bigquery/docs/query-reference.

Popular Posts

Real Time Web Analytics