Repository: spark
Updated Branches:
  refs/heads/master a5f51e216 -> 9c530576a


[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 <dongj...@apache.org>

Closes #14190 from dongjoon-hyun/SPARK-16536.


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

Branch: refs/heads/master
Commit: 9c530576a44cbeb956db94e7fdd1fad50bd62973
Parents: a5f51e2
Author: Dongjoon Hyun <dongj...@apache.org>
Authored: Wed Jul 13 22:24:26 2016 -0700
Committer: Reynold Xin <r...@databricks.com>
Committed: Wed Jul 13 22:24:26 2016 -0700

----------------------------------------------------------------------
 python/pyspark/shell.py | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/9c530576/python/pyspark/shell.py
----------------------------------------------------------------------
diff --git a/python/pyspark/shell.py b/python/pyspark/shell.py
index ac5ce87..c1917d2 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


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

Reply via email to