gpt4 book ai didi

Azure HDI Spark导入sqlContext.implicits._错误

转载 作者:行者123 更新时间:2023-12-03 04:15:16 27 4
gpt4 key购买 nike

我在将数据从 Azure Blob 存储 csv 文件导入到我的 Spark by Jupyter 笔记本时遇到问题。我正在尝试实现关于 ML 和 Spark 的教程之一。当我像这样填写 Jupyter 笔记本时:

import sqlContext.implicits._
val flightDelayTextLines = sc.textFile("wasb://sparkcontainer@[my account].blob.core.windows.net/sparkcontainer/Scored_FlightsAndWeather.csv")

case class AirportFlightDelays(OriginAirportCode:String,OriginLatLong:String,Month:Integer,Day:Integer,Hour:Integer,Carrier:String,DelayPredicted:Integer,DelayProbability:Double)

val flightDelayRowsWithoutHeader = flightDelayTextLines.map(s => s.split(",")).filter(line => line(0) != "OriginAirportCode")

val resultDataFrame = flightDelayRowsWithoutHeader.map(
s => AirportFlightDelays(
s(0), //Airport code
s(13) + "," + s(14), //Lat,Long
s(1).toInt, //Month
s(2).toInt, //Day
s(3).toInt, //Hour
s(5), //Carrier
s(11).toInt, //DelayPredicted
s(12).toDouble //DelayProbability
)
).toDF()

resultDataFrame.write.mode("overwrite").saveAsTable("FlightDelays")

我收到这样的错误:

SparkSession available as 'spark'.
<console>:23: error: not found: value sqlContext
import sqlContext.implicits._
^

我也使用了短路径,例如(“wasb:///sparkcontainer/Scored_FlightsAndWeather.csv”)这个相同的错误。有任何想法吗?BR,马立克

最佳答案

当我看到您的代码片段时,我没有看到创建 sqlContext,请引用以下代码并创建 sqlContext,然后开始使用它。

val sqlContext = new org.apache.spark.sql.SQLContext(sc)
import sqlContext.implicits._

enter image description here

关于Azure HDI Spark导入sqlContext.implicits._错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53571815/

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