Bigquery - scala anorm的Simba JDBC错误

时间:2017-03-02 16:15:14

标签: java scala jdbc google-bigquery

我试图通过anorm(2.5.3)使用Simba JDBC Driver(bigquery jdbc 4.2)和在Ubuntu 16.04上播放框架(2.5.8)来从scala(2.11.8)查询bigquery。这是我的代码:

class BigQueryController @Inject() (@NamedDatabase("bigquery") db: Database) extends Controller {

    case class VixStudioProduct(short_name: String)

    def test = Action {

        val names: Seq[String] = db.withConnection { implicit connection =>
            val query = SQL("SELECT name FROM dataset.table")
            query.as(SqlParser.scalar[String].*)
        }
        Logger.debug(s"products - $names")
        Ok
    }

}

但我收到以下错误。

2017-03-02T12:58:44,428-0300 [error] [org.jdbcdslog.ConnectionLogger      ] - java.sql.Connection.prepareStatement: 
    throws exception: java.sql.SQLException: [Simba][BigQueryJDBCDriver](100038) Error getting query result object.
    java.sql.SQLException: [Simba][BigQueryJDBCDriver](100038) Error getting query result object.
        at com.simba.googlebigquery.client.BQClient.getQueryResults(Unknown Source)
        at com.simba.googlebigquery.dataengine.BQDoubleBuffer.getResultsResponse(Unknown Source)
        at com.simba.googlebigquery.dataengine.BQDoubleBuffer.<init(Unknown Source)
        at com.simba.googlebigquery.dataengine.BQResultSet.<init(Unknown Source)
        at com.simba.googlebigquery.dataengine.BQSQLExecutor.<init(Unknown Source)
        at com.simba.googlebigquery.dataengine.BQDataEngine.prepare(Unknown Source)
        at com.simba.jdbc.common.SPreparedStatement.<init(Unknown Source)
        at com.simba.jdbc.jdbc41.S41PreparedStatement.<init(Unknown Source)
        at com.simba.jdbc.jdbc42.S42PreparedStatement.<init(Unknown Source)
        at com.simba.jdbc.jdbc42.JDBC42ObjectFactory.createPreparedStatement(Unknown Source)
        at com.simba.jdbc.common.SConnection.prepareStatement(Unknown Source)
        at com.simba.jdbc.common.SConnection.prepareStatement(Unknown Source)
        at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:310)
        at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.jdbcdslog.GenericLoggingHandler.invoke(GenericLoggingHandler.java:30)
        at com.sun.proxy.$Proxy24.prepareStatement(Unknown Source)
        at anorm.SimpleSql$$anonfun$2.apply(SimpleSql.scala:40)
        at anorm.SimpleSql$$anonfun$2.apply(SimpleSql.scala:39)
        at anorm.SimpleSql.unsafeStatement(SimpleSql.scala:61)
        at anorm.SimpleSql.unsafeStatement(SimpleSql.scala:53)
        at anorm.Sql$$anonfun$preparedStatement$1.apply(Anorm.scala:90)
        at anorm.Sql$$anonfun$preparedStatement$1.apply(Anorm.scala:90)
        at resource.DefaultManagedResource.open(AbstractManagedResource.scala:110)
        at resource.AbstractManagedResource.acquireFor(AbstractManagedResource.scala:87)
        at resource.ManagedResourceOperations$$anon$2.acquireFor(ManagedResourceOperations.scala:49)
        at resource.DeferredExtractableManagedResource.acquireFor(AbstractManagedResource.scala:27)
        at resource.ManagedResourceOperations$class.apply(ManagedResourceOperations.scala:26)
        at resource.DeferredExtractableManagedResource.apply(AbstractManagedResource.scala:24)
        at resource.ManagedResourceOperations$class.acquireAndGet(ManagedResourceOperations.scala:25)
        at resource.DeferredExtractableManagedResource.acquireAndGet(AbstractManagedResource.scala:24)
        at anorm.Sql$$anonfun$asTry$1.apply(Anorm.scala:228)
        at anorm.Sql$$anonfun$asTry$1.apply(Anorm.scala:228)
        at scala.util.Try$.apply(Try.scala:192)
        at anorm.Sql$.asTry(Anorm.scala:228)
        at anorm.WithResult$class.asTry(SqlResult.scala:181)
        at anorm.SimpleSql.asTry(SimpleSql.scala:6)
        at anorm.WithResult$class.as(SqlResult.scala:173)
        at anorm.SimpleSql.as(SimpleSql.scala:6)
        at controllers.BigQueryController$$anonfun$asdf$1$$anonfun$1.apply(BigQueryController.scala:26)
        at controllers.BigQueryController$$anonfun$asdf$1$$anonfun$1.apply(BigQueryController.scala:24)
        at play.api.db.DefaultDatabase.withConnection(Databases.scala:155)
        at play.api.db.DefaultDatabase.withConnection(Databases.scala:149)
        at controllers.BigQueryController$$anonfun$asdf$1.apply(BigQueryController.scala:24)
        at controllers.BigQueryController$$anonfun$asdf$1.apply(BigQueryController.scala:18)
        at play.api.mvc.ActionBuilder$$anonfun$apply$14.apply(Action.scala:403)
        at play.api.mvc.ActionBuilder$$anonfun$apply$14.apply(Action.scala:403)
        at play.api.mvc.ActionBuilder$$anonfun$apply$13.apply(Action.scala:371)
        at play.api.mvc.ActionBuilder$$anonfun$apply$13.apply(Action.scala:370)
        at play.api.mvc.Action$.invokeBlock(Action.scala:498)
        at play.api.mvc.Action$.invokeBlock(Action.scala:495)
        at play.api.mvc.ActionBuilder$$anon$2.apply(Action.scala:458)
        at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:112)
        at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:112)
        at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
        at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:111)
        at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:110)
        at scala.Option.map(Option.scala:146)
        at play.api.mvc.Action$$anonfun$apply$2.apply(Action.scala:110)
        at play.api.mvc.Action$$anonfun$apply$2.apply(Action.scala:103)
        at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:253)
        at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
        at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
        at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:91)
        at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
        at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
        at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:72)
        at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:90)
        at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:39)
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:405)
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    Caused by: com.simba.support.exceptions.GeneralException: [Simba][BigQueryJDBCDriver](100038) Error getting query result object.
        ... 77 common frames omitted
    Caused by: java.lang.NullPointerException: Required parameter jobId must be specified.
        at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:229)
        at com.google.api.client.util.Preconditions.checkNotNull(Preconditions.java:140)
        at com.google.api.services.bigquery.Bigquery$Jobs$GetQueryResults.<init(Bigquery.java:1248)
        at com.google.api.services.bigquery.Bigquery$Jobs.getQueryResults(Bigquery.java:1221)
        at com.simba.googlebigquery.client.BQClient.getQueryResults(Unknown Source)
        at com.simba.googlebigquery.dataengine.BQDoubleBuffer.getResultsResponse(Unknown Source)
        at com.simba.googlebigquery.dataengine.BQDoubleBuffer.<init(Unknown Source)
        at com.simba.googlebigquery.dataengine.BQResultSet.<init(Unknown Source)
        at com.simba.googlebigquery.dataengine.BQSQLExecutor.<init(Unknown Source)
        at com.simba.googlebigquery.dataengine.BQDataEngine.prepare(Unknown Source)
        at com.simba.jdbc.common.SPreparedStatement.<init(Unknown Source)
        at com.simba.jdbc.jdbc41.S41PreparedStatement.<init(Unknown Source)
        at com.simba.jdbc.jdbc42.S42PreparedStatement.<init(Unknown Source)
        at com.simba.jdbc.jdbc42.JDBC42ObjectFactory.createPreparedStatement(Unknown Source)
        at com.simba.jdbc.common.SConnection.prepareStatement(Unknown Source)
        at com.simba.jdbc.common.SConnection.prepareStatement(Unknown Source)
        at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:310)
        at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.jdbcdslog.GenericLoggingHandler.invoke(GenericLoggingHandler.java:30)
        at com.sun.proxy.$Proxy24.prepareStatement(Unknown Source)
        at anorm.SimpleSql$$anonfun$2.apply(SimpleSql.scala:40)
        at anorm.SimpleSql$$anonfun$2.apply(SimpleSql.scala:39)
        at anorm.SimpleSql.unsafeStatement(SimpleSql.scala:61)
        at anorm.SimpleSql.unsafeStatement(SimpleSql.scala:53)
        at anorm.Sql$$anonfun$preparedStatement$1.apply(Anorm.scala:90)
        at anorm.Sql$$anonfun$preparedStatement$1.apply(Anorm.scala:90)
        at resource.DefaultManagedResource.open(AbstractManagedResource.scala:110)
        at resource.AbstractManagedResource.acquireFor(AbstractManagedResource.scala:87)
        at resource.ManagedResourceOperations$$anon$2.acquireFor(ManagedResourceOperations.scala:49)
        at resource.DeferredExtractableManagedResource.acquireFor(AbstractManagedResource.scala:27)
        at resource.ManagedResourceOperations$class.apply(ManagedResourceOperations.scala:26)
        at resource.DeferredExtractableManagedResource.apply(AbstractManagedResource.scala:24)
        at resource.ManagedResourceOperations$class.acquireAndGet(ManagedResourceOperations.scala:25)
        at resource.DeferredExtractableManagedResource.acquireAndGet(AbstractManagedResource.scala:24)
        at anorm.Sql$$anonfun$asTry$1.apply(Anorm.scala:228)
        at anorm.Sql$$anonfun$asTry$1.apply(Anorm.scala:228)
        at scala.util.Try$.apply(Try.scala:192)
        at anorm.Sql$.asTry(Anorm.scala:228)
        at anorm.WithResult$class.asTry(SqlResult.scala:181)
        at anorm.SimpleSql.asTry(SimpleSql.scala:6)
        at anorm.WithResult$class.as(SqlResult.scala:173)
        at anorm.SimpleSql.as(SimpleSql.scala:6)
        at controllers.BigQueryController$$anonfun$asdf$1$$anonfun$1.apply(BigQueryController.scala:26)
        at controllers.BigQueryController$$anonfun$asdf$1$$anonfun$1.apply(BigQueryController.scala:24)
        at play.api.db.DefaultDatabase.withConnection(Databases.scala:155)
        at play.api.db.DefaultDatabase.withConnection(Databases.scala:149)
        at controllers.BigQueryController$$anonfun$asdf$1.apply(BigQueryController.scala:24)
        at controllers.BigQueryController$$anonfun$asdf$1.apply(BigQueryController.scala:18)
        at play.api.mvc.ActionBuilder$$anonfun$apply$14.apply(Action.scala:403)
        at play.api.mvc.ActionBuilder$$anonfun$apply$14.apply(Action.scala:403)
        at play.api.mvc.ActionBuilder$$anonfun$apply$13.apply(Action.scala:371)
        at play.api.mvc.ActionBuilder$$anonfun$apply$13.apply(Action.scala:370)
        at play.api.mvc.Action$.invokeBlock(Action.scala:498)
        at play.api.mvc.Action$.invokeBlock(Action.scala:495)
        at play.api.mvc.ActionBuilder$$anon$2.apply(Action.scala:458)
        at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:112)
        at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:112)
        at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
        at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:111)
        at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:110)
        at scala.Option.map(Option.scala:146)
        at play.api.mvc.Action$$anonfun$apply$2.apply(Action.scala:110)
        at play.api.mvc.Action$$anonfun$apply$2.apply(Action.scala:103)
        at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:253)
        at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
        at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
        at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:91)
        at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
        at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
        at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:72)
        at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:90)
        at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:39)
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:405)
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

这是google云平台上bigquery的日志

serviceData: {
   @type: "type.googleapis.com/google.cloud.bigquery.logging.v1.AuditData"    
   jobInsertRequest: {
    resource: {
     jobName: {
      projectId: "zentinel-datawarehouse"        
     }
     jobConfiguration: {
      query: {
       query: "SELECT id,short_name FROM vix_studio.product   "        
       destinationTable: {…}        
       createDisposition: "CREATE_IF_NEEDED"        
       writeDisposition: "WRITE_EMPTY"        
       defaultDataset: {…}        
      }
      dryRun: true        
     }
     jobStatus: {
      state: "PENDING"        
      error: {…}        
     }
     jobStatistics: {…}      
    }
   }
  }

我发现了此报告的问题https://issuetracker.google.com/issues/35906079 原因是相同的,因为anorm使用准备好的声明。

提前感谢您的帮助

0 个答案:

没有答案