← Back to Pull requests

[ZEPPELIN-6457] Extract shared Python ZeppelinContext helpers for PySpark and PyFlink #5405

Closed
unknown closed this pull request without merging on Aug 09, 2026 12:05 UTC
View on GitHub
unknown unknown commented on Aug 09, 2026 09:05 UTC
Author

What is this PR for?

PySpark and PyFlink currently define their ZeppelinContext subclasses separately in the classic Python and IPython bootstrap resources, even though the implementations are effectively the same for each backend.

This PR moves the PySpark and PyFlink implementations into the shared zeppelin_context.py resource and reuses them from both bootstrap paths.

Backend-specific behavior remains unchanged:

PySpark handles Spark DataFrame objects through _jdf.
PyFlink handles Flink Table objects through _j_table.
PyFlink retains support for the stream_type argument.
Other object types fall back to PyZeppelinContext.show().
IPySparkZeppelinContext and IPyFlinkZeppelinContext remain available as compatibility aliases.

No new dependencies are introduced.

What type of PR is it?

Refactoring

Todos

[x] Move the PySpark ZeppelinContext implementation to the shared resource
[x] Move the PyFlink ZeppelinContext implementation to the shared resource
[x] Reuse the shared implementations from Python and IPython bootstraps
[x] Keep the existing IPython class names as compatibility aliases
[x] Verify Spark and Flink interpreter packaging
[x] Verify PySpark z.show(DataFrame) behavior

What is the Jira issue?

https://issues.apache.org/jira/browse/ZEPPELIN-6457

How should this be tested?

The following checks passed successfully:

./mvnw test \
  -pl python \
  -Dtest=PythonInterpreterTest#testBackendZeppelinContextsAvailable \
  -DfailIfNoTests=false \
  -Dmaven.gitcommitid.skip=true

Result: 1 test passed.

PYSPARK_PYTHON="$(command -v python3.12)" \
PYSPARK_DRIVER_PYTHON="$(command -v python3.12)" \
./mvnw test \
  -pl spark/interpreter \
  --am \
  -Pspark-3.5 \
  -Pspark-scala-2.12 \
  -Dtest=PySparkInterpreterTest#testPySpark \
  -Dsurefire.failIfNoSpecifiedTests=false \
  -Dmaven.gitcommitid.skip=true

Results:

PySparkInterpreterTest#testPySpark passed.
Existing ScalaTest suite: 18 tests passed.
z.show(DataFrame) was exercised successfully.

./mvnw package \
  -pl spark/interpreter \
  --am \
  -Pspark-3.5 \
  -Pspark-scala-2.12 \
  -DskipTests \
  -Dmaven.gitcommitid.skip=true

Result: 12-module reactor build succeeded.

./mvnw package \
  -pl flink/flink-scala-2.12 \
  --am \
  -Pflink-1.20 \
  -DskipTests \
  -Dmaven.gitcommitid.skip=true

Result: 13-module reactor build succeeded.

The generated Spark and Flink interpreter JARs were also verified to contain the shared context resource and the corresponding classic and IPython bootstrap resources.

git diff --check also passes.

Screenshots (if appropriate)

Not applicable. This PR does not change the user interface.

Questions

Do the license files need to be updated? No.
Are there breaking changes for older versions? No. The existing IPython context names remain available as compatibility aliases.

  • Does this need documentation? No. There are no user-facing behavior or configuration changes.
  • Diff: 380 lines (+285 / -95) across 4 files Reviewer: ParkGyeongTae Review duration: 179m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 380 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.356
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5405"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.9% (MEDIUM) · Higher = larger blast radius
    42.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.0% · Safe to merge
    17.0%