2016-11-10 4 views
1

私はEMRのSpark 2を使用しています。私がマスターノードにsshしてspark-shellを実行すると、私はsqlContextにアクセスできません。私は行方不明のものがありますか?エラー:見つからない:EMRの値sqlContext

[[email protected] ~]$ spark-shell 
Setting default log level to "WARN". 
To adjust logging level use sc.setLogLevel(newLevel). 
16/11/10 21:07:05 WARN Client: Neither spark.yarn.jars nor spark.yarn.archive is set, falling back to uploading libraries under SPARK_HOME. 
16/11/10 21:07:14 WARN SparkContext: Use an existing SparkContext, some configuration may not take effect. 
Spark context Web UI available at http://172.31.13.180:4040 
Spark context available as 'sc' (master = yarn, app id = application_1478720853870_0003). 
Spark session available as 'spark'. 
Welcome to 
     ____    __ 
    /__/__ ___ _____/ /__ 
    _\ \/ _ \/ _ `/ __/ '_/ 
    /___/ .__/\_,_/_/ /_/\_\ version 2.0.1 
     /_/ 

Using Scala version 2.11.8 (OpenJDK 64-Bit Server VM, Java 1.8.0_111) 
Type in expressions to have them evaluated. 
Type :help for more information. 

scala> import org.apache.spark.sql.SQLContext 
import org.apache.spark.sql.SQLContext 

scala> sqlContext 
<console>:25: error: not found: value sqlContext 
     sqlContext 
    ^

私は無駄に以下試してみた私のローカルコンピュータ上で同じエラーを取得していますので:

エクスポートSPARK_LOCAL_IP

➜ play grep "SPARK_LOCAL_IP" ~/.zshrc 
export SPARK_LOCAL_IP=127.0.0.1 
➜ play source ~/.zshrc 
➜ play spark-shell 
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties 
Setting default log level to "WARN". 
To adjust logging level use sc.setLogLevel(newLevel). 
16/11/10 16:12:18 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 
16/11/10 16:12:19 WARN SparkContext: Use an existing SparkContext, some configuration may not take effect. 
Spark context Web UI available at http://127.0.0.1:4040 
Spark context available as 'sc' (master = local[*], app id = local-1478812339020). 
Spark session available as 'spark'. 
Welcome to 
     ____    __ 
    /__/__ ___ _____/ /__ 
    _\ \/ _ \/ _ `/ __/ '_/ 
    /___/ .__/\_,_/_/ /_/\_\ version 2.0.1 
     /_/ 

Using Scala version 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_79) 
Type in expressions to have them evaluated. 
Type :help for more information. 

scala> sqlContext 
<console>:24: error: not found: value sqlContext 
     sqlContext 
    ^

scala> 

/etc/hostsは、次の

が含まれています
127.0.0.1  localhost 
255.255.255.255 broadcasthost 
::1    localhost 

答えて

3

スパーク2。 0もうSQLContextを使用していません:(sparkとしてspark-shellで初期化)

  • 使用SparkSessionを。することができますレガシーアプリケーションのための
  • val sqlContext = spark.sqlContext 
    
+0

ので 'ヴァルsqlContext = spark.sqlContext。レガシーでは 'sqlContext.read ...'、新しいアプリケーションでは 'spark.read'ですか? – Omnipresent

+0

@Omnipresent確かに。しかし、 'SQLContext'が必要なメソッドを持っていない限り、実際にはspark.sqlContextは必要ありません。 –

関連する問題