Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ocadaruma/scalikejdbc-bigquery
ScalikeJDBC extension for Google BigQuery
https://github.com/ocadaruma/scalikejdbc-bigquery
bigquery scala scalikejdbc
Last synced: 3 months ago
JSON representation
ScalikeJDBC extension for Google BigQuery
- Host: GitHub
- URL: https://github.com/ocadaruma/scalikejdbc-bigquery
- Owner: ocadaruma
- License: apache-2.0
- Created: 2017-01-06T04:28:03.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-03-15T01:42:47.000Z (almost 5 years ago)
- Last Synced: 2024-09-29T06:21:37.235Z (3 months ago)
- Topics: bigquery, scala, scalikejdbc
- Language: Scala
- Size: 86.9 KB
- Stars: 18
- Watchers: 5
- Forks: 8
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# scalikejdbc-bigquery
[![Build Status](https://travis-ci.org/ocadaruma/scalikejdbc-bigquery.svg?branch=master)](https://travis-ci.org/ocadaruma/scalikejdbc-bigquery)
ScalikeJDBC extension for Google BigQuery
## Prerequisites
- Java 8
- Scala 2.11.x / 2.12.x / 2.13.x
- ScalikeJDBC 2.4.x or newer## Installation
```scala
libraryDependencies ++= Seq(
"com.mayreh" %% "scalikejdbc-bigquery" % "0.1.4",
"com.google.cloud" % "google-cloud-bigquery" % "1.51.0",
"org.scalikejdbc" %% "scalikejdbc" % scalikejdbcVersion // specify scalikejdbc version you want.
)
```## Usage
```scala
import com.google.auth.oauth2.GoogleCredentials
import com.google.cloud.bigquery.{BigQueryOptions, DatasetId}
import scalikejdbc._, bigquery._// instantiate BigQuery service and DatsetId
val credentials = GoogleCredentials.fromStream(new FileInputStream("/path/to/key.json"))
val bigQuery = BigQueryOptions.newBuilder()
.setCredentials(credentials)
.setProjectId("your-gcp-project-id")
.build()
.getService
val dataset = DatasetId.of("your-gcp-project-id", "your-dataset")// build query by QueryDSL then execute
val executor = new QueryExecutor(bigQuery, QueryConfig())val response = bq {
selectFrom(User in dataset as u)
.where.eq(u.id, 42)
}.map(User(_)).single.run(executor)response.result // => Option[User]
```See also [integration test](https://github.com/ocadaruma/scalikejdbc-bigquery/blob/master/src/it/scala/scalikejdbc/bigquery/QueryDSLIntegration.scala).
## Current status
This project is still in an early stage. Newer releases can include breaking changes.
Be careful using in production.