Skip to content

Commit fa79d34

Browse files
author
Andrew Or
committed
[SPARK-14896][SQL] Deprecate HiveContext in python
## What changes were proposed in this pull request? See title. ## How was this patch tested? PySpark tests. Author: Andrew Or <[email protected]> Closes apache#12917 from andrewor14/deprecate-hive-context-python.
1 parent b281377 commit fa79d34

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

python/pyspark/sql/column.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,6 @@ def over(self, window):
418418
>>> window = Window.partitionBy("name").orderBy("age").rowsBetween(-1, 1)
419419
>>> from pyspark.sql.functions import rank, min
420420
>>> # df.select(rank().over(window), min('age').over(window))
421-
422-
.. note:: Window functions is only supported with HiveContext in 1.4
423421
"""
424422
from pyspark.sql.window import WindowSpec
425423
if not isinstance(window, WindowSpec):

python/pyspark/sql/context.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from __future__ import print_function
1919
import sys
20+
import warnings
2021

2122
if sys.version >= '3':
2223
basestring = unicode = str
@@ -434,7 +435,6 @@ def streams(self):
434435
return ContinuousQueryManager(self._ssql_ctx.streams())
435436

436437

437-
# TODO(andrew): deprecate this
438438
class HiveContext(SQLContext):
439439
"""A variant of Spark SQL that integrates with data stored in Hive.
440440
@@ -444,8 +444,15 @@ class HiveContext(SQLContext):
444444
:param sparkContext: The SparkContext to wrap.
445445
:param jhiveContext: An optional JVM Scala HiveContext. If set, we do not instantiate a new
446446
:class:`HiveContext` in the JVM, instead we make all calls to this object.
447+
448+
.. note:: Deprecated in 2.0.0. Use SparkSession.builder.enableHiveSupport().getOrCreate().
447449
"""
448450

451+
warnings.warn(
452+
"HiveContext is deprecated in Spark 2.0.0. Please use " +
453+
"SparkSession.builder.enableHiveSupport().getOrCreate() instead.",
454+
DeprecationWarning)
455+
449456
def __init__(self, sparkContext, jhiveContext=None):
450457
if jhiveContext is None:
451458
sparkSession = SparkSession.withHiveSupport(sparkContext)

python/pyspark/sql/streaming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def _test():
221221
globs['os'] = os
222222
globs['sc'] = sc
223223
globs['sqlContext'] = SQLContext(sc)
224-
globs['hiveContext'] = HiveContext(sc)
224+
globs['hiveContext'] = HiveContext._createForTesting(sc)
225225
globs['df'] = \
226226
globs['sqlContext'].read.format('text').stream('python/test_support/sql/streaming')
227227

0 commit comments

Comments
 (0)