HyukjinKwon opened a new pull request, #652:
URL: https://github.com/apache/spark-connect-rust/pull/652
### What changes were proposed in this pull request?
PySpark's Connect client keeps the schema that `DataFrame.to` is given and
the flag that `unionByName` is given, and uses them only when it builds the
plan of a request. The drop-in parsed or checked them at the call. With this
PR, as in PySpark:
- `DataFrame.to` keeps a schema that is not a `DataType`, such as a DDL
string, unparsed, and `.schema` returns it. Each action raises PySpark's
`PySparkValueError` `[UNSUPPORTED_OPERATION]` "data type <schema> is not
supported." when it builds the plan. A None schema is still an `AssertionError`
at the call.
- `unionByName` with an `allowMissingColumns` that a protobuf bool does not
take (None, "x", 1.5, [1]) raises the builtin `TypeError` at the action, and
2**70 raises `OverflowError`. Before, they raised at the call.
- The set operations (`union`, `unionAll`, `unionByName`, `intersect`,
`intersectAll`, `subtract`, `exceptAll`) keep an equal unconverted schema, as
PySpark's `_merge_cached_schema` does.
- `checkpoint` and `localCheckpoint` keep checking their `eager` flag at the
call, since PySpark raises there.
In the Rust crates:
- a new plan node, `LogicalPlan::Unbuildable`, carries the error, and a
request raises it before it serializes the plan, the deepest and leftmost
first, as PySpark builds its plans;
- two new error kinds, `SparkErrorKind::BuiltinTypeError` and
`BuiltinOverflowError`;
- two new `DataFrame` methods for the drop-in, `unbuildable` and
`union_by_name_unbuildable`, hidden from the docs.
### Why are the changes needed?
For parity with PySpark 4.3.0. These are findings of a post-merge review of
#630 (SPARK-61628).
```python
df = spark.range(1)
df.to("a bigint") # before: parsed, and the DataFrame worked
df.to("a foo") # before: an error at the call
df.unionByName(df, "x") # before: TypeError at the call
```
After, as PySpark 4.3.0:
```python
df.to("a foo") # no error; the str is the schema
df.to("a foo").collect() # PySparkValueError
[UNSUPPORTED_OPERATION] data type a foo is not supported.
df.unionByName(df, "x") # no error
df.unionByName(df, "x").collect() # TypeError, as protobuf raises it
```
### Does this PR introduce _any_ user-facing change?
Yes, in the Python client:
- `df.to` of a string no longer parses it, and its actions raise PySpark's
error.
- `unionByName` raises a bad flag at the action.
Still different from PySpark: PySpark keeps an unconverted schema through
about 20 other transformations (`df.to("a bigint").filter(...).schema` returns
`'a bigint'`), while the drop-in raises the action's error there.
### How was this patch tested?
- New and updated offline tests in `python/tests/test_dropin_offline.py`,
three of them checked to fail without the fix, and Rust unit tests of the new
plan node.
- Also passing, with `TZ=UTC`:
- CI's offline Python set: 3709 passed;
- `test_dropin_e2e.py` against Spark 4.3.0: 280 passed;
- the Rust e2e suites `e2e_dataframe`, `e2e_new_methods` and
`e2e_ops_breadth`, and the offline `plans_golden` and `coverage_plan_extra`;
- the Rust lib tests and the `--no-run` builds;
- `cargo fmt`, the stub audit and ruff.
### 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]