Skip to content

Commit

Permalink
[SPARK-50701][PYTHON] Make plotting require the minimum plotly version
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?
Make plotting require the minimum plotly version

### Why are the changes needed?
the `minimum_plotly_version = "4.8"` didn't take effect in existing implementation

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
CI

### Was this patch authored or co-authored using generative AI tooling?
No

Closes #49333 from zhengruifeng/py_plot_minimum_version.

Authored-by: Ruifeng Zheng <ruifengz@apache.org>
Signed-off-by: Ruifeng Zheng <ruifengz@apache.org>
  • Loading branch information
zhengruifeng committed Dec 31, 2024
1 parent 5ef556b commit 8a09817
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions python/pyspark/sql/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,34 @@ def require_test_compiled() -> None:

def require_minimum_plotly_version() -> None:
"""Raise ImportError if plotly is not installed"""
from pyspark.loose_version import LooseVersion

minimum_plotly_version = "4.8"

try:
import plotly # noqa: F401
import plotly

have_plotly = True
except ImportError as error:
have_plotly = False
raised_error = error
if not have_plotly:
raise PySparkImportError(
errorClass="PACKAGE_NOT_INSTALLED",
messageParameters={
"package_name": "plotly",
"package_name": "Plotly",
"minimum_version": str(minimum_plotly_version),
},
) from error
) from raised_error
if LooseVersion(plotly.__version__) < LooseVersion(minimum_plotly_version):
raise PySparkImportError(
errorClass="UNSUPPORTED_PACKAGE_VERSION",
messageParameters={
"package_name": "Plotly",
"minimum_version": str(minimum_plotly_version),
"current_version": str(plotly.__version__),
},
)


class ForeachBatchFunction:
Expand Down

0 comments on commit 8a09817

Please sign in to comment.