Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

scalikejdbc-bigquery

1,220 views

Published on

#bq_sushi tokyo #5の登壇資料です

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

scalikejdbc-bigquery

  1. 1. ↑↑We’re Hiring!
  2. 2. bq { select(p.result.*, t.result.*).from( (Post in dataset) as p ).leftJoin( (Tag in dataset) as t ).on(p.id, t.postId) } .one(Post(_)) .toMany(Tag.opt) .map(PostWithTags) .list .run(executor)
  3. 3. bq { select(p.result.*, t.result.*).from( (Post in dataset) as p ).leftJoin( (Tag in dataset) as t ).on(p.id, t.posssssstId) // wrong column name }
  4. 4. bq { select(p.result.*, t.result.*).from( (Post in dataset) as p ).leftJoin( (Tag in dataset) as t ).on(p.id, t.postId) .where // Don't know how to bind MyDataType as parameter .eq(t.name, MyDataType("some tag_name")) }
  5. 5. bq { select( // window function p.result.*, rank.over(orderBy(p.postedAt.desc)).as(sqls"rnk") ).from( (Post in dataset) as p ) } .map { resultSet => PostWithRank(Post(resultSet), resultSet.int(sqls"rnk")) } .list .run(executor)
  6. 6. 
 Query Building
 (ScalikeJDBC) Execute
 using BigQuery Java Client Library
 (scalikejdbc-bigquery) Extract Result
 (scalikejdbc-bigquery)
  7. 7.
  8. 8. 
 

  9. 9.
  10. 10. 
 

  11. 11. 
 

  12. 12. // JDBC val statement = conn.prepareStatement( "select * from user where id = ? and name = ?" ) // bind parameters statement.setInt(1, 42) statement.setString(2, "John") // BigQuery Java Client Library val request = QueryRequest.newBuilder( "select * from user where id = ? and name = ?") .setPositionalParameters( Seq( QueryParameterValue.int64(42), QueryParameterValue.string("John") ).asJava ) .build()
  13. 13.
  14. 14. 
 


×