【问题标题】:error: not found: value StructType/StructField/StringType错误:未找到:值 StructType/StructField/StringType
【发布时间】:2016-11-02 07:07:14
【问题描述】:

我在本地机器上运行 scala,版本 2.0。

val schema = StructType(schemaString.split("|^").map(fieldName =>StructField(fieldName, StringType, true)))
<console>:45: error: not found: value StructType
   val schema = StructType(schemaString.split("|^").map(fieldName =>StructField(fieldName, StringType, true)))
                ^
<console>:45: error: not found: value StructField
   val schema = StructType(schemaString.split("|^").map(fieldName => StructField(fieldName, StringType, true)))
                                                                     ^
<console>:45: error: not found: value StringType
   val schema = StructType(schemaString.split("|^").map(fieldName => StructField(fieldName, StringType, true)))
                                                                                            ^

我加载了 import org.apache.spark.sql._ 但仍然收到此错误。我缺少任何包裹吗?

【问题讨论】:

  • 尝试导入org.apache.spark.sql.types._,这就是这些类的所在...
  • 谢谢它的工作:)

标签: scala apache-spark


【解决方案1】:
import org.apache.spark.sql.types.{StructType, StructField, StringType, IntegerType};

尝试导入

【讨论】:

  • StructField 可以是 FloatType 还是 DoubleType?
猜你喜欢
  • 1970-01-01
  • 2014-11-07
  • 2019-12-19
  • 2019-06-22
  • 1970-01-01
  • 1970-01-01
  • 2015-12-02
  • 2018-04-23
  • 1970-01-01
相关资源
最近更新 更多