suhuruli opened a new pull request, #60464:
URL: https://github.com/apache/spark/pull/60464

   ### What changes were proposed in this pull request?
   
   `SparkConnectGraphElementRegistry.register_output` raises `PySparkTypeError` 
with error class `UNSUPPORTED_PIPELINES_DATASET_TYPE` at two raise sites:
   
   1. A `Table` subclass that is neither `MaterializedView` nor 
`StreamingTable`.
   2. An `Output` that is not a `Table`, `TemporaryView`, or `Sink`.
   
   Both sites passed `messageParameters={"output_type": ...}`. The template in 
`python/pyspark/errors/error-conditions.json` is `Unsupported pipelines dataset 
type: <dataset_type>.` This PR renames the parameter key to `dataset_type` at 
both sites. The value, `type(output).__name__`, is unchanged.
   
   ### Why are the changes needed?
   
   `ErrorClassesReader.get_error_message` asserts that the template 
placeholders match the provided message parameters. Because `{dataset_type} != 
{output_type}`, building the exception failed inside 
`PySparkException.__init__`. Users got an opaque `AssertionError` instead of 
the intended `PySparkTypeError`:
   
   ```
   AssertionError: Undefined error message parameter for error class: 
UNSUPPORTED_PIPELINES_DATASET_TYPE. Parameters: {'output_type': 'Output'}
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Registering an unsupported output type now raises `PySparkTypeError` 
with condition `UNSUPPORTED_PIPELINES_DATASET_TYPE` and the message 
`Unsupported pipelines dataset type: <type name>.`. Previously it raised 
`AssertionError`. Spark 4.1.0 and later are affected.
   
   ### How was this patch tested?
   
   Added 
`SparkConnectGraphElementRegistryTests.test_register_output_unsupported_dataset_type`
 to `python/pyspark/pipelines/tests/test_spark_connect.py`. It covers both 
raise sites, with a bare `Output` and a `CustomTable(Table)` subclass. For each 
one it asserts the error condition, the message parameters, and the rendered 
message. The test uses a mocked session, so it does not need a Spark Connect 
server. It fails on master with the `AssertionError` above and passes with this 
change.
   
   ```
   python/run-tests --testnames 'pyspark.pipelines.tests.test_spark_connect 
SparkConnectGraphElementRegistryTests'
   ```
   
   `ruff check`, `ruff format --check`, `dev/lint-python 
--custom-pyspark-error`, and `mypy` report no issues on the changed files.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 5.5
   
   This pull request and its description were written by Isaac.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to