Skip to content

Commit 7275937

Browse files
m-aciekclaude
andcommitted
fix: guard PythonUtils.toScalaMap, normalize Spark 4 CI version, rename PANDAS_VERSION_SPEC
- to_scala_map: add CollectionConverters fallback in case PythonUtils is removed in a future Spark/PySpark version - base.yml: use "4.0" (two-part) for PYSPARK_VERSION to match other matrix entries - base.yml: rename PANDAS_VERSION → PANDAS_VERSION_SPEC to reflect that the value is a version specifier (e.g. ">=2.0.0"), not a bare version number Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b0c4b07 commit 7275937

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

.github/workflows/base.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
- PYSPARK_VERSION: "3.5"
2626
PYTHON_VERSION: "3.9"
2727
JAVA_VERSION: "17"
28-
- PYSPARK_VERSION: "4.0.0"
28+
- PYSPARK_VERSION: "4.0"
2929
PYTHON_VERSION: "3.9"
3030
JAVA_VERSION: "17"
31-
PANDAS_VERSION: ">=2.0.0"
31+
PANDAS_VERSION_SPEC: ">=2.0.0"
3232

3333
steps:
3434
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -45,11 +45,11 @@ jobs:
4545
- name: Running tests with pyspark==${{matrix.PYSPARK_VERSION}}
4646
env:
4747
SPARK_VERSION: ${{matrix.PYSPARK_VERSION}}
48-
PANDAS_VERSION: ${{matrix.PANDAS_VERSION}}
48+
PANDAS_VERSION_SPEC: ${{matrix.PANDAS_VERSION_SPEC}}
4949
run: |
5050
pip install --upgrade pip
5151
pip install poetry==1.7.1
5252
poetry install
5353
poetry run pip install pyspark==$SPARK_VERSION
54-
if [ -n "$PANDAS_VERSION" ]; then poetry run pip install "pandas$PANDAS_VERSION"; fi
54+
if [ -n "$PANDAS_VERSION_SPEC" ]; then poetry run pip install "pandas$PANDAS_VERSION_SPEC"; fi
5555
poetry run python -m pytest -s tests --ignore=tests/test_bot.py

pydeequ/scala_utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,15 @@ def to_scala_map(spark_session, d):
124124
Returns:
125125
Scala map
126126
"""
127-
return spark_session._jvm.PythonUtils.toScalaMap(d)
127+
jvm = spark_session._jvm
128+
try:
129+
# PythonUtils.toScalaMap is a PySpark internal that may be removed in future versions.
130+
return jvm.PythonUtils.toScalaMap(d)
131+
except Exception:
132+
style, converters = _get_converters(jvm)
133+
if style == "jdk":
134+
return converters.asScala(d).toMap()
135+
return converters.mapAsScalaMapConverter(d).asScala().toMap()
128136

129137

130138
def scala_map_to_dict(jvm, scala_map):

0 commit comments

Comments
 (0)