Skip to content

Commit

Permalink
[SPARK-16503] SparkSession should provide Spark version
Browse files Browse the repository at this point in the history
## What changes were proposed in this pull request?

This patch enables SparkSession to provide spark version.

## How was this patch tested?

Manual test:

```
scala> sc.version
res0: String = 2.1.0-SNAPSHOT

scala> spark.version
res1: String = 2.1.0-SNAPSHOT
```

```
>>> sc.version
u'2.1.0-SNAPSHOT'
>>> spark.version
u'2.1.0-SNAPSHOT'
```

Author: Liwei Lin <[email protected]>

Closes apache#14165 from lw-lin/add-version.
  • Loading branch information
lw-lin authored and rxin committed Jul 14, 2016
1 parent 9c53057 commit 39c836e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions python/pyspark/sql/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ def sparkContext(self):
"""Returns the underlying :class:`SparkContext`."""
return self._sc

@property
@since(2.0)
def version(self):
"""The version of Spark on which this application is running."""
return self._jsparkSession.version()

@property
@since(2.0)
def conf(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import scala.reflect.ClassTag
import scala.reflect.runtime.universe.TypeTag
import scala.util.control.NonFatal

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.{SPARK_VERSION, SparkConf, SparkContext}
import org.apache.spark.annotation.{DeveloperApi, Experimental}
import org.apache.spark.api.java.JavaRDD
import org.apache.spark.internal.Logging
Expand Down Expand Up @@ -79,6 +79,13 @@ class SparkSession private(

sparkContext.assertNotStopped()

/**
* The version of Spark on which this application is running.
*
* @since 2.0.0
*/
def version: String = SPARK_VERSION

/* ----------------------- *
| Session-related state |
* ----------------------- */
Expand Down

0 comments on commit 39c836e

Please sign in to comment.