该项目是 Google Cloud 官方的 Ruby 客户端开发包。
安装:$ gem install google-cloud
示例代码:
require "google/cloud/bigquery" bigquery = Google::Cloud::Bigquery.new( project: "my-todo-project", keyfile: "/path/to/keyfile.json" ) # Create a new table to archive todos dataset = bigquery.dataset "my-todo-archive" table = dataset.create_table "todos", name: "Todos Archive", description: "Archive for completed TODO records" # Load data into the table file = File.open "/archive/todos/completed-todos.csv" load_job = table.load file # Run a query for the number of completed todos by owner count_sql = "SELECT owner, COUNT(*) AS complete_count FROM todos GROUP BY owner" data = bigquery.query count_sql data.each do |row| puts row["name"] end