I would like to know if you are willing to switch to use com.google.cloud.google-cloud-bigquery
api instead of the current com.google.apis.google-api-services-bigquery
There is interesting functions available there using objects like FieldValue
containing better typing than TableValue
.
It looks like these APIs are mostly for rest apis versus the first mentioned one is a java wrapper for those, we might be able to have something closer to scalikejdbc more easily.
I have a few examples in my code that I can show that I have issues reproducing with TableCell
:
protected[this] def string(columnName: String)(implicit row: FieldValueList): String = row.get(columnName).getStringValue
protected[this] def int(columnName: String)(implicit row: FieldValueList): Int = row.get(columnName).getLongValue.toInt
protected[this] def double(columnName: String)(implicit row: FieldValueList): Double = row.get(columnName).getDoubleValue
I wanted to add these to WrappedTableCell and would be a lot easier if the underlying was a FieldValue
I am willing to make a relatively big refactoring if you want to go with it @seratch I could make bigquery4s.BigQuery
extend the com.google.cloud.bigquery.BigQuery
(or be some kind of wrapper to it like you did) and add the credential utilities to it. We won't need pagination anymore I think. Let me know what you think!
Also another example of some of my code using FieldValues:
def apply(implicit row: FieldValueList): Member = {
new Member(
stringOpt("id"),
string("name"),
double("x_local"),
double("y_local"),
timestamp("time_created")
)
}
def fetch(): Seq[Member] = bqs"select * from $datasetName.$tableName".map(Member(_))