gpt4 book ai didi

scala - 无法使用 spark-2.3.0 创建 spark-warehouse 目录

转载 作者:行者123 更新时间:2023-12-03 21:22:21 31 4
gpt4 key购买 nike

我想用akka和spark创建一个项目。我也添加了依赖项和其他一些依赖项。这些依赖项是否会对使用 spark 产生任何影响。

我有以下 sbt 文件

    dependencyOverrides += "com.fasterxml.jackson.core" % "jackson-core" % "2.8.7"
dependencyOverrides += "com.fasterxml.jackson.core" % "jackson-databind" % "2.8.7"
dependencyOverrides += "com.fasterxml.jackson.module" % "jackson-module-scala_2.11" % "2.8.7"

lazy val commonSettings = Seq(
organization := "com.bitool.analytics",
scalaVersion := "2.11.12",
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-async" % "0.9.6",
"com.softwaremill.macwire" %% "macros" % "2.3.0",
"com.softwaremill.macwire" %% "macrosakka" % "2.3.0",
"com.typesafe.akka" %% "akka-http" % "10.0.6",
"io.swagger" % "swagger-jaxrs" % "1.5.19",
"com.github.swagger-akka-http" %% "swagger-akka-http" % "0.9.1",
"io.circe" %% "circe-generic" % "0.8.0",
"io.circe" %% "circe-literal" % "0.8.0",
"io.circe" %% "circe-parser" % "0.8.0",
"io.circe" %% "circe-optics" % "0.8.0",
"org.scalafx" %% "scalafx" % "8.0.144-R12",
"org.scalafx" %% "scalafxml-core-sfx8" % "0.4",
"org.apache.spark" %% "spark-core" % "2.3.0",
"org.apache.spark" %% "spark-sql" % "2.3.0",
"org.apache.spark" %% "spark-hive" % "2.3.0",
"org.scala-lang" % "scala-xml" % "2.11.0-M4",
"mysql" % "mysql-connector-java" % "6.0.5"
)
)
lazy val root = (project in file(".")).
settings(commonSettings: _*).
settings(
name := "BITOOL-1.0"
)
ivyScala := ivyScala.value map {
_.copy(overrideScalaVersion = true)
}
fork in run := true

下面是我的 Spark 代码
private val warehouseLocation = new File("spark-warehouse").getAbsolutePath
val conf = new SparkConf()
conf.setMaster("local[4]")
conf.setAppName("Bitool")
conf.set("spark.sql.warehouse.dir", warehouseLocation)

val SPARK = SparkSession
.builder().config(conf).enableHiveSupport()
.getOrCreate()
val SPARK_CONTEXT = SPARK.sparkContext

当我尝试执行此操作时,它正在创建 metastore_db 文件夹,但未创建 spark-warehouse 文件夹。

最佳答案

此目录不是由 getOrCreate 创建的.您可以在 Spark 源代码中查看:getOrCreate将其操作委托(delegate)给 SparkSession.getOrCreate ,这只是一个二传手。所有内部测试和CliSuite使用这样的代码片段提前初始化目录:val warehousePath = Utils.createTempDir()相反,在实际的用户代码中,您必须执行至少一个数据修改操作才能实现您的仓库目录。尝试在你的代码之后运行类似的东西并再次检查硬盘上的仓库目录:

  import SPARK.implicits._
import SPARK.sql
sql("DROP TABLE IF EXISTS test")
sql("CREATE TABLE IF NOT EXISTS test (key INT, value STRING) USING hive")

关于scala - 无法使用 spark-2.3.0 创建 spark-warehouse 目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50817934/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com