Skip to content

Commit 15a278f

Browse files
author
Davies Liu
committed
use sqlContext in python shell
1 parent 9fe4125 commit 15a278f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

docs/ml-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ from pyspark.ml.feature import HashingTF, Tokenizer
493493
from pyspark.sql import Row, SQLContext
494494

495495
sc = SparkContext(appName="SimpleTextClassificationPipeline")
496-
sqlCtx = SQLContext(sc)
496+
sqlContext = SQLContext(sc)
497497

498498
# Prepare training documents, which are labeled.
499499
LabeledDocument = Row("id", "text", "label")

docs/sql-programming-guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,15 +1642,15 @@ moved into the udf object in `SQLContext`.
16421642
<div data-lang="scala" markdown="1">
16431643
{% highlight java %}
16441644

1645-
sqlCtx.udf.register("strLen", (s: String) => s.length())
1645+
sqlContext.udf.register("strLen", (s: String) => s.length())
16461646

16471647
{% endhighlight %}
16481648
</div>
16491649

16501650
<div data-lang="java" markdown="1">
16511651
{% highlight java %}
16521652

1653-
sqlCtx.udf().register("strLen", (String s) -> { s.length(); });
1653+
sqlContext.udf().register("strLen", (String s) -> { s.length(); });
16541654

16551655
{% endhighlight %}
16561656
</div>

python/pyspark/shell.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
try:
5454
# Try to access HiveConf, it will raise exception if Hive is not added
5555
sc._jvm.org.apache.hadoop.hive.conf.HiveConf()
56-
sqlCtx = HiveContext(sc)
56+
sqlCtx = sqlContext = HiveContext(sc)
5757
except py4j.protocol.Py4JError:
58-
sqlCtx = SQLContext(sc)
58+
sqlCtx = sqlContext = SQLContext(sc)
5959

6060
print("""Welcome to
6161
____ __
@@ -68,7 +68,7 @@
6868
platform.python_version(),
6969
platform.python_build()[0],
7070
platform.python_build()[1]))
71-
print("SparkContext available as sc, %s available as sqlCtx." % sqlCtx.__class__.__name__)
71+
print("SparkContext available as sc, %s available as sqlContext." % sqlCtx.__class__.__name__)
7272

7373
if add_files is not None:
7474
print("Warning: ADD_FILES environment variable is deprecated, use --py-files argument instead")

0 commit comments

Comments
 (0)