From 30020cd2ffae6bb7dce0c46cd2c2cf29b0c6c563 Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Thu, 18 Jul 2024 16:07:16 -0400 Subject: [PATCH] chore(pyspark): fix ParseException import on older pyspark --- ibis/backends/pyspark/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ibis/backends/pyspark/__init__.py b/ibis/backends/pyspark/__init__.py index e79a4a6cf4b9..77f22a1e3a17 100644 --- a/ibis/backends/pyspark/__init__.py +++ b/ibis/backends/pyspark/__init__.py @@ -11,7 +11,6 @@ import sqlglot.expressions as sge from packaging.version import parse as vparse from pyspark import SparkConf -from pyspark.errors import ParseException as PySparkParseException from pyspark.sql import SparkSession from pyspark.sql.types import BooleanType, DoubleType, LongType, StringType @@ -30,6 +29,11 @@ from ibis.legacy.udf.vectorized import _coerce_to_series from ibis.util import deprecated +try: + from pyspark.errors import ParseException as PySparkParseException +except ImportError: + from pyspark.sql.utils import ParseException as PySparkParseException + if TYPE_CHECKING: from collections.abc import Mapping, Sequence from urllib.parse import ParseResult