You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "HyukjinKwon (via GitHub)" <gi...@apache.org> on 2026/06/22 02:23:21 UTC
[PR] [CONNECT][PYTHON][TESTS] Keep test_sql_context importable in remote-only (Connect client-only) mode [spark]
HyukjinKwon opened a new pull request, #56644:
URL: https://github.com/apache/spark/pull/56644
### What changes were proposed in this pull request?
The Spark Connect parity test `pyspark.sql.tests.connect.test_parity_sql_context` reuses
`SQLContextTestsMixin` from `pyspark.sql.tests.test_sql_context`. That module imports the
classic SQLContext at module load time:
```python
from pyspark import SQLContext
```
In a remote-only (Spark Connect client-only, i.e. `pyspark-client`) install, `pyspark/__init__.py`
only exposes `SQLContext` when `not is_remote_only()`. So the import raises `ImportError` and the
whole module fails to import, aborting the "Python-only, Connect-only" build's `Run tests (local)`
step with exit code 255 at collection time.
This PR guards that import so the module stays importable in remote-only mode, falling back to the
Connect `SQLContext` (which the parity test already uses):
```python
try:
from pyspark import SQLContext
except ImportError:
from pyspark.sql.connect.context import SQLContext
```
The same `try/except ImportError` import pattern is already used elsewhere in the test tree
(e.g. `pyspark/sql/tests/test_session.py`). The change is test-only.
### Why are the changes needed?
The scheduled "Build / Python-only, Connect-only (Python 3.11)" build has been failing since the
parity test started importing the classic mixin in remote-only mode (it was last green on
2026-06-11). The `Run tests (local)` step aborts at import:
```
File ".../pyspark/sql/tests/test_sql_context.py", line 21, in <module>
from pyspark import SQLContext
ImportError: cannot import name 'SQLContext' from 'pyspark'
```
### Does this PR introduce _any_ user-facing change?
No. Test-only change.
### How was this patch tested?
Validated on the fork by running the actual scheduled workflow
(`build_python_connect.yml`) on the branch:
- Fork run: https://github.com/HyukjinKwon/spark/actions/runs/27923450056
With this fix, the `Run tests (local)` step (which previously aborted at import with exit 255) now
passes and test collection proceeds.
Note: that same run still fails at a **separate, pre-existing** regression in the later
`Run tests (local-cluster)` step -- `pyspark.resource.tests.test_connect_resources.
ResourceProfileTests.test_profile_before_sc_for_connect` errors with a server-side
`java.lang.AssertionError` when creating a `ResourceProfile` over Connect in local-cluster mode.
That failure was masked until now (the job stopped at the failed `local` step) and is unrelated to
this import fix; it is being tracked/fixed separately.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8)
---
NOTE FOR COMMITTER: the last commit `[DO NOT MERGE] CI: trigger build_python_connect on fork for
validation` is validation-only (it lets the scheduled workflow run on the fork) and must be dropped
before merging. JIRA id TBD -- please assign a SPARK ticket / adjust the title component as needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57598][CONNECT][PYTHON][TESTS] Make test_sql_context importable in Spark Connect client-only mode [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon closed pull request #56644: [SPARK-57598][CONNECT][PYTHON][TESTS] Make test_sql_context importable in Spark Connect client-only mode
URL: https://github.com/apache/spark/pull/56644
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57598][CONNECT][PYTHON][TESTS] Make test_sql_context importable in Spark Connect client-only mode [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #56644:
URL: https://github.com/apache/spark/pull/56644#issuecomment-4773145940
Fixed by https://github.com/apache/spark/pull/56601
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [DO-NOT-MERGE][CONNECT][PYTHON][TESTS] Keep test_sql_context importable in remote-only (Connect client-only) mode [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #56644:
URL: https://github.com/apache/spark/pull/56644#issuecomment-4766440784
### Scope note: a separate, pre-existing local-cluster ResourceProfile failure (NOT this fix)
This PR is intentionally scoped to the SQLContext import guard in `test_sql_context.py`, which is a real, validated fix: the connect-only build (`build_python_connect`) used to abort at the "Run tests (local)" collection step with `ImportError: cannot import name 'SQLContext' from 'pyspark'` (exit 255) in the remote-only client install. With this change that step passes.
After the import is fixed, the connect-only build re-exposes a separate, pre-existing failure that this PR does not touch:
- Test: `pyspark.resource.tests.test_connect_resources.ResourceProfileTests.test_profile_before_sc_for_connect`, in the "Run tests (local-cluster)" step.
- Symptom: a fast (~0.025s) server-side `java.lang.AssertionError` ("assertion failed", no message) surfaced to the client as `StatusCode.UNKNOWN: "Application error processing RPC"`, triggered at the test's first explicit `rp.id` call (test line 49), which fires a synchronous `CreateResourceProfileCommand` RPC immediately after `getOrCreate()` on a freshly started `local-cluster[2,4,1024]` Connect server.
Why this is pre-existing and out of scope for the import fix:
1. The test and its explicit early `rp.id` line are unchanged for months (predate the current commit history window). It is not a new test and not modified here.
2. It never ran on apache's scheduled connect-only build: that job always died earlier at the same SQLContext import this PR fixes, so the local-cluster step has been masked since the import regression landed. The import fix merely re-exposes it.
3. The ResourceProfile-over-Connect feature itself works: in the same build, `pyspark.sql.tests.connect.test_parity_resources.ResourceProfileParityTests` (5 tests) passes against the same local-cluster server, building a `TaskResourceProfile` and running `mapInPandas`/`mapInArrow`. The classic analogue `test_profile_before_sc_for_sql` also passes; it never calls `rp.id` explicitly (it resolves the profile lazily via `mapInPandas`). The unique trigger here is the synchronous cold-start `rp.id` probe.
4. The failure is non-deterministic across runs (passes on some attempts, fails on others) with a ~25ms fast-fail, which is the signature of a cold-start race rather than a deterministic logic bug. The driver-side `addResourceProfile` -> `isSupported` -> `limitingResource` path for a task-only profile in local-cluster contains no message-less `assert` that can fire (the only message-less assert, `assert(master != null)` in `ResourceProfileManager`, cannot fire since `master` is an `Option`), and `ResourceProfile*.scala` is unchanged for months. So the bare assert originates outside the resource package, on the server/scheduler init path raced by the very-early RPC.
This is being investigated separately and should be filed as its own JIRA (Connect / ResourceProfile cold-start over local-cluster). It should not block this import-guard fix, which is independently correct and was confirmed working ("Run tests (local)" green) on the fork.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org