A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://datastation.multiprocess.io/docs/tutorials/Query_BigQuery_with_DataStation.html below:

Querying BigQuery with DataStation | DataStation

Querying BigQuery with DataStation

Requires DataStation 0.7.0+.

Data source setup

First create a new data source in the left sidebar.

Give it a nice name so you easily can find it later. And select BigQuery in the Vendor dropdown.

Project and service token

Fill in your Google project ID and paste in your service account token JSON.

Panel setup

Now create a new panel and select the Database type.

Run a query

Let's pull population data from a public BigQuery dataset. Enter the following query and hit play!

SELECT
 *
FROM
 `bigquery-public-data`.census_bureau_usa.population_by_zip_2010
ORDER BY population DESC
LIMIT 10

Interesting! But random US zipcodes don't mean very much. So let's grab a public CSV of zipcode data that does include the city and state information.

Load zipcode metadata

Create an new HTTP panel, enter the following URL, and hit play.

https://raw.githubusercontent.com/scpike/us-state-county-zip/master/geo-data.csv

Join the two datasets

Now that we have the top 10 zipcodes by population and a list of zipcodes with names, we can join the two datasets to find the city names of the zipcodes with the greatest population.

Create a new panel and select the Program type. Select SQL as the language. Enter the following query and hit run.

SELECT population, city || ', ' || state
FROM DM_getPanel(0)
  LEFT JOIN DM_getPanel(1) ON t_0.zipcode = t_1.zipcode
WHERE t_1.zipcode IS NOT NULL
ORDER BY population DESC;

Note: DataStation doesn't allow you to pick table aliases. They automatically become t_N where N is the string passed to DM_getPanel().

Graph the results

Create a new panel. Change the type to Graph. Select the previous Database panel as the panel source. Then select the X and Y columns you'd like to graph.

Finally, click the play button to generate the graph. You can download the graph as a PNG by clicking the download button.

Note: Ctrl-r is a shortcut for hitting the play button when you are focused on one panel.

About this page

See an error or want to add a clarification? This page is generated from this file on Github.

Last edited Feb 07, 2022.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4