crystal-bigquery

Version, currently main branch1 version
  • main branchlatestJun 27, 2025

github.com/russ/crystal-bigquery

A Bigquery client for Crystal

4 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  crystal-bigquery:
    github: russ/crystal-bigquery
    branch: main

main is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
>= 1.6.0
License
MIT

Dependencies

Runtime Dependencies

  • jwt~> 1.4github: crystal-community/jwt
  • connect-proxy~> 1.0github: spider-gazelle/connect-proxy

Development Dependencies

  • ameba~> 1.3github: crystal-ameba/amebadev
  • webmock*github: manastech/webmock.crdev

README

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

  • https://github.com/PlaceOS/google (For the Auth)
  • https://github.com/googleapis/google-cloud-ruby/tree/master/google-cloud-bigquery (Layout)
  • https://cloud.google.com/bigquery/docs/reference/rest (API)
  • https://github.com/googleapis/google-api-ruby-client/blob/master/google-api-client/generated/google/apis/bigquery_v2/service.rb#L84
  • https://github.com/googleapis/google-api-ruby-client/blob/3c9671176f2d1296cd0921a25fa55c5d8709e6d5/google-apis-core/lib/google/apis/core/base_service.rb#L370