diff options
author | Dongjoon Hyun <dongjoon@apache.org> | 2016-07-13 22:24:26 -0700 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2016-07-13 22:24:26 -0700 |
commit | 9c530576a44cbeb956db94e7fdd1fad50bd62973 (patch) | |
tree | 4c6746b0a14fa50810c6e2ad3fc3bf4418d0978f | |
parent | a5f51e21627c1bcfc62829a3a962707abf41a452 (diff) | |
download | spark-9c530576a44cbeb956db94e7fdd1fad50bd62973.tar.gz spark-9c530576a44cbeb956db94e7fdd1fad50bd62973.tar.bz2 spark-9c530576a44cbeb956db94e7fdd1fad50bd62973.zip |
[SPARK-16536][SQL][PYSPARK][MINOR] Expose `sql` in PySpark Shell
## What changes were proposed in this pull request?
This PR exposes `sql` in PySpark Shell like Scala/R Shells for consistency.
**Background**
* Scala
```scala
scala> sql("select 1 a")
res0: org.apache.spark.sql.DataFrame = [a: int]
```
* R
```r
> sql("select 1")
SparkDataFrame[1:int]
```
**Before**
* Python
```python
>>> sql("select 1 a")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sql' is not defined
```
**After**
* Python
```python
>>> sql("select 1 a")
DataFrame[a: int]
```
## How was this patch tested?
Manual.
Author: Dongjoon Hyun <dongjoon@apache.org>
Closes #14190 from dongjoon-hyun/SPARK-16536.
-rw-r--r-- | python/pyspark/shell.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/python/pyspark/shell.py b/python/pyspark/shell.py index ac5ce87a3f..c1917d2be6 100644 --- a/python/pyspark/shell.py +++ b/python/pyspark/shell.py @@ -49,6 +49,7 @@ except TypeError: spark = SparkSession.builder.getOrCreate() sc = spark.sparkContext +sql = spark.sql atexit.register(lambda: sc.stop()) # for compatibility |