【发布时间】:2016-02-11 01:14:42
【问题描述】:
这是我通过 UI 在 Dataproc 中作为 PySpark 作业提交的文件
# Load file data fro Google Cloud Storage to Dataproc cluster, creating an RDD
# Because Spark transforms are 'lazy', we do a 'count()' action to make sure
# we successfully loaded the main data file
allFlt = sc.textFile("gs://mybucket/mydatafile")
allFlt.count()
# Remove header from file so we can work w data ony
header = allFlt.take(1)[0]
dataOnly = allFlt.filter(lambda line: line != header)
它启动然后出错
allFlt = sc.textFile("gs://thomtect/flightinfo")
NameError: name 'sc' is not defined
这是为什么? Dataproc 不应该已经建立了火花上下文吗?我需要在我的代码中添加什么才能将其作为 Spark 命令接受
【问题讨论】: