← Back to Pull requests

Use a UTF-8 locale for PySpark integration tests #17083

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 23, 2026 03:08 UTC
Author

Fixes #17063. Related to #17086.

Description

The PySpark path tests write a partition named p=路径 before comparing CPU and GPU reads. In premerge's local mode the write runs in the driver JVM. A standalone executor inherits the environment of its Worker and can fail to encode the same filename even when the test driver uses UTF-8.

The shared PySpark test launcher selects a UTF-8 locale before starting Spark and passes the effective locale to executors through spark.executorEnv.LC_ALL. This applies to both Spark 3 and Spark 4.

<details>
<summary>How the locale reaches the process that writes the partition</summary>

1. Image and test entry point. The Ubuntu premerge Dockerfile runs locale-gen en_US.UTF-8 and leaves the default locale unset. The regular path test invokes the shared launcher without a locale argument. The separate LC_ALL=en_US.UTF-8 assignment applies only to the regex test command. Ubuntu Dockerfile · Premerge test commands
2. CPython startup. With C-locale coercion enabled, an initial character locale of C, and LC_ALL unset or empty, CPython 3.10 tries C.UTF-8, C.utf8, then UTF-8. It exports the first usable candidate as LC_CTYPE before pytest runs. In a rebuild of the premerge image, Python 3.10.12 selected C.UTF-8 with no test-side setting. With LC_ALL=C or PYTHONCOERCECLOCALE=0, Python still reported UTF-8 mode in this experiment, but the child JDK 17 reported ASCII for its filename encoding (sun.jnu.encoding). Startup condition · Startup call · Candidate order · Selection loop · LC_CTYPE export
3. Premerge execution. Premerge #15564 ran pytest via Python with Spark 3.3.0 in local[4,1]. PySpark copies the Python environment when it launches the driver JVM. In local mode that JVM also runs the CPU task that writes p=路径, before the GPU read. The historical log records the launch mode and passing test. The child JVM’s UTF-8 filename encoding was measured in the reproduction. Python test entry point · PySpark child environment · Partition write
4. Nightly execution and the fix. In the Rocky nightly image, the shell starts a standalone Worker before Python starts. The Worker later launches the executor that writes the partition. A locale set inside Python cannot update that Worker’s environment. This PR exports PYSP_TEST_spark_executorEnv_LC_ALL in the shared launcher. The test harness maps it to spark.executorEnv.LC_ALL on the SparkSession builder, and the Worker applies that value to the new executor process. Rocky Dockerfile · Nightly Worker startup · Launcher export · Test harness configuration · Worker child environment

</details>

Locally, we started a standalone Worker with LC_ALL=C and ran test_path_characters[base-v1-parquet-PERFILE] with the test launcher in C.UTF-8. On Spark 3.3.0, 4.0.1, and 4.0.5 the original launcher failed with InvalidPathException on the Chinese partition name. With the fix, the same test passed its CPU write, GPU read, and result checks. All 44 path-character cases also passed on Spark 4.0.5 and 4.1.1 in earlier launcher validation.

The change and this description were prepared with Codex assistance.

Checklists

Documentation

  • Updated for new or modified user-facing features or behaviors

  • No user-facing change
  • Testing

  • Added or modified tests to cover new code paths

  • Covered by existing tests

  • (Please provide the names of the existing tests in the PR description.)
  • Not required
  • Performance

  • Tests ran and results are added in the PR description

  • Issue filed with a link in the PR description

  • Not required
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: wjxiz1992 Review duration: 11170m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.52) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    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.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #17083"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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: 52% (MEDIUM) · Higher = larger blast radius
    52%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 29.7% · Safe to merge
    29.7%