From c74fd1e546440e604c546894e956c44fb6021156 Mon Sep 17 00:00:00 2001
From: "wm624@hotmail.com" <wm624@hotmail.com>
Date: Wed, 27 Apr 2016 11:56:57 -0700
Subject: [PATCH] [SPARK-14937][ML][DOCUMENT] spark.ml LogisticRegression
 sqlCtx in scala is inconsistent with java and python

## What changes were proposed in this pull request?
In spark.ml document, the LogisticRegression scala example uses sqlCtx. It is inconsistent with java and python examples which use sqlContext. In addition, a user can't copy & paste to run the example in spark-shell as sqlCtx doesn't exist in spark-shell while sqlContext exists.

Change the scala example referred by the spark.ml example.

## How was this patch tested?

Compile the example scala file and it passes compilation.

Author: wm624@hotmail.com <wm624@hotmail.com>

Closes #12717 from wangmiao1981/doc.
---
 .../examples/ml/LinearRegressionWithElasticNetExample.scala | 4 ++--
 .../examples/ml/LogisticRegressionSummaryExample.scala      | 6 +++---
 .../ml/LogisticRegressionWithElasticNetExample.scala        | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/examples/src/main/scala/org/apache/spark/examples/ml/LinearRegressionWithElasticNetExample.scala b/examples/src/main/scala/org/apache/spark/examples/ml/LinearRegressionWithElasticNetExample.scala
index c7352b3e7a..f68aef7082 100644
--- a/examples/src/main/scala/org/apache/spark/examples/ml/LinearRegressionWithElasticNetExample.scala
+++ b/examples/src/main/scala/org/apache/spark/examples/ml/LinearRegressionWithElasticNetExample.scala
@@ -29,11 +29,11 @@ object LinearRegressionWithElasticNetExample {
   def main(args: Array[String]): Unit = {
     val conf = new SparkConf().setAppName("LinearRegressionWithElasticNetExample")
     val sc = new SparkContext(conf)
-    val sqlCtx = new SQLContext(sc)
+    val sqlContext = new SQLContext(sc)
 
     // $example on$
     // Load training data
-    val training = sqlCtx.read.format("libsvm")
+    val training = sqlContext.read.format("libsvm")
       .load("data/mllib/sample_linear_regression_data.txt")
 
     val lr = new LinearRegression()
diff --git a/examples/src/main/scala/org/apache/spark/examples/ml/LogisticRegressionSummaryExample.scala b/examples/src/main/scala/org/apache/spark/examples/ml/LogisticRegressionSummaryExample.scala
index 04c60c0c1d..89c5edf1ac 100644
--- a/examples/src/main/scala/org/apache/spark/examples/ml/LogisticRegressionSummaryExample.scala
+++ b/examples/src/main/scala/org/apache/spark/examples/ml/LogisticRegressionSummaryExample.scala
@@ -30,11 +30,11 @@ object LogisticRegressionSummaryExample {
   def main(args: Array[String]): Unit = {
     val conf = new SparkConf().setAppName("LogisticRegressionSummaryExample")
     val sc = new SparkContext(conf)
-    val sqlCtx = new SQLContext(sc)
-    import sqlCtx.implicits._
+    val sqlContext = new SQLContext(sc)
+    import sqlContext.implicits._
 
     // Load training data
-    val training = sqlCtx.read.format("libsvm").load("data/mllib/sample_libsvm_data.txt")
+    val training = sqlContext.read.format("libsvm").load("data/mllib/sample_libsvm_data.txt")
 
     val lr = new LogisticRegression()
       .setMaxIter(10)
diff --git a/examples/src/main/scala/org/apache/spark/examples/ml/LogisticRegressionWithElasticNetExample.scala b/examples/src/main/scala/org/apache/spark/examples/ml/LogisticRegressionWithElasticNetExample.scala
index f632960f26..6e27571f1d 100644
--- a/examples/src/main/scala/org/apache/spark/examples/ml/LogisticRegressionWithElasticNetExample.scala
+++ b/examples/src/main/scala/org/apache/spark/examples/ml/LogisticRegressionWithElasticNetExample.scala
@@ -29,11 +29,11 @@ object LogisticRegressionWithElasticNetExample {
   def main(args: Array[String]): Unit = {
     val conf = new SparkConf().setAppName("LogisticRegressionWithElasticNetExample")
     val sc = new SparkContext(conf)
-    val sqlCtx = new SQLContext(sc)
+    val sqlContext = new SQLContext(sc)
 
     // $example on$
     // Load training data
-    val training = sqlCtx.read.format("libsvm").load("data/mllib/sample_libsvm_data.txt")
+    val training = sqlContext.read.format("libsvm").load("data/mllib/sample_libsvm_data.txt")
 
     val lr = new LogisticRegression()
       .setMaxIter(10)
-- 
GitLab