![]() |
VOOZH | about |
The CData Cmdlets Module for BigQuery is a standard PowerShell module offering straightforward integration with BigQuery. Below, you will find examples of using our GoogleBigQuery Cmdlets with native PowerShell cmdlets.
CData simplifies access and integration of live Google BigQuery data. Our customers leverage CData connectivity to:
Most CData customers are using Google BigQuery as their data warehouse and so use CData solutions to migrate business data from separate sources into BigQuery for comprehensive analytics. Other customers use our connectivity to analyze and report on their Google BigQuery data, with many customers using both solutions.
For more details on how CData enhances your Google BigQuery experience, check out our blog post: https://www.cdata.com/blog/what-is-bigquery
Google uses the OAuth authentication standard. To access Google APIs on behalf of individual users, you can use the embedded credentials or you can register your own OAuth app.
OAuth also enables you to use a service account to connect on behalf of users in a Google Apps domain. To authenticate with a service account, register an application to obtain the OAuth JWT values.
In addition to the OAuth values, specify the DatasetId and ProjectId. See the "Getting Started" chapter of the help documentation for a guide to using OAuth.
$conn = Connect-GoogleBigQuery -DataSetId "$DataSetId" -ProjectId "$ProjectId" -InitiateOAuth "$InitiateOAuth"
Follow the steps below to retrieve data from the Orders table and pipe the result into to a CSV file:
Select-GoogleBigQuery -Connection $conn -Table Orders | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myOrdersData.csv -NoTypeInformation
You will notice that we piped the results from Select-GoogleBigQuery into a Select-Object cmdlet and excluded some properties before piping them into an Export-Csv cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each "row" in the result set, and we do not necessarily want that information in our CSV file.
The Connection, Table, and Columns are appended to the results in order to facilitate piping results from one of the CData Cmdlets directly into another one.The following line deletes any records that match the criteria:
Select-GoogleBigQuery -Connection $conn -Table Orders -Where "ShipCity = New York" | Remove-GoogleBigQuery
The cmdlets make data transformation easy as well as data cleansing. The following example loads data from a CSV file into BigQuery, checking first whether a record already exists and needs to be updated instead of inserted.
Import-Csv -Path C:\MyOrdersUpdates.csv | %{
$record = Select-GoogleBigQuery -Connection $GoogleBigQuery -Table Orders -Where ("Id = `'"+$_.Id+"`'")
if($record){
Update-GoogleBigQuery -Connection $googlebigquery -Table Orders -Columns ("OrderName","Freight") -Values ($_.OrderName, $_.Freight) -Where ("Id = `'"+$_.Id+"`'")
}else{
Add-GoogleBigQuery -Connection $googlebigquery -Table Orders -Columns ("OrderName","Freight") -Values ($_.OrderName, $_.Freight)
}
}
As always, our goal is to simplify the way you connect to data. With cmdlets users can install a data module, set the connection properties, and start building. Download Cmdlets and start working with your data in PowerShell today!
Download a free trial of the Google BigQuery Cmdlets to get started:
Download NowLearn more:
👁 Google BigQuery IconAn easy-to-use set of PowerShell Cmdlets offering real-time access to Google BigQuery data. The Cmdlets allow users to easily read, write, update, and delete live data - just like working with SQL server.