Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spark <console>:12: error: not found: value sc

I wrote the following:

val a = 1 to 10000
val b = sc.parallelize(a)

and it shows error saying:

<console>:12: error: not found: value sc

Any help?

like image 769
Amitesh Ranjan Avatar asked Aug 08 '14 12:08

Amitesh Ranjan


People also ask

What is SC object in Spark?

In Spark/PySpark 'sc' is a SparkContext object that's created upfront by default on spark-shell/pyspark shell, this object also available in Databricks however when you write PySpark program you need to create SparkSession which internally create SparkContext .

What is SC in Apache spark?

setMaster(master) sc = SparkContext(conf=conf) The appName parameter is a name for your application to show on the cluster UI. master is a Spark, Mesos or YARN cluster URL, or a special “local” string to run in local mode.

How do I get SQLContext in Spark shell?

You can create an SQLContext in Spark shell by passing a default SparkContext object (sc) as a parameter to the SQLContext constructor.

What is import Spark Implicits _?

From Apache spark source code, implicits is an object class inside SparkSession class. The implicits class has extended the SQLImplicits like this : object implicits extends org. apache. spark.


1 Answers

In my case I have spark installed on local windows system and I observed the same error but it was because of below issue

Issue:Caused by: java.lang.RuntimeException: The root scratch dir: /tmp/hive on HDFS should be writable.

This was because of permission issue.I resolved it by changing the permissions using below command.Though log says "on hdfs" this is on windows system

E:\winutils\bin\winutils.exe chmod 777 E:\tmp\hive

like image 123
satish sasate Avatar answered Oct 08 '22 00:10

satish sasate