问题描述
在Spark-shell中运行官方文档提供的例子时,出现error: not found: value StructType/StructField/StringType的错误

解决方案
将相关的类导入即可
import org.apache.spark.sql.types.{StructType, StructField, StringType, IntegerType};
或者
org.apache.spark.sql.types._
本文解决在Spark-shell中运行官方示例时遇到的错误:找不到StructType、StructField和StringType。通过导入相关类,如StructType、StructField和StringType,可以轻松解决此问题。
在Spark-shell中运行官方文档提供的例子时,出现error: not found: value StructType/StructField/StringType的错误

将相关的类导入即可
import org.apache.spark.sql.types.{StructType, StructField, StringType, IntegerType};
或者
org.apache.spark.sql.types._
954
1427
619
778