BigQuery Plugin
Introduction
Google provides BigQuery for querying massive datasets by enabling super-fast SQL queries against append-only tables using the processing power of Googles's infrastructure. Users can move their data into BigQuery and let it to handle the hard work.Â
Now CDAP provides the interface for users to handle their datasets in BigQuery.Â
Use-case
Users want to integrate CDAP with their already stored dataset in Google BigQuery.Â
Â
User Stories
As a user, I would like to run arbitrary queries synchronously against my datasets in BigQuery and pull those records in a hydrator pipeline.
Â
Requirements
- User should provide the correct project id which he has access to.Â
- User should provide the SQL query against a dataset inside his project.
- User should provide the Json Key File of the project.
- User should provide the temporary google cloud storage bucket to store the intermediate query result.Â
- User should provide the fully qualified input table in BigQuery. Â If import query is not provided, this table will be downloaded toÂ
temporary Google Cloud Storage directory and finally to the CDAP source. If import query is given, this table will be a intermediateÂ
storage to cache the query result and then downloaded to the temporary directory in Google Cloud Storage before going to CDAP source. - The temporary Google Cloud Storage directory should be deleted manually to avoid unnecessary charge from Google.
Example
Following are two simple examples showing how BigQuery Source would work.
Â
A dataset already exist in Google BigQuery:121
project Id: vernal-project1
dataset name: baby_names
table name: names_2014
name | count |
---|---|
Emma | 100 |
Oscar | 334 |
Peter | 223 |
Jay | 1123 |
Nicolas | 764 |
example1:
{ "name": "BigQuery", "properties": { "referenceName": "bigquery", "projectId": "vernal-project1", "tempBuketPath": "gs://bucketName.datasetName/tableName", "jsonFilePath": "/path/to/jsonkeyfile", "InputTableId": "vernal-project1:babynames.names_2014", "outputSchema": "name:string,count:int" } } }
Â
This source will read the vernal-project1:babynames.names_2014 table, download the whole table to gs://bucketName.datasetName/tableName, and then get the data from there.
Â
example2:
{ "name": "BigQuery", "properties": { "referenceName": "bigquery", "projectId": "vernal-project1", "tempBuketPath": "gs://bucketName.datasetName/tableName", "jsonFilePath": "/path/to/jsonkeyfile", "importQuery":"SELECT name as babyName, count as nameCount FROM [vernal-project1:babynames.names_2014] ORDER BY count DESC LIMIT 3", "InputTableId": "vernal-project1:babynames.blankTable", "outputSchema": "babyName:string,babyCount:int" } } }
Â
Before running this source, user should create a blank table with schema :Â {babyname:string, babyCount:int}. File in r example, make this blank table in vernal-project1:babynames.
and the output of the source is as follows:
babyName | babyCount |
---|---|
Jay | 1123 |
Nicolas | 764 |
Oscar | 334 |
Â
Â
Â