gaogaotiantian opened a new pull request, #60578: URL: https://github.com/apache/spark/pull/60578
### What changes were proposed in this pull request? Adds `test_observe_with_various_types` to `DataFrameObservationTestsMixin` in `python/pyspark/sql/tests/test_observation.py`. One `DataFrame.observe` call collects metrics of type null, byte, short, float, and timestamp_ntz, plus a struct that contains a nested struct and a map, and the test asserts the values returned by `Observation.get`. Because the test lives in the mixin, it runs on both classic and Spark Connect. ### Why are the changes needed? 15 lines of `LiteralExpression._to_value` in `python/pyspark/sql/connect/expressions.py` were not covered by any test. This method converts the proto literals that the Connect server returns for observed metrics into Python values. The existing observation tests only use long and double values plus a top-level struct, array, and map, so the null, byte, short, float, and timestamp_ntz branches and the type checks for a struct or map nested inside a struct never ran. This test covers 14 of those 15 lines. The remaining line is the `UNSUPPORTED_LITERAL` error branch, which cannot be reached through public APIs. ### Does this PR introduce _any_ user-facing change? No, test-only change. ### How was this patch tested? Ran in the PySpark CI image: - `python/run-tests --testnames 'pyspark.sql.tests.test_observation DataFrameObservationTests'` (13 tests pass) - `python/run-tests --testnames 'pyspark.sql.tests.connect.test_parity_observation DataFrameObservationParityTests'` (13 tests pass) The new test adds about 0.1 s when run in its class. ### 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]
