spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject spark git commit: [SPARK-16503] SparkSession should provide Spark version
Date Thu, 14 Jul 2016 05:30:54 GMT
Repository: spark
Updated Branches:
  refs/heads/branch-2.0 5244f86cf -> f6eda6b30


[SPARK-16503] SparkSession should provide Spark version

## 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 <lwlin7@gmail.com>

Closes #14165 from lw-lin/add-version.

(cherry picked from commit 39c836e976fcae51568bed5ebab28e148383b5d4)
Signed-off-by: Reynold Xin <rxin@databricks.com>


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/f6eda6b3
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/f6eda6b3
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/f6eda6b3

Branch: refs/heads/branch-2.0
Commit: f6eda6b3020a5be0ff898111bf84c71e36e9433b
Parents: 5244f86
Author: Liwei Lin <lwlin7@gmail.com>
Authored: Wed Jul 13 22:30:46 2016 -0700
Committer: Reynold Xin <rxin@databricks.com>
Committed: Wed Jul 13 22:30:52 2016 -0700

----------------------------------------------------------------------
 python/pyspark/sql/session.py                               | 6 ++++++
 .../src/main/scala/org/apache/spark/sql/SparkSession.scala  | 9 ++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/f6eda6b3/python/pyspark/sql/session.py
----------------------------------------------------------------------
diff --git a/python/pyspark/sql/session.py b/python/pyspark/sql/session.py
index a360fbe..594f937 100644
--- a/python/pyspark/sql/session.py
+++ b/python/pyspark/sql/session.py
@@ -234,6 +234,12 @@ class SparkSession(object):
 
     @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):
         """Runtime configuration interface for Spark.
 

http://git-wip-us.apache.org/repos/asf/spark/blob/f6eda6b3/sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala b/sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala
index a3fd39d..df0950d 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala
@@ -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
@@ -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  |
    * ----------------------- */


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org


Mime
View raw message