【问题标题】:Error compiling pipeline when using Scio typed bigquery api with apache-beam将 Scio 类型的 bigquery api 与 apache-beam 一起使用时编译管道时出错
【发布时间】:2019-06-27 16:16:26
【问题描述】:

我正在尝试使用键入的bigquery api,如scio website 所示:

@BigQueryType.fromTable("sandbox-data:Users.uid")
class UIDTable

我在命令行中运行sbt pack -Dbigquery.project=sandbox-data,得到如下错误:

exception during macro expansion:
[error] java.lang.RuntimeException: Property bigquery.project not set. Use - 
Dbigquery.project=<BILLING_PROJECT>
[error]         at com.spotify.scio.bigquery.client.BigQuery$$anonfun$instance$lzycompute$2$$anonfun$apply$2.apply(BigQuery.scala:156)
[error]         at com.spotify.scio.bigquery.client.BigQuery$$anonfun$instance$lzycompute$2$$anonfun$apply$2.apply(BigQuery.scala:154)
[error]         at scala.Option.getOrElse(Option.scala:138)
[error]         at com.spotify.scio.bigquery.client.BigQuery$$anonfun$instance$lzycompute$2.apply(BigQuery.scala:154)
[error]         at com.spotify.scio.bigquery.client.BigQuery$$anonfun$instance$lzycompute$2.apply(BigQuery.scala:154)
[error]         at scala.Option.getOrElse(Option.scala:138)
[error]         at com.spotify.scio.bigquery.client.BigQuery$.instance$lzycompute(BigQuery.scala:154)
[error]         at com.spotify.scio.bigquery.client.BigQuery$.instance(BigQuery.scala:150)
[error]         at com.spotify.scio.bigquery.client.BigQuery$.defaultInstance(BigQuery.scala:176)
[error]         at com.spotify.scio.bigquery.types.TypeProvider$.bigquery$lzycompute(TypeProvider.scala:42)
[error]         at com.spotify.scio.bigquery.types.TypeProvider$.bigquery(TypeProvider.scala:42)
[error]         at com.spotify.scio.bigquery.types.TypeProvider$.tableImpl(TypeProvider.scala:53)
[error]   @BigQueryType.fromTable("sandbox-data:Users.uid")
[error]    ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed

我的build.sbt 文件是:

import sbt.Keys._
import sbt.{util, _}

val scioVersion = "0.7.4"
val beamVersion = "2.11.0"
val scalaMacrosVersion = "2.1.1"

//logLevel := util.Level.Debug

lazy val commonSettings = Defaults.coreDefaultSettings ++ Seq(
  organization := "haaretz",
  // Semantic versioning http://semver.org/
  version := "0.1.0-SNAPSHOT",
  scalaVersion := "2.12.8",
  scalacOptions ++= Seq("-target:jvm-1.8",
    "-deprecation",
    "-feature",
    "-unchecked"),
  javacOptions ++= Seq("-source", "1.8", "-target", "1.8")
)

lazy val paradiseDependency =
  "org.scalamacros" % "paradise" % scalaMacrosVersion cross CrossVersion.full
lazy val macroSettings = Seq(
  libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value,
  addCompilerPlugin(paradiseDependency)
)

lazy val root: Project = project
  .in(file("."))
  .settings(commonSettings)
  .settings(macroSettings)
  .settings(
    name := "htz-dataflow",
    description := "DataFlow pipelines for htz projects",
    publish / skip := true,
    libraryDependencies ++= Seq(
      "com.spotify" %% "scio-core" % scioVersion,
      "com.spotify" %% "scio-bigquery" % scioVersion,
      "com.spotify" %% "scio-test" % scioVersion % Test,
      "org.apache.beam" % "beam-runners-direct-java" % beamVersion,
      "org.apache.beam" % "beam-runners-google-cloud-dataflow-java" % beamVersion,
      "org.slf4j" % "slf4j-simple" % "1.7.25",
      "org.jsoup" % "jsoup" % "1.11.3",
      "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.9.8",
      "com.typesafe.slick" %% "slick" % "3.3.1",
      "org.slf4j" % "slf4j-nop" % "1.7.26",
    )
  )
  .enablePlugins(PackPlugin)

lazy val repl: Project = project
  .in(file(".repl"))
  .settings(commonSettings)
  .settings(macroSettings)
  .settings(
    name := "repl",
    description := "Scio REPL for POC",
    libraryDependencies ++= Seq(
      "com.spotify" %% "scio-repl" % scioVersion
    ),
    Compile / mainClass := Some("com.spotify.scio.repl.ScioShell"),
    publish / skip := true
  )
  .dependsOn(root)

如果您需要任何其他信息,请发表评论,我会提供。

【问题讨论】:

  • sbt -Dbigquery.project=... {compile,pack} 适合您吗?或者,您可以使用 gcloud config set project [PROJECT] 设置默认项目
  • @NevilleLi 是的,它奏效了。谢谢!您可以发表您的评论作为答案。

标签: scala google-cloud-dataflow apache-beam spotify-scio


【解决方案1】:

应该是sbt -Dbigquery.project=... {compile,pack},即JVM标志应该在sbt任务之前。 或者,您可以使用gcloud config set project [PROJECT] 设置默认项目。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-07-25
    • 2020-01-17
    • 2022-06-27
    • 1970-01-01
    • 1970-01-01
    • 2022-08-19
    • 1970-01-01
    相关资源
    最近更新 更多