Google::Cloud::Bigquery

This shard allows you to use Google's BigQuery API service using Crystal.

Installation

Add this to your application's shard.yml:

dependencies:
  bigquery:
    github: russ/crystal-bigquery

Usage

To connect to BigQuery, you'll need to authenticate. This can be done using the Google::Cloud::Bigquery::Auth, or Google::Cloud::Bigquery::FileAuth. For the FileAuth, you'll need to generate a JSON file.

require "crystal-bigquery/bigquery"

# TODO: Link to docs on generating this JSON file
bigquery = Google::Cloud::Bigquery.new(
  project_id: "your-project-id",
  credentials: Google::Cloud::Bigquery::FileAuth.new(
    "/path/to/your/google-cloud-auth.json",
    "https://www.googleapis.com/auth/bigquery"
  )
)

sql = <<-SQL
SELECT some_field FROM your_table LIMIT 1000;
SQL

results = bigquery.query_job(sql)

Links that are helpful for me developing this