小编T. *_*ęda的帖子

对象ml不是软件包org.apache.spark的成员

我正在尝试在Mllib中迈出第一步。我的库依赖项是:

libraryDependencies += "org.apache.spark" % "spark-core_2.11" % "2.2.0"
libraryDependencies += "com.github.fommil.netlib" % "all" % "1.1.2"
Run Code Online (Sandbox Code Playgroud)

但我仍然得到:

Error:(4, 27) object ml is not a member of package org.apache.spark
  import org.apache.spark.ml.regression.GeneralizedLinearRegression
Run Code Online (Sandbox Code Playgroud)

sbt apache-spark apache-spark-mllib

3
推荐指数
1
解决办法
2318
查看次数

Spark 中的分解结构

我有具有以下架构的 DataFrame:

 |-- data: struct (nullable = true)
 |    |-- asin: string (nullable = true)
 |    |-- customerId: long (nullable = true)
 |    |-- eventTime: long (nullable = true)
 |    |-- marketplaceId: long (nullable = true)
 |    |-- rating: long (nullable = true)
 |    |-- region: string (nullable = true)
 |    |-- type: string (nullable = true)
 |-- uploadedDate: long (nullable = true)
Run Code Online (Sandbox Code Playgroud)

我想分解结构,使 asin、customerId、eventTime 等所有元素都成为 DataFrame 中的列。我尝试了爆炸函数,但它适用于数组而不是结构类型。是否可以将数据框转换为以下数据框:

     |-- asin: string (nullable = true)
     |-- customerId: long (nullable = true) …
Run Code Online (Sandbox Code Playgroud)

hadoop apache-spark apache-spark-sql

3
推荐指数
1
解决办法
5464
查看次数

如何将Scala集合Seq [(Int,Seq [String])]转换为Java集合List [(int,List [String])]?

我知道scala.collection包中有两个非常有用的对象,它们将帮助我们实现这个目标:

  • JavaConverters(如果我想要明确并告诉我想要转换的内容)
  • JavaConversions(如果我不想进行共同控制转换,让编译器为我做隐式工作)

但是我在我的案例中应用它们有一些麻烦,因为我的数据结构比我在许多例子中看到的其他数据结构稍微复杂一些.

我在scala代码中,我希望我的scala函数返回Java集合.所以我想将Scala Seq [(Int,Seq [String])]转换为Java集合List [(int,List [String])].

我怎样才能做到这一点?

java scala

3
推荐指数
1
解决办法
336
查看次数

如何在spark sql(Scala)中解析url

我正在使用以下函数来解析 url 但它会抛出错误,

val b = Seq(("http://spark.apache.org/path?query=1"),("https://people.apache.org/~pwendell/spark-nightly/spark-master-docs/latest/api/sql/#negative")).toDF("url_col")
        .withColumn("host",parse_url($"url_col","HOST"))
        .withColumn("query",parse_url($"url_col","QUERY"))
        .show(false)
Run Code Online (Sandbox Code Playgroud)

错误:

<console>:285: error: not found: value parse_url
               .withColumn("host",parse_url($"url_col","HOST"))
                                  ^
<console>:286: error: not found: value parse_url
               .withColumn("query",parse_url($"url_col","QUERY"))
                                   ^
Run Code Online (Sandbox Code Playgroud)

请指导如何将 url 解析为不同的部分。

scala apache-spark

2
推荐指数
2
解决办法
8589
查看次数