gaogaotiantian opened a new pull request, #60576:
URL: https://github.com/apache/spark/pull/60576
### What changes were proposed in this pull request?
Adds `test_write_modes_with_options_and_properties` to
`ReadwriterV2TestsMixin` in `python/pyspark/sql/tests/test_readwriter.py`. The
test runs in both the classic and the Spark Connect suites and covers:
-
`DataFrame.writeTo(...).using("parquet").option(...).tableProperty(...).create()`:
checks the written row count and that the table property shows up in `SHOW
TBLPROPERTIES`.
- `replace()` and `createOrReplace()` on a session-catalog (v1) table:
`AnalysisException` with `UNSUPPORTED_FEATURE.TABLE_OPERATION`.
- `append()` and `overwritePartitions()` on a session-catalog (v1) table:
`AnalysisException` with `Cannot write into v1 table`.
### Why are the changes needed?
12 lines of `WriteOperationV2.command` in
`python/pyspark/sql/connect/plan.py` were not covered by any test. This method
builds the Spark Connect proto for `DataFrameWriterV2`. The existing tests only
call `create()` and `overwrite()` and never pass options or table properties,
so the serialization of `option`/`tableProperty` and of the `replace`,
`createOrReplace`, `append` and `overwritePartitions` modes never ran. With
this test 12 of the 15 previously uncovered lines in the method are covered.
The rest are the `None` value branches, which the public
`option()`/`tableProperty()` methods never produce, and the fallback for an
unknown mode, which no public method can reach.
### Does this PR introduce _any_ user-facing change?
No, test-only change.
### How was this patch tested?
Ran the new test and both full test classes, and all passed:
```
python/run-tests --testnames
'pyspark.sql.tests.connect.test_parity_readwriter ReadwriterV2ParityTests'
python/run-tests --testnames 'pyspark.sql.tests.test_readwriter
ReadwriterV2Tests'
```
The new test adds about 0.4 s to the class. `dev/lint-python` formatting
checks pass.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (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]