Skip to content

Commit ab6e4ae

Browse files
WeichenXu123srowen
authored andcommitted
[SPARK-16662][PYSPARK][SQL] fix HiveContext warning bug
## What changes were proposed in this pull request? move the `HiveContext` deprecate warning printing statement into `HiveContext` constructor. so that this warning will appear only when we use `HiveContext` otherwise this warning will always appear if we reference the pyspark.ml.context code file. ## How was this patch tested? Manual. Author: WeichenXu <WeichenXu123@outlook.com> Closes apache#14301 from WeichenXu123/hiveContext_python_warning_update.
1 parent 25db516 commit ab6e4ae

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

python/pyspark/sql/context.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,12 +471,11 @@ class HiveContext(SQLContext):
471471
.. note:: Deprecated in 2.0.0. Use SparkSession.builder.enableHiveSupport().getOrCreate().
472472
"""
473473

474-
warnings.warn(
475-
"HiveContext is deprecated in Spark 2.0.0. Please use " +
476-
"SparkSession.builder.enableHiveSupport().getOrCreate() instead.",
477-
DeprecationWarning)
478-
479474
def __init__(self, sparkContext, jhiveContext=None):
475+
warnings.warn(
476+
"HiveContext is deprecated in Spark 2.0.0. Please use " +
477+
"SparkSession.builder.enableHiveSupport().getOrCreate() instead.",
478+
DeprecationWarning)
480479
if jhiveContext is None:
481480
sparkSession = SparkSession.builder.enableHiveSupport().getOrCreate()
482481
else:

0 commit comments

Comments
 (0)