HyukjinKwon opened a new pull request, #760:
URL: https://github.com/apache/spark-connect-rust/pull/760

   ### What changes were proposed in this pull request?
   
   `Column.alias` and `Column.name` of the drop-in raised every error of their 
names and metadata at the call. PySpark's `ColumnAlias` raises them when a 
request builds the plan:
   - a name that protobuf refuses: a `TypeError`, or the `UnicodeEncodeError` / 
`UnicodeDecodeError` of UTF-8;
   - metadata of one name that `json.dumps` refuses;
   - metadata of no names (`CANNOT_PROVIDE_METADATA`).
   
   So a Column that PySpark builds and never uses raised here, and such a 
Column did not copy or pickle. Its `__repr__` also differed. PySpark's joins 
the names, which raises a `TypeError` for a name that is not a `str`, bytes 
included.
   
   This raises them as PySpark does:
   - **Core** (`crates/spark-connect/src/expression.rs`): 
`ExpressionNode::Unbuildable` (doc-hidden, like `LogicalPlan::Unbuildable`) 
wraps an expression with the errors that a request raises before it builds the 
expression and after it. The names of an alias are set before its child, and 
its metadata after. The serialization of a request records the first such 
error, in the order in which PySpark builds the plan, and raises it 
(`with_expression_depth_bound`). `Expression::try_render` raises the error of 
the `__repr__`.
   - **Drop-in** (`crates/pyspark-rs/src/column.rs`): `alias` keeps PySpark's 
checks at the call (the metadata of several names, other keywords). It records 
the other errors on the expression, and the reprs of a Column raise PySpark's 
`TypeError`.
   - **Pickling:** a Column of such an expression pickles and copies, as 
PySpark's does, with its errors as `(kind, text, payload)`. Its copy raises 
them as the Column did, also on a Python worker of the server 
(`_column_reduce.column_of`, `raise_error`).
   
   ### Why are the changes needed?
   
   So that `alias` and `name` behave as PySpark's do: when they raise, what 
they raise, and what a Column of them does in `repr`, `copy` and `pickle`.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, as described above. One small difference remains, documented in 
`docs/compatibility.md`: a name of lone surrogates shows escaped in the 
`__repr__`, where PySpark's shows it as it is. A rendering of UTF-8 cannot hold 
a lone surrogate.
   
   ### How was this patch tested?
   
   - Probes on both clients against a Spark 4.3.0 Connect server:
     - 17 alias cases (int, None, bytes, bad bytes, surrogates, several names, 
metadata of none, one and several names, keywords, nested and re-aliased), each 
at the call, in `repr`, and in `select`, `columns`, `withColumn` and `filter`;
     - `groupBy`, `agg`, `orderBy`, a window, `observe`, `sql` args, 
`withColumns`, `explain`, `schema`, `str`, `_expr` and 
`writeTo().partitionedBy`;
     - `copy`, `deepcopy` and `pickle`.
   
     All match, apart from the surrogate repr above. A Column pickled here also 
unpickles in official PySpark's `column_of` path with the same repr and plan 
errors.
   - New tests in `test_dropin_types_columns_offline.py`, plus two core unit 
tests of `ExpressionNode::Unbuildable`.
   - The CI offline list, the core lib tests, the compile of all integration 
tests, clippy 1.100 with `-D warnings`, fmt, the no-stub audit and the vendored 
drift check.
   
   ### 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