-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-22313][PYTHON] Mark/print deprecation warnings as DeprecationWarning for deprecated APIs #19535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-22313][PYTHON] Mark/print deprecation warnings as DeprecationWarning for deprecated APIs #19535
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| import math | ||
| import sys | ||
| import functools | ||
| import warnings | ||
|
|
||
| if sys.version < "3": | ||
| from itertools import imap as map | ||
|
|
@@ -44,6 +45,14 @@ def _(col): | |
| return _ | ||
|
|
||
|
|
||
| def _wrap_deprecated_function(func, message): | ||
| """ Wrap the deprecated function to print out deprecation warnings""" | ||
| def _(col): | ||
| warnings.warn(message, DeprecationWarning) | ||
| return func(col) | ||
|
||
| return functools.wraps(func)(_) | ||
|
|
||
|
|
||
| def _create_binary_mathfunction(name, doc=""): | ||
| """ Create a binary mathfunction by name""" | ||
| def _(col1, col2): | ||
|
|
@@ -207,6 +216,12 @@ def _(): | |
| """returns the relative rank (i.e. percentile) of rows within a window partition.""", | ||
| } | ||
|
|
||
| # Wraps deprecated functions (keys) with the messages (values). | ||
| _functions_deprecated = { | ||
| 'toDegrees': 'Deprecated in 2.1, use degrees instead.', | ||
| 'toRadians': 'Deprecated in 2.1, use radians instead.', | ||
| } | ||
|
|
||
| for _name, _doc in _functions.items(): | ||
| globals()[_name] = since(1.3)(_create_function(_name, _doc)) | ||
| for _name, _doc in _functions_1_4.items(): | ||
|
|
@@ -219,6 +234,8 @@ def _(): | |
| globals()[_name] = since(1.6)(_create_function(_name, _doc)) | ||
| for _name, _doc in _functions_2_1.items(): | ||
| globals()[_name] = since(2.1)(_create_function(_name, _doc)) | ||
| for _name, _message in _functions_deprecated.items(): | ||
| globals()[_name] = _wrap_deprecated_function(globals()[_name], _message) | ||
| del _name, _doc | ||
|
|
||
|
|
||
|
|
@@ -227,6 +244,7 @@ def approxCountDistinct(col, rsd=None): | |
| """ | ||
| .. note:: Deprecated in 2.1, use :func:`approx_count_distinct` instead. | ||
| """ | ||
| warnings.warn("Deprecated in 2.1, use approx_count_distinct instead.", DeprecationWarning) | ||
| return approx_count_distinct(col, rsd) | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,8 +54,13 @@ def createStream(ssc, hostname, port, | |
| :param bodyDecoder: A function used to decode body (default is utf8_decoder) | ||
| :return: A DStream object | ||
|
|
||
| .. note:: Deprecated in 2.3.0 | ||
| .. note:: Deprecated in 2.3.0. Flume support is deprecated as of Spark 2.3.0. | ||
| See SPARK-22142. | ||
| """ | ||
| warnings.warn( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is not. Will make a followup after double checking other files too. Thank you.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you :) It will be good to also check why master build does not fail since python should complain about it.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I took a quick look and I think this one is actually not being tested and seems that's why .. will double check and take a closer look tonight (KST). I have seen few mistakes about this so far and .. I am working on Python coverage BTW - https://issues.apache.org/jira/browse/SPARK-7721 Anyway, it was my stupid mistake. Thanks .. |
||
| "Deprecated in 2.3.0. Flume support is deprecated as of Spark 2.3.0. " | ||
| "See SPARK-22142.", | ||
| DeprecationWarning) | ||
| jlevel = ssc._sc._getJavaStorageLevel(storageLevel) | ||
| helper = FlumeUtils._get_helper(ssc._sc) | ||
| jstream = helper.createStream(ssc._jssc, hostname, port, jlevel, enableDecompression) | ||
|
|
@@ -82,8 +87,13 @@ def createPollingStream(ssc, addresses, | |
| :param bodyDecoder: A function used to decode body (default is utf8_decoder) | ||
| :return: A DStream object | ||
|
|
||
| .. note:: Deprecated in 2.3.0 | ||
| .. note:: Deprecated in 2.3.0. Flume support is deprecated as of Spark 2.3.0. | ||
| See SPARK-22142. | ||
| """ | ||
| warnings.warn( | ||
| "Deprecated in 2.3.0. Flume support is deprecated as of Spark 2.3.0. " | ||
| "See SPARK-22142.", | ||
| DeprecationWarning) | ||
| jlevel = ssc._sc._getJavaStorageLevel(storageLevel) | ||
| hosts = [] | ||
| ports = [] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another example: