{"id":16696905,"url":"https://github.com/seratch/bigquery4s","last_synced_at":"2025-03-21T19:31:28.811Z","repository":{"id":57722677,"uuid":"37757121","full_name":"seratch/bigquery4s","owner":"seratch","description":"A handy Scala wrapper of Google BigQuery API 's Java Client Library.","archived":false,"fork":false,"pushed_at":"2018-09-29T04:53:00.000Z","size":31,"stargazers_count":34,"open_issues_count":3,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-13T17:45:38.031Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seratch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-20T04:02:42.000Z","updated_at":"2022-12-07T21:13:49.000Z","dependencies_parsed_at":"2022-08-28T08:40:50.448Z","dependency_job_id":null,"html_url":"https://github.com/seratch/bigquery4s","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seratch%2Fbigquery4s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seratch%2Fbigquery4s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seratch%2Fbigquery4s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seratch%2Fbigquery4s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seratch","download_url":"https://codeload.github.com/seratch/bigquery4s/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221817809,"owners_count":16885633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T17:45:13.398Z","updated_at":"2024-10-28T10:39:04.264Z","avatar_url":"https://github.com/seratch.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"### bigquery4s\n\n[![Build Status](https://travis-ci.org/seratch/bigquery4s.svg)](https://travis-ci.org/seratch/bigquery4s)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.seratch/bigquery4s_2.11/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.seratch/bigquery4s_2.11)\n\nA handy Scala wrapper of Google BigQuery API 's Java Client Library.\n\n#### Getting Started\n\nRead BigQuery API Quickstart for details.\n\nhttps://cloud.google.com/bigquery/bigquery-api-quickstart\n\n##### Create a New BigQuery Project\n\n- Visit the [Google Developers Console](https://console.developers.google.com/project), create a new project.\n- Expand APIS \u0026 AUTH, and click on APIs. In that list, search for and enable the BigQuery API.\n- Finally, note the number of the project you just created. You can find the project number listed at the top of the project overview page for your project: https://console.developers.google.com/project/apps~\n\n##### Generate a Client ID and Client Secret for your Application\n\n- Visit the [Google APIs Management Console / Credentials](https://console.developers.google.com/apis/credentials) and select the project you just created.\n- Click on \"Create credentials\" and select \"OAuth client ID\"\n- Regarding \"Application type\", choose \"Other\"\n- Select the created credentials, then click \"DOWNLOAD JSON\" to download the client file.\n- Copy the downloaded file to a location accessible from your application, and give it a name like client_secrets.json. Your application will refer to this file as part of the flow of authorizing access to the BigQuery API. For more information about using the client_secrets.json format, see [this page](https://developers.google.com/api-client-library/python/guide/aaa_client_secrets).\n\nSave the JSON file as `$HOME/.bigquery/client_secret.json`(the default path).\n\n```json\n{\n  \"installed\": {\n    \"client_id\": \"227606545271-**********************.apps.googleusercontent.com\",\n    \"project_id\": \"project-name-****\",\n    \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n    \"token_uri\": \"https://accounts.google.com/o/oauth2/token\",\n    \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n    \"client_secret\": \"_ErCD2t-lY-**********-****\",\n    \"redirect_uris\": [\n      \"urn:ietf:wg:oauth:2.0:oob\",\n      \"http://localhost\"\n    ]\n  }\n}\n```\n##### Setting up sbt project\n\nIf you don't have sbt installed yet, read the official guide:\n\nhttps://www.scala-sbt.org/1.x/docs/Setup.html\n\nIf you're a MacOS X user, just `brew install sbt` will work fine for you.\n\n```sh\nbrew install sbt # MacOS X\n\nmkdir -p $HOME/bq-sample/project\ncd $HOME/bq-sample\n\necho 'libraryDependencies += \"com.github.seratch\" %% \"bigquery4s\" % \"0.8\"\nscalaVersion := \"2.12.6\"' \u003e build.sbt\necho \"sbt.version=1.1.6\" \u003e project/build.properties\nsbt console\n```\n\n##### Run Examples\n\nTry the following examples on the `sbt console`.\n\n```scala\nimport bigquery4s._\n\nval bq = BigQuery() // expects $HOME/.bigquery/client_secret.json\n\nval ds = bq.listDatasets(\"publicdata\")\n// ds: Seq[bigquery4s.WrappedDatasets] = ArrayBuffer(WrappedDatasets({\"datasetReference\":{\"datasetId\":\"samples\",\"projectId\":\"publicdata\"},\"id\":\"publicdata:samples\",\"kind\":\"bigquery#dataset\"}))\n\nval yourOwnProjectId = \"CHANGE THIS\"\nval jobId = bq.startQuery(yourOwnProjectId,\n  \"SELECT weight_pounds,state,year,gestation_weeks FROM publicdata:samples.natality ORDER BY weight_pounds DESC LIMIT 100\")\n// jobId: bigquery4s.JobId = JobId(ProjectId(thinking-digit-98014),job_yzM_VroG0wbj1CIeLh4U4u6V1BI)\n\nval job = bq.await(jobId)\n// job: bigquery4s.WrappedCompletedJob = WrappedCompletedJob({\"configuration\":{\"query\":{\"createDisposition\":\"CREATE_IF_NEEDED\",\"destinationTable\":{\"datasetId\":\"_ce67ab3da040a9d26fa59261366d42efce66d7a2\",\"projectId\":\"thinking-digit-98014\",\"tableId\":\"anoncda8bb0f9e2201ba87406ed02b1681750920f9af\"},\"query\":\"SELECT weight_pounds,state,year,gestation_weeks FROM publicdata:samples.natality ORDER BY weight_pounds DESC LIMIT 100\",\"writeDisposition\":\"WRITE_TRUNCATE\"}},\"etag\":\"\\\"Gn3Hpo5WaKnpFuT457VBDNMgZBw/8QF2L_W0fUFwBdI0pxm5gUIc6dw\\\"\",\"id\":\"thinking-digit-98014:job_DgtpBcg85jewo3soMIwXDH0v-r8\",\"jobReference\":{\"jobId\":\"job_DgtpBcg85jewo3soMIwXDH0v-r8\",\"projectId\":\"thinking-digit-98014\"},\"kind\":\"bigquery#job\",\"selfLink\":\"https://www.googleapis.com/bigquery/v2/projects/thinking-digit-98014/jobs/job_Dg...\n\nval rows = bq.getRows(job)\n// rows: Seq[bigquery4s.WrappedTableRow] = ArrayBuffer(WrappedTableRow({\"f\":[{\"v\":\"18.0007436923\"},{\"v\":null},{\"v\":\"2005\"},{\"v\":null}]}), WrappedTableRow({\"f\":[{\"v\":\"18.0007436923\"},{\"v\":null},{\"v\":\"2005\"},{\"v\":\"37\"}]}), WrappedTableRow({\"f\":[{\"v\":\"18.0007436923\"},{\"v\":\"KY\"},{\"v\":\"2004\"},{\"v\":\"47\"}]}), WrappedTableRow({\"f\":[{\"v\":\"18.0007436923\"},{\"v\":\"WY\"},{\"v\":\"1979\"},{\"v\":\"35\"}]}), WrappedTableRow({\"f\":[{\"v\":\"18.0007436923\"},{\"v\":null},{\"v\":\"2006\"},{\"v\":\"39\"}]}), WrappedTableRow({\"f\":[{\"v\":\"18.0007436923\"},{\"v\":null},{\"v\":\"2006\"},{\"v\":\"37\"}]}), WrappedTableRow({\"f\":[{\"v\":\"18.0007436923\"},{\"v\":\"KY\"},{\"v\":\"2004\"},{\"v\":\"38\"}]}), WrappedTableRow({\"f\":[{\"v\":\"18.0007436923\"},{\"v\":\"KY\"},{\"v\":\"2004\"},{\"v\":\"39\"}]}), WrappedTableRow({\"f\":[{\"v\":\"18.0007436923\"},{\"v\":\"KY\"},{\"v\":\"2004\"},{\"v\":\"47\"}]})...\n\nprintln(rows.take(10).map(_.cells.map(_.value.orNull).mkString(\",\")).mkString(\"\\n\"))\n\n18.0007436923,null,2005,null\n18.0007436923,null,2005,37\n18.0007436923,KY,2004,47\n18.0007436923,WY,1979,35\n18.0007436923,null,2006,39\n18.0007436923,null,2006,37\n18.0007436923,KY,2004,38\n18.0007436923,KY,2004,39\n18.0007436923,KY,2004,47\n18.0007436923,UT,1982,33\n```\n\nSee more examples [here](https://github.com/seratch/bigquery4s/tree/master/src/test/scala/bigquery4s/UsageExamplesSpec.scala).\n\n#### License\n\n(The MIT License)\n\nCopyright (c) 2015 - Kazuhiro Sera \u003cseratch_at_gmail.com\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseratch%2Fbigquery4s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseratch%2Fbigquery4s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseratch%2Fbigquery4s/lists"}