<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: 23: error: not found: value sqlContext in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171469#M54131</link>
    <description>&lt;PRE&gt;
[spark@sandbox spark2-client]$ hdfs dfs -ls /user/spark
Found 3 items
drwxr-xr-x   - spark hdfs          0 2017-02-11 17:04 /user/spark/.sparkStaging
-rwxrwxrwx   1 spark hdfs         73 2017-02-12 00:21 /user/spark/people.json
-rwxrwxrwx   1 spark hdfs         32 2017-02-12 00:18 /user/spark/people.txt
[spark@sandbox spark2-client]$ ./bin/spark-shell
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel).
17/02/12 03:00:11 WARN SparkContext: Use an existing SparkContext, some configuration may not take effect.
Spark context Web UI available at &lt;A href="http://172.17.0.2:4040" target="_blank"&gt;http://172.17.0.2:4040&lt;/A&gt;
Spark context available as 'sc' (master = local[*], app id = local-1486868408718).
Spark session available as 'spark'.
Welcome to
      ____              __
     / __/__  ___ _____/ /__
    _\ \/ _ \/ _ `/ __/  '_/
   /___/ .__/\_,_/_/ /_/\_\   version 2.0.0.2.5.0.0-1245
      /_/
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&amp;gt; val df = sqlContext.jsonFile("people.json")
&amp;lt;console&amp;gt;:23: error: not found: value sqlContext
       val df = sqlContext.jsonFile("people.json")

&lt;/PRE&gt;</description>
    <pubDate>Sun, 12 Feb 2017 12:42:13 GMT</pubDate>
    <dc:creator>ram_ghase</dc:creator>
    <dc:date>2017-02-12T12:42:13Z</dc:date>
    <item>
      <title>23: error: not found: value sqlContext</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171468#M54130</link>
      <description>&lt;P&gt;I am following tutorial &lt;A href="http://hortonworks.com/hadoop-tutorial/a-lap-around-apache-spark/"&gt;a-lap-around-apache-spark&lt;/A&gt;,  
For the section "Using the Spark DataFrame API" I am stucked at below step
val df = sqlContext.jsonFile("people.json")&lt;/P&gt;&lt;P&gt;It throws error
&amp;lt;console&amp;gt;:23: error: not found: value sqlContext.&lt;/P&gt;&lt;P&gt;Please guide me if you have come across similar issue. I tried few posts but no luck.&lt;/P&gt;&lt;P&gt;Below are actual steps.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Feb 2017 12:36:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171468#M54130</guid>
      <dc:creator>ram_ghase</dc:creator>
      <dc:date>2017-02-12T12:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: 23: error: not found: value sqlContext</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171469#M54131</link>
      <description>&lt;PRE&gt;
[spark@sandbox spark2-client]$ hdfs dfs -ls /user/spark
Found 3 items
drwxr-xr-x   - spark hdfs          0 2017-02-11 17:04 /user/spark/.sparkStaging
-rwxrwxrwx   1 spark hdfs         73 2017-02-12 00:21 /user/spark/people.json
-rwxrwxrwx   1 spark hdfs         32 2017-02-12 00:18 /user/spark/people.txt
[spark@sandbox spark2-client]$ ./bin/spark-shell
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel).
17/02/12 03:00:11 WARN SparkContext: Use an existing SparkContext, some configuration may not take effect.
Spark context Web UI available at &lt;A href="http://172.17.0.2:4040" target="_blank"&gt;http://172.17.0.2:4040&lt;/A&gt;
Spark context available as 'sc' (master = local[*], app id = local-1486868408718).
Spark session available as 'spark'.
Welcome to
      ____              __
     / __/__  ___ _____/ /__
    _\ \/ _ \/ _ `/ __/  '_/
   /___/ .__/\_,_/_/ /_/\_\   version 2.0.0.2.5.0.0-1245
      /_/
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&amp;gt; val df = sqlContext.jsonFile("people.json")
&amp;lt;console&amp;gt;:23: error: not found: value sqlContext
       val df = sqlContext.jsonFile("people.json")

&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 Feb 2017 12:42:13 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171469#M54131</guid>
      <dc:creator>ram_ghase</dc:creator>
      <dc:date>2017-02-12T12:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: 23: error: not found: value sqlContext</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171470#M54132</link>
      <description>&lt;P&gt;You are trying to run Spark2 spark-shell, have you done "export SPARK_MAJOR_VERSION=2" ?&lt;/P&gt;</description>
      <pubDate>Sun, 12 Feb 2017 12:47:37 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171470#M54132</guid>
      <dc:creator>pminovic</dc:creator>
      <dc:date>2017-02-12T12:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: 23: error: not found: value sqlContext</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171471#M54133</link>
      <description>&lt;P&gt;Yes, I used export SPARK MAJOR VERSION=2. &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;without "_"&lt;/STRONG&gt;. I guess that is the mistake. I will try with export SPARK_MAJOR_VERSION=2&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Feb 2017 13:00:11 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171471#M54133</guid>
      <dc:creator>ram_ghase</dc:creator>
      <dc:date>2017-02-12T13:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: 23: error: not found: value sqlContext</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171472#M54134</link>
      <description>&lt;PRE&gt;[spark@sandbox spark2-client]$ echo $SPARK_HOME
/usr/hdp/current/spark2-client
[spark@sandbox spark2-client]$ echo $SPARK_MAJOR_VERSION
2
[spark@sandbox spark2-client]$ ./bin/spark-shell
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel).
17/02/12 03:58:15 WARN SparkContext: Use an existing SparkContext, some configuration may not take effect.
Spark context Web UI available at &lt;A href="http://172.17.0.2:4040" target="_blank"&gt;http://172.17.0.2:4040&lt;/A&gt;
Spark context available as 'sc' (master = local[*], app id = local-1486871892126).
Spark session available as 'spark'.
Welcome to
      ____              __
     / __/__  ___ _____/ /__
    _\ \/ _ \/ _ `/ __/  '_/
   /___/ .__/\_,_/_/ /_/\_\   version 2.0.0.2.5.0.0-1245
      /_/
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&amp;gt; val df = sqlContext.jsonFile("people.json")
&amp;lt;console&amp;gt;:23: error: not found: value sqlContext
       val df = sqlContext.jsonFile("people.json")
                ^


&lt;/PRE&gt;&lt;DIV&gt;&lt;A rel="user" href="https://community.cloudera.com/users/177/pminovic.html" nodeid="177"&gt;@Predrag Minovic&lt;/A&gt; I tried setting SPARK_MAJOR_VERSION=2.  its not working.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 12 Feb 2017 13:14:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171472#M54134</guid>
      <dc:creator>ram_ghase</dc:creator>
      <dc:date>2017-02-12T13:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: 23: error: not found: value sqlContext</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171473#M54135</link>
      <description>&lt;P&gt;Sorry, in Spark2, sqlContext is not created by spark-shell, you can create it by yourself from sc, followed by impor implicits. Then it should work. You can also replace sqlContext by hiveContext&lt;/P&gt;&lt;PRE&gt;scala&amp;gt; val sqlContext = new org.apache.spark.sql.SQLContext(sc)
scala&amp;gt; import sqlContext.implicits._
scala&amp;gt; sqlContext.sql("show tables").show()
+-----------+-----------+
|  tableName|isTemporary|
+-----------+-----------+
|    flights|      false|
|flights_ext|      false|
+-----------+-----------+
&lt;/PRE&gt;&lt;P&gt;You can also replace sqlContext by hiveContext&lt;/P&gt;&lt;PRE&gt;scala&amp;gt; val sqlContext = new org.apache.spark.sql.hive.HiveContext(sc)&lt;/PRE&gt;&lt;P&gt;Actually, in Spark2, you are encouraged to use &lt;A href="https://databricks.com/blog/2016/08/15/how-to-use-sparksession-in-apache-spark-2-0.html"&gt;SparkSessions&lt;/A&gt;, see the link for details. It includes sqlContext functionality.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Feb 2017 13:21:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171473#M54135</guid>
      <dc:creator>pminovic</dc:creator>
      <dc:date>2017-02-12T13:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: 23: error: not found: value sqlContext</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171474#M54136</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/177/pminovic.html" nodeid="177"&gt;@Predrag Minovic.&lt;/A&gt;&lt;P&gt;Thank you sir. It worked.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Feb 2017 13:30:18 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171474#M54136</guid>
      <dc:creator>ram_ghase</dc:creator>
      <dc:date>2017-02-12T13:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: 23: error: not found: value sqlContext</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171475#M54137</link>
      <description>&lt;P&gt;A Spark session called "spark" is created when you run spark-shell in Spark2. You can just say as below. And please accept the answer if it was helpful. Thanks!&lt;/P&gt;&lt;PRE&gt;scala&amp;gt; spark.sql("show tables").show()
+-----------+-----------+
|  tableName|isTemporary|
+-----------+-----------+
|    flights|      false|
|flights_ext|      false|
+-----------+-----------+&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 Feb 2017 13:40:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171475#M54137</guid>
      <dc:creator>pminovic</dc:creator>
      <dc:date>2017-02-12T13:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: 23: error: not found: value sqlContext</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171476#M54138</link>
      <description>&lt;P&gt;Unable to replace sql context with hive context.&lt;/P&gt;&lt;P&gt;In scala prgm spark 1.6&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2017 01:27:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171476#M54138</guid>
      <dc:creator>harika6126</dc:creator>
      <dc:date>2017-07-09T01:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: 23: error: not found: value sqlContext</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171477#M54139</link>
      <description>&lt;P&gt;Thanks So much.. Worked like a charm!!&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 18:15:25 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/23-error-not-found-value-sqlContext/m-p/171477#M54139</guid>
      <dc:creator>sagar_girish</dc:creator>
      <dc:date>2017-10-09T18:15:25Z</dc:date>
    </item>
  </channel>
</rss>

