From ab6e4aea5f39c429d5ea62a5170c8a1da612b74a Mon Sep 17 00:00:00 2001 From: WeichenXu Date: Sat, 23 Jul 2016 12:33:47 +0100 Subject: [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 Closes #14301 from WeichenXu123/hiveContext_python_warning_update. --- python/pyspark/sql/context.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/python/pyspark/sql/context.py b/python/pyspark/sql/context.py index 4cfdf799f6..0debcf1de4 100644 --- a/python/pyspark/sql/context.py +++ b/python/pyspark/sql/context.py @@ -471,12 +471,11 @@ class HiveContext(SQLContext): .. note:: Deprecated in 2.0.0. Use SparkSession.builder.enableHiveSupport().getOrCreate(). """ - warnings.warn( - "HiveContext is deprecated in Spark 2.0.0. Please use " + - "SparkSession.builder.enableHiveSupport().getOrCreate() instead.", - DeprecationWarning) - def __init__(self, sparkContext, jhiveContext=None): + warnings.warn( + "HiveContext is deprecated in Spark 2.0.0. Please use " + + "SparkSession.builder.enableHiveSupport().getOrCreate() instead.", + DeprecationWarning) if jhiveContext is None: sparkSession = SparkSession.builder.enableHiveSupport().getOrCreate() else: -- cgit v1.2.3