-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-15644] [MLlib] [SQL] Replace SQLContext with SparkSession in MLlib #13380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
01e4cdf
6835704
9180687
b38a21e
d2b84af
fda8025
ac0dccd
6e0018b
0546772
b37a64f
c2a872c
ab6dbd7
4276356
2dab708
0458770
1debdfa
763706d
4de6ec1
9422a4f
52bdf48
1e95df3
fab24cf
8b2e33b
2ee1876
b9f0090
ade6f7e
9fd63d2
5199d49
404214c
c001dd9
59daa48
41d5f64
472a6e3
0fba10a
cbf73b3
c08f561
474df88
3d9828d
72d2361
07afea5
8bf2007
87a165b
b9359cd
65bd090
babf2da
9e09469
50a8e4a
f3337fa
09cc36d
83a1915
0483145
236a5f4
08aaa4d
64f704e
006ea2d
0c0dc8a
7c4b2f0
38f3af9
8089c6f
a6c7518
546c1db
e2ece35
13c04be
ac88fc1
154d3df
412e88a
c570065
ac03674
650cdcc
29d16c1
8d02eea
c752518
db0f48c
acc4a1c
2e907db
dffc628
5bdc447
7dcaaa4
42a1ed9
0f316f9
f0efc3e
65534a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ import org.apache.spark.ml.classification.{OneVsRest, OneVsRestModel} | |
| import org.apache.spark.ml.feature.RFormulaModel | ||
| import org.apache.spark.ml.param.{ParamPair, Params} | ||
| import org.apache.spark.ml.tuning.ValidatorParams | ||
| import org.apache.spark.sql.SparkSession | ||
| import org.apache.spark.sql.{SparkSession, SQLContext} | ||
| import org.apache.spark.util.Utils | ||
|
|
||
| /** | ||
|
|
@@ -43,9 +43,18 @@ private[util] sealed trait BaseReadWrite { | |
| private var optionSparkSession: Option[SparkSession] = None | ||
|
|
||
| /** | ||
| * Sets the Spark Session to use for saving/loading. | ||
| * Sets the Spark SQLContext to use for saving/loading. | ||
| */ | ||
| @Since("1.6.0") | ||
| def context(sqlContext: SQLContext): this.type = { | ||
| optionSparkSession = Option(sqlContext.sparkSession) | ||
| this | ||
| } | ||
|
|
||
| /** | ||
| * Sets the Spark Session to use for saving/loading. | ||
| */ | ||
| @Since("2.0.0") | ||
| def context(sparkSession: SparkSession): this.type = { | ||
| optionSparkSession = Option(sparkSession) | ||
| this | ||
|
|
@@ -61,6 +70,11 @@ private[util] sealed trait BaseReadWrite { | |
| optionSparkSession.get | ||
| } | ||
|
|
||
| /** | ||
| * Returns the user-specified SQL context or the default. | ||
| */ | ||
| protected final def sqlContext: SQLContext = sparkSession.sqlContext | ||
|
|
||
| /** Returns the underlying [[SparkContext]]. */ | ||
| protected final def sc: SparkContext = sparkSession.sparkContext | ||
| } | ||
|
|
@@ -115,6 +129,9 @@ abstract class MLWriter extends BaseReadWrite with Logging { | |
|
|
||
| // override for Java compatibility | ||
| override def context(sparkSession: SparkSession): this.type = super.context(sparkSession) | ||
|
||
|
|
||
| // override for Java compatibility | ||
| override def context(sqlContext: SQLContext): this.type = super.context(sqlContext) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just realized: Can you please change this to call
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, will do it. Thanks! |
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -159,6 +176,9 @@ abstract class MLReader[T] extends BaseReadWrite { | |
|
|
||
| // override for Java compatibility | ||
| override def context(sparkSession: SparkSession): this.type = super.context(sparkSession) | ||
|
|
||
| // override for Java compatibility | ||
| override def context(sqlContext: SQLContext): this.type = super.context(sqlContext) | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,7 +109,7 @@ class SparkSession private( | |
| * A wrapped version of this session in the form of a [[SQLContext]], for backward compatibility. | ||
| */ | ||
| @transient | ||
| private[sql] val sqlContext: SQLContext = new SQLContext(this) | ||
| private[spark] val sqlContext: SQLContext = new SQLContext(this) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rxin Is that OK? Here, the reason why I changed is for the call in https://github.com/gatorsmile/spark/blob/7dcaaa4539324d596c290ca189adc2e65d77bb0c/mllib/src/main/scala/org/apache/spark/ml/util/ReadWrite.scala#L76 |
||
|
|
||
| /** | ||
| * Runtime configuration interface for Spark. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to maintain compatibility. Can you create a new method which accepts a SparkSession?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Let me fix it now. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we deprecate these existing methods? Perhaps we can call the new method
session(for example)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! @MLnick A good point!
@rxin @jkbradley What is your opinion? Should we rename it?